Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Arm Community blogs
Arm Community blogs
Internet of Things (IoT) blog How to build remote configuration for Arduino devices
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded and Microcontrollers blog

  • Internet of Things (IoT) blog

  • Laptops and Desktops blog

  • Mobile, Graphics, and Gaming blog

  • Operating Systems blog

  • Servers and Cloud Computing blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • internet_of_things
  • Arduino
  • iot
  • home_automation
  • pubnub
  • configuration
  • remote
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

How to build remote configuration for Arduino devices

Joe Hanson
Joe Hanson
November 19, 2014
3 minute read time.

A 'smart' device isn't smart if you can only control it locally. What good is that? You need the ability to control your devices remotely. And that's where remote configuration comes into play. Remote configuration enables developers and users to trigger actions and control their devices from anywhere. The device state interprets a signal that is transferred through a network (in this case, PubNub), and is interpreted to permanently change the state of a device (like a light bulb turning from off to on).

A Messaging Layer for Remote Configuration

In this tutorial, we'll show you how to make remote configuration a reality for [Microchip-based] Arduino connected devices. In developing, we came across two issues.

  1. The need to detect the device state of all connected devices (eg. online/offline status) in realtime
  2. The state of the devices connected to the cloud

The first one can easily be solved using the Presence API, so let's focus on the second issue. We'll be using Storage & Playback to store and retrieve the state of connected devices for a home automation solution. In this case, we'll be able to control smart devices remotely, sending signals in realtime. A typical example of a state will be a JSON object looking like this:

{"state":[    

     {"alive":"true"},    

     {"CoffeeAmount: Half"},    

{"Temperature":"45"} ]}

Overall Procedure for Arduino Remote Configuration

  • Sign up for a free PubNub account. In doing so, you'll get your unique publish/subscribe keys which you'll use to initiate PubNub. These keys can be found in the Developer's Console.
  • Publish messages through the PubNub IoT Network using Arduino to control smart devices.
  • Access these messages through a web browser.

Onto the tutorial!

Step 1: Connect to PubNub

Say we want to control the temperature on a refrigerator. The following parameters can be stored as the state of the device, for example, seeing if the door is open/closed, temperature, power consumption, and even volume of our fridge.

arduino remote configuration home automation Run this on the Arduino IDE, and check out the tutorial on connecting PubNub to Arduino in 2 steps for more details.

Step 2: Create a JSON Object in Arduino

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

aJsonObject *msg = aJson.createObject();

     aJson.addStringToObject(msg, "name", "Arduino");

     aJson.addNumberToObject(msg, "TemperatureOutside", 34);

Step 3: Signaling Devices

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

char pubkey[] = "demo";

char subkey[] = "demo";

char channel[] = "devices_state";

//setup void setup()

{

     Serial.begin(9600);

     Serial.println("Serial set up");

     while (!Ethernet.begin(mac)) {

          Serial.println("Ethernet setup error");

          delay(1000);

          }

          Serial.println("Ethernet set up");

          PubNub.begin(pubkey, subkey);

          Serial.println("PubNub set up");

}

// establishing internet connection to the Arduino and publishing the state void loop()

{

          Ethernet.maintain();

          EthernetClient *client;

          client = PubNub.publish(channel, msg);

          if (!client) {

               Serial.println("publishing error");

          } else {

               client->stop(); }

          delay(5000);

}

And one more thing, what if we were able to check the state of devices in simply a web browser? Paste the code below in a browser console and watch the state be filled in.

// Initialize with Publish & Subscribe Keys

var pubnub = PUBNUB.init({     

     publish_key: 'PUBLISH_KEY_HERE',     

     subscribe_key: 'SUBSCRIBE_KEY_HERE',     

     uuid: 'devices_state'

});

// Retrieving the messages that have been published on to this channel using History.

pubnub.history({     

     channel: 'history_channel',     

     callback: function(m){console.log(JSON.stringify(m))},

});

That's it! Just a note, PubNub doesn't limit the number of messages that you can publish or retrieve via history. You can try this out with as many Arduinos as you want, and check their state remotely.

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.

Anonymous
Internet of Things (IoT) blog
  • Transforming smart home privacy and latency with local LLM inference on Arm devices

    Fidel Makatia
    Fidel Makatia
    Learn how Raspberry Pi 5 and Arm-based local LLM inference can power a fully private, cloud-free smart home assistant with real-time performance
    • August 19, 2025
  • Building vision-enabled devices to capture the emerging wave in IoT

    Diya Soubra
    Diya Soubra
    IoT devices will drive an explosion in use cases with vision. Read more about the different use cases and what Arm technology is involved here.
    • December 9, 2024
  • The power of SystemReady for custom-built OS distributions

    Pere Garcia
    Pere Garcia
    Arm developed the SystemReady Devicetree band as part of the SystemReady program, learn more in this blog post.
    • November 22, 2024