Particle + Raspberry Pi
On November 2015, Particle announced that they will be providing a mechanism to connect any Raspberry Pi to their cloud.
Not only can you now connect your Pi to the Particle Cloud and flash it from anywhere effortlessly, but it gives you the ability to run Arduino code in your Raspberry Pi.
And it does not end there. From Particle's site:
No more complicated tooling, setup, or scripting to perform simple tasks like trigger a pin, blink an LED, or read a sensor value. With Particle's Raspberry Pi Agent, you can now program in C/C++, making these tasks easy!
And from their blog here:
- Simple Arduino Code: Use the existing Particle Web IDE and program your Pi with Wiring. No more complicated tooling, setup, or scripting to perform simple tasks like trigger a pin, blink an LED, or read a sensor value.
- Over-the-Air Updates: Safely reprogram code running on your Pi's one at a time in the Web IDE or as a fleet of devices in the Console.
- Batch Script Execution: Remotely execute customized scripts on groups of Raspberry Pi’s using the exec command.
- Remote Data Collection: Collect and publish data to the Particle Cloud, or store it locally by logging it on your Pi.
- Integrations: Integrate with IFTTT, Google Cloud, or Microsoft Azure.
You can sign up for the beta program here. I, on my end, signed up for the beta right away, got my account set up, and started using my Raspberry Pi 3 for the first time couple of weeks ago.
I was mostly interested in how to trigger remote scripts in the Pi, so this article is the first useful thing I came up with.
You can look at this project as my “hello world” with the Particle Cloud + Raspberry Pi. The next use I have for this Rasp Pi is a detection via Bluetooth of my phones around the house. What for? To turn on the away mode of my Minimalist Thermostat automatically when we leave the house. Coming soon!
What is my IP?
Sometimes I need to know my external IP at home. Of course, most of the times when this happens, I am NOT home.
So how was I able to solve this in the past? I would run a script in a Linux server that would email me the external IP address of my home router every single day. Not a good use of bandwidth if you ask me. Today, with the power of the Particle Cloud, I'm able to do this on demand.
The Pi will run a firmware with an exposed cloud function that will print in the Particle Console the external IP of my router at home.
- STEP 1: Register for the BETA here.
- STEP 1 loop: Wait until you get in the beta.
- STEP 2: Install the Particle Agent in your Pi.
- STEP 3: Flash it with the firmware in this project (see code section below). You can use the Particle online IDE, Particle local IDE (called DEV, based on Atom), Visual Studio as described here, or any other option you may be familiar with.
- STEP 4: Start the Particle console (optional).
- STEP 5: Fire up your Particle 2.0 app (iOS only), Porter (iOS and Android), or from a console if you have the Particle CLI installed.
- STEP 6: Call the cloud function
- STEP 7: Observe the IP being printed in the Particle console or in the cloud variable in your Particle app or Porter app.
Read More: What is my IP?