Can't communicate devices

Hi everybody

I’m trying to communicate two devices according to the example of the documentation section but i can’t. The idea is to set a value on Device A from Device B using call.device() function

Device A

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

unsigned long int previous_millis = 0;
int val1 = 0;
int val2 = 0;

void setup() {

  Serial.begin(115200);

  if(WiFi.status() != WL_CONNECTED)
  {
    Serial.print("Connecting");
    WiFi.begin(SSID_NAME, SSID_PASSWORD);
    
    while (WiFi.status() != WL_CONNECTED)
    {
      delay(500);
      Serial.print(".");
    }
    Serial.println();
  }

    thing["resourceOnA"] << [](pson& in){
        val1 = in["anyValue1"];
        val2 = in["anyValue2"];
        // Work with the updated parameters here
    };

}

void loop() {
  thing.handle();

  if(millis() - previous_millis > CALL_DEVICE_INTERVAL)   //Wait some time
  {
    Serial.println(val1);
    Serial.println(val2);
  }
}

Device B

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

unsigned long int previous_millis = 0;

void setup() {

  Serial.begin(115200);

  if(WiFi.status() != WL_CONNECTED)
  {
    Serial.print("Connecting");
    WiFi.begin(SSID_NAME, SSID_PASSWORD);
    
    while (WiFi.status() != WL_CONNECTED)
    {
      delay(500);
      Serial.print(".");
    }
    Serial.println();
  }
}

void loop() {
  thing.handle();
    // be sure to call it at an appropiate rate

  if(millis() - previous_millis > CALL_DEVICE_INTERVAL)
  {
    previous_millis = millis();
    pson data;
    data["anyValue1"] = 3;
    data["anyValue2"] = 43.1;
    thing.call_device("deviceA", "resourceOnA", data);
  }
}

In my dashboard i have other resources defined (those of the project i’ve been working in)

What is the problem? val1 and val2 are always 0

Thanks in advance

I’m trying even a simpler thing, and i still can’t communicate one device with another

Device A (prueba1)

#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>

//Here the user name
#define DEVICE_ID "prueba1"
#define DEVICE_CREDENTIAL "Z0SewXS47%!!"

#define SSID_NAME "Feli"
#define SSID_PASSWORD "holahola"

#define CALL_DEVICE_INTERVAL 1000

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
unsigned long int previous_millis = 0;

void setup() {

  Serial.begin(115200);
  thing.add_wifi(SSID_NAME, SSID_PASSWORD);
  delay(5000);

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

void loop() {
  thing.handle();
}

Device B

#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>

//Here the user
#define DEVICE_ID "Sensor_movimiento_01"
#define DEVICE_CREDENTIAL "XjNCM8WtHl%C"

#define CALL_DEVICE_INTERVAL 10000 //(I will call other device every 10 seconds)

#define SSID_NAME "Feli"
#define SSID_PASSWORD "holahola"

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

unsigned long int previous_millis = 0;

void setup() {

  Serial.begin(115200);

  thing.add_wifi(SSID_NAME, SSID_PASSWORD);
  delay(5000);

void loop() {
  thing.handle();
    // be sure to call it at an appropiate rate

  if(millis() - previous_millis > CALL_DEVICE_INTERVAL)
  {
    previous_millis = millis();
    
    thing.call_device("prueba1", "resourceOnA");
    Serial.println("Call");  
  }
}

Please help!! I tried with 2 different Internet connections (my home router and my smartphone)

I don’t know what else to do!!!

Hi, it should be working now! We have recently updated the server to cover this issue.

Best!

I couldnt do it two days ago with cloud console and own deploy on ubuntu (fresh install)

Is it the server deployment updated too?

Thanks in advance

I just test the device call, it is working with no issues :+1:

Thanks again @alvarolb

1 Like