IoT Remote Configuration w/ Arduino & Raspberry Pi

3 min readPubNub Staff 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

Can Empathy Exist in the Metaverse
News May 16, 20221 min read

Can Empathy Exist in the Metaverse

A roundtable discussion led by PubNub’s COO, Casey Clegg, exploring the topics of what it means to be human in a virtual world.

PubNub Staff

PubNub Staff

How to Advance Telehealth and Virtual Care Technologies
News May 2, 20221 min read

How to Advance Telehealth and Virtual Care Technologies

Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...

PubNub Staff

PubNub Staff

Another Step Towards Data Security: ISO-27001 Implementation
BuildMay 2, 20221 min read

Another Step Towards Data Security: ISO-27001 Implementation

Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.

PubNub Staff

PubNub Staff