IoT Remote Configuration w/ Arduino & Raspberry Pi

3 min read Michael Carroll on Nov 13, 2014
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

With remote configuration, you can control smart devices from anywhere. This tutorial shows you how to do it with Raspberry Pi, Arduino, and a web browser.

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 real time.
  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 real time.

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


More from PubNub

NPP and HIPAA: Notice of Privacy Practices Definition
Healthcare CategoryJan 6, 20235 min read

NPP and HIPAA: Notice of Privacy Practices Definition

A Notice of Privacy Practices (NPP) is one of the requirements of HIPAA and helps patients understand their personal data rights.

Michael Carroll

Michael Carroll

HIPAA Violation Examples
Healthcare CategoryJan 5, 20236 min read

HIPAA Violation Examples

HIPAA violations can be financially expensive and devastating to a brand. Examine some examples of HIPAA violations, and learn...

Michael Carroll

Michael Carroll

HIPAA Technical Safeguards: How To Protect Sensitive Data
Healthcare CategoryJan 5, 20236 min read

HIPAA Technical Safeguards: How To Protect Sensitive Data

HIPAA covered entities must follow the five technical safeguards to achieve HIPAA compliance and prevent data corruption.

Michael Carroll

Michael Carroll