IoT Remote Configuration w/ Arduino & Raspberry Pi

We have connected homes, connected cars, connected watches, and connected clothes, so we need control.

Remote configuration is paramount when it comes to connecting IoT devices. How can we control our garage doors, lights, and toasters from outside the home, anywhere on Earth? The answer is remote configuration.

At PubNub, we decided to make remote configuration a reality, and in doing so, we came across two major issues.

  1. The need to detect the devices that are online/offline in realtime.
  2. The state of the devices connected to the cloud.

The first one can be easily solved using PubNub’s Presence API. I’ll be focusing on the second issue. This tutorial digs into PubNub Storage & Playback to store and retrieves the state of connected devices in a home. This enables you to control smart devices, not just in your home, but from any location in realtime.

A typical example of a state will be a JSON object looking like this:

To get remote configuration up and running, here’s the overall procedure.

  • Signup for a free PubNub account and get your unique publish/subscribe keys from the Developer’s Console.
  • Publish messages to the PubNub Data Stream Network using the Raspberry Pi and Arduino to control your home devices
  • Access these messages through your web browser of choice.

Scenario 1: Raspberry Pi Remote Configuration

In this scenario, think of opening your garage door or turning on your house’s heater from anywhere! We’ll be using Storage & Playback to store device state using publish. This’ll run on your Raspberry Pi, check out my tutorial on connecting your Raspberry Pi in 2 steps for a detailed tutorial to connect the Raspberry Pi to PubNub.

Scenario 2: Arduino Remote Configuration

Let’s control our coffee maker using Arduino. The following parameters could be stored as the state of the device, for example triggering on/off, time that coffee was last made, amount of coffee stored in the machine. Run this on the Arduino IDE, and check out my tutorial on connecting PubNub to Arduino in 2 steps for more detailed steps.

To create a json object in Arduino, we use the JSON.h library. The above JSON object can be created using the following.

Other than that, it’s just about publishing a message using the Arduino IDE. The following code lets you do just that:

Scenario 3: Browser Application Remote Configuration

Now imagine being anywhere in the world and being able to check the state of your devices by just opening an application or web page. Paste the below code into your browser console, and see the state being filled in.

Unlimited Messages

Remote Configuration IoT 2PubNub does not limit the number of messages that you publish nor the messages that you can retrieve as part of history. Try this out with as many Arduino and Rapsberry Pi’s as possible and check out their state on the fly.

The use cases are endless for remote configuration, from agriculture to shipping and logistics, to home automation. It gives you complete control over your smart devices from anywhere on Earth, and that’s powerful.

IoT Resources


Try PubNub Today

Connect up to 100 devices for Free