Receiving and using data from another device

Hi all,

I can’t seem to get my head around working with data send from another device. This is what I want to do:
Device A collects biometric data and sends that out. I don’t want to send it to any specific device because I want more devices to be able to use the same data. That seems to be working because I can see it in my dashboard. Here is the data structure:

void setup() {
  thing["Breath"] >> [](pson& out){
        out["top"] = brTopVal;
        out["bot"] = brBotVal;
    thing["HeartRate"] >> [](pson& out){
        out["beat"] = sendBeat; // boolean
        out["hr"] = myHeartRate;
        out["ibi"] = secsElapsed;

But now I want to work with this data in another device. Eventually I want an led to blink at the rythm of the heartbeat. Here’s my code. But I only get zero values, the led stays off. No data seems to be coming in…

boolean beat;
float hr;
float ibi;

void setup() {
  thing.add_wifi(SSID, SSID_PASSWORD);
  // init led

  thing["led"] << [](pson& in){
    hr = in["hr"];
    ibi = in["ibi"];
    beat = in["beat"];

void loop() {
  thing.call_device("deviceA", "HeartRate");
  digitalWrite(LED_BUILTIN, beat ? HIGH : LOW); // stays off
  Serial.println(hr); // output 0.0
    Serial.println(ibi); // output 0.0
    Serial.println(beat); // output 0

There must be something basic that I am not getting. I would be very grateful for any help. Thanks in advance for your time and efford. Danielle.

The communication between devices is not designed for asking values, it is designed to send values, I mean, the device A should send values to the device B, not the device B ask for values to device A (it can be done but not by the native way).

Be careful how often do you call this instruction, because as it is written, it will be called maybe more than hundred times in a second.

Thanks Ega,

I seems not logical to me that I can’t read data from one source. I seems to me that it would be much more logical to have a device output the data and I can add as many other devices I want to use that data… And also:

In the documentation they give the following example:
The deviceA defines a resource like in the following example.

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

deviceB can easily call this method by running the following command.

    // be sure to call it at an appropiate rate
    thing.call_device("deviceA", "resourceOnA");

This means that B is listening to A right? I can’t get this example to work though…

Can you please give me an example of how to do it in a non native way?

Thank you very much.

Hello @danielle_r,

I can confirm that Ega is right. Although… this section is not very intuitive in our documentation, but I will try to explain a little more: In this example, deviceB is sending data to deviceA in an active way, but deviceB cannot request information from deviceA.

You could always do it with a double message: deviceB sends deviceA a call_device instruction sending its identifier, then deviceA resumes it and sends the data to that deviceID. Another option would be store deviceA data in a data bucket and retrieve it with the other devices but this only can be done with a Platfomr privated instance due to the bucket writting limitations.


It seems not logical according your need, but I think this feature is designed kind of “Master-Slave” communication, so the Master orders to run a procedure, or gives some values to the Slave.

So as jtrinc26 says, you can do it by a double message, kind of device B gives order to device A to send values to device B, it’s kind a request disguised :wink:

Another non native way to do it is making a HTTP request directly to the device, I like this more because you don’t need to modify the device A’s sketch, and you can access it from unlimited devices

You need to build the link to access your device’s resource (THING_NAME), just modify the fields between [ ][YOUR_USERNAME]/devices/[DEVICE_NAME]/[THING_NAME]?authorization=[ACCESS_TOKEN]

The access token could be generated by the “Access tokens” link on the platform, or you can use one generated directly at the device’s dashboard, with access to “THING_NAME” resource.

You can test if its working the request by the browser, it must show you the data in a json format.

Once you have the right link to the device that you want to read the actual values, apply this, it is explained to apply with a bucket, but its the same work consulting the device by http

Hope this helps

1 Like

That is an amazing idea Ega! :+1::+1:

Right? So amazing that it doesn’t seem mine :rofl: