Communication Between Devices in IoT

Communication Between Devices in IoT

In this post we want to introduce a new feature released in the latests server updates and Arduino libraries (starting at 2.5.0). This feature is related to inter-device communication in real-time, both for devices of the same account, or devices from different accounts.

In, it is possible that devices can communicate between them trough the Internet in real-time. Imagine you have two ESP8266, or any other micro connected to the Internet, that needs to communicate for some reason. Suppose that you are building some automation mechanism, like turning on your home heater when you leave the office, or a system that automatically opens your garage door when you are getting home. One device can be established in your home, and other device in your office, your car, and so on. In this context, it can be very useful that your devices can communicate in real-time for sharing information, so they can complete complex actions.

There are two possibilities here. The first one is the communication between devices from the same account, and the second one is the communication between devices from different accounts. covers both alternatives.

Communication between devices (from the same account) is as simple as calling a new function in your code, called call_device. This new function allows to specify the target device id, the target resource, and optional data that can be transmitted in the call.

For example, suppose you have two devices, deviceA, and deviceB. The deviceA defines a resource like in the following example.

    thing[“resourceOnA”] = [](){
        Serial.println("Someone is calling me!");

Device deviceB can easily execute the resource resourceOnA method by calling the following method.

    // here you can call the device resource when your condition is met
    thing.call_device("deviceA", "resourceOnA");

In this way, the device deviceB is calling the resource resourceOnA in device deviceA as required. This communication is currently done in unicast, but there are plans for supporting multicast schemes.

Take a look to the Arduino documentation to see how to transmit information while calling a device, or how to call a device from a different account.

Arduino Documentation: Communication between devices 

Share this post

Comments (2)

  • David Reply

    I’ve surprised myself and got this working!! I’m not a programmer but found it wasn’t too hard to get this up and running following your blog. I then got an analog input on one ESP8266 device controlling an LED on another ESP8266 directly. I’ve been looking for a while for a system to get one device to control another device without a dashboard or user intervention, finally it is working!! I’m very impressed with this Platform, keep up the good work!!

    November 21, 2016 at 11:51 pm
    • student Reply

      Hi David!
      how did u do it can u help me
      i really need it

      November 7, 2017 at 12:40 am

Leave a Reply

Your email address will not be published. Required fields are marked *