Free up to 1MM monthly messages. No credit card required.
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.
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.
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.
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:
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.
PubNub 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.
Comparing the major game engines: Unity vs Unreal Engine vs Corona SDK vs GameMaker Studio, including the benefits and cons of...
Sockets (aka socket programming) enable programs to send and receive data, bi-directionally, at any given moment. This tutorial...