ESP RainMaker Sensor Update Values
-
- Posts: 27
- Joined: Thu Feb 17, 2022 4:41 am
ESP RainMaker Sensor Update Values
Hi, I am trying to see how to update a temp sensor values in the rainmaker app. I am using arduino ide this is the callback function im using:
void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
const char *device_name = device->getDeviceName();
const char *param_name = param->getParamName();
if (strcmp(param_name, "Temperature F") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_temperature = val.val.f;
param->updateAndReport(val);
}
if (strcmp(param_name, "Humidity Rh") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_humidity = val.val.f;
param->updateAndReport(val);
}
}
However; the sensor value doesn't get updated it just stays the same. How can I get it to update. Thanks.
void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
const char *device_name = device->getDeviceName();
const char *param_name = param->getParamName();
if (strcmp(param_name, "Temperature F") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_temperature = val.val.f;
param->updateAndReport(val);
}
if (strcmp(param_name, "Humidity Rh") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_humidity = val.val.f;
param->updateAndReport(val);
}
}
However; the sensor value doesn't get updated it just stays the same. How can I get it to update. Thanks.
-
- Posts: 16
- Joined: Mon Oct 25, 2021 4:15 am
Re: ESP RainMaker Sensor Update Values
Have you attached the callback to the device? Are you able to see serial print output?
-
- Posts: 27
- Joined: Thu Feb 17, 2022 4:41 am
Re: ESP RainMaker Sensor Update Values
Hi, how should the callback function look like cuz mine it not doing anything. This is my callback function:
void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
const char *device_name = device->getDeviceName();
const char *param_name = param->getParamName();
if (strcmp(param_name, "Temperature F") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_temperature = val.val.f;
param->updateAndReport(val);
}
if (strcmp(param_name, "Humidity Rh") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_humidity = val.val.f;
param->updateAndReport(val);
}
}
However; the updateandReport fucntion is not updating the param as it should do. Any suggestion as why that might be.
void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
const char *device_name = device->getDeviceName();
const char *param_name = param->getParamName();
if (strcmp(param_name, "Temperature F") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_temperature = val.val.f;
param->updateAndReport(val);
}
if (strcmp(param_name, "Humidity Rh") == 0) {
Serial.printf("Received value = %2.2f for %s - %s\n", val.val.f, device_name, param_name);
dht_humidity = val.val.f;
param->updateAndReport(val);
}
}
However; the updateandReport fucntion is not updating the param as it should do. Any suggestion as why that might be.
-
- Posts: 16
- Joined: Mon Oct 25, 2021 4:15 am
Re: ESP RainMaker Sensor Update Values
Your callback functions looks alright. My question here is when you start the serial monitor do you see the Serial.prints going through? it maybe because you might nto have attached write_callback to your dht device.
Refer to official example -> https://github.com/espressif/arduino-es ... Switch.ino
Refer to official example -> https://github.com/espressif/arduino-es ... Switch.ino
Code: Select all
//Standard switch device
my_switch.addCb(write_callback);
//Add switch device to the node
my_node.addDevice(my_switch);
-
- Posts: 27
- Joined: Thu Feb 17, 2022 4:41 am
Re: ESP RainMaker Sensor Update Values
Yes I do have it, but it still doesn't update it just reads the first value after flashing the device and after that it just stays the same.
This is what I have:
Node my_sensor;
my_sensor = RMaker.initNode("Sensor Node");
DHT_Sensor.addCb(write_callback);
my_sensor.addDevice(DHT_Sensor);
But I cant figure out why it doesn't update the values.
This is what I have:
Node my_sensor;
my_sensor = RMaker.initNode("Sensor Node");
DHT_Sensor.addCb(write_callback);
my_sensor.addDevice(DHT_Sensor);
But I cant figure out why it doesn't update the values.
-
- Posts: 16
- Joined: Mon Oct 25, 2021 4:15 am
Re: ESP RainMaker Sensor Update Values
Oh Hold On. write_callback gets called from the cloud if the "User" tried to write any value.
From my understanding Temperature and Humidity should be be a read only param. A User wont write the value of temperature from the App so a write callback wont be called.
Try to update the param value after you read the readings from the sensor in your loop function.
From my understanding Temperature and Humidity should be be a read only param. A User wont write the value of temperature from the App so a write callback wont be called.
Try to update the param value after you read the readings from the sensor in your loop function.
Code: Select all
DHT_Sensor.updateAndReportParam("Temperature F", temp_val);
-
- Posts: 27
- Joined: Thu Feb 17, 2022 4:41 am
Re: ESP RainMaker Sensor Update Values
Thanks, already figure it out.
Re: ESP RainMaker Sensor Update Values
Do you still have the code?
im struggleing really bad whit mine
I cant make rainmaker read the sensor, but the esp can
when i open the serial monitor and i try to print the parameters, it pull out this message
this is the code
- #include "RMaker.h"
- #include "WiFi.h"
- #include "WiFiProv.h"
- #include <Adafruit_AHTX0.h>
- #include <SimpleTimer.h>
- const char *service_name = "Indoor Control Unit";
- const char *pop = "1234567";
- void Send_Sensor();
- // define the Device Names
- char deviceName_1[] = "Iluminación 1";
- char deviceName_2[] = "Iluminación 2";
- char deviceName_3[] = "Riego 1";
- char deviceName_4[] = "Riego 2";
- char deviceName_5[] = "Frio";
- char deviceName_6[] = "Calor";
- char deviceName_7[] = "Ventilación 1";
- char deviceName_8[] = "Ventilación 2";
- char deviceName_9[] = "Temperatura";
- char deviceName_10[] = "Humedad";
- // define the GPIO connected with Relays and switches
- static uint8_t RelayPin1 = 13; //D23
- static uint8_t RelayPin2 = 12; //D22
- static uint8_t RelayPin3 = 14; //D21
- static uint8_t RelayPin4 = 27; //D19
- static uint8_t RelayPin5 = 26; //D18
- static uint8_t RelayPin6 = 25; //D5
- static uint8_t RelayPin7 = 33; //D25
- static uint8_t RelayPin8 = 32; //D26
- static uint8_t SwitchPin1 ; //D13
- static uint8_t SwitchPin2 ; //D12
- static uint8_t SwitchPin3 ; //D14
- static uint8_t SwitchPin4 ; //D27
- static uint8_t SwitchPin5 ; //D33
- static uint8_t SwitchPin6 ; //D32
- static uint8_t SwitchPin7 ; //D15
- static uint8_t SwitchPin8 ; //D4
- static uint8_t wifiLed = 2; //D2
- static uint8_t gpio_reset = 0;
- /* Variable for reading pin status*/
- // Relay State
- bool toggleState_1 = true; //Define integer to remember the toggle state for relay 1
- bool toggleState_2 = true; //Define integer to remember the toggle state for relay 2
- bool toggleState_3 = true; //Define integer to remember the toggle state for relay 3
- bool toggleState_4 = true; //Define integer to remember the toggle state for relay 4
- bool toggleState_5 = true; //Define integer to remember the toggle state for relay 5
- bool toggleState_6 = true; //Define integer to remember the toggle state for relay 6
- bool toggleState_7 = true; //Define integer to remember the toggle state for relay 7
- bool toggleState_8 = true; //Define integer to remember the toggle state for relay 8
- float temperatura = 0;
- float humedad = 0;
- // Switch State
- bool SwitchState_1 = true;
- bool SwitchState_2 = true;
- bool SwitchState_3 = true;
- bool SwitchState_4 = true;
- bool SwitchState_5 = true;
- bool SwitchState_6 = true;
- bool SwitchState_7 = true;
- bool SwitchState_8 = true;
- Adafruit_AHTX0 aht;
- SimpleTimer Timer;
- //The framework provides some standard device types like switch, lightbulb, fan, temperature sensor.
- static LightBulb my_switch1(deviceName_1, &RelayPin1);
- static LightBulb my_switch2(deviceName_2, &RelayPin2);
- static Switch my_switch3(deviceName_3, &RelayPin3);
- static Switch my_switch4(deviceName_4, &RelayPin4);
- static Switch my_switch5(deviceName_5, &RelayPin5);
- static Switch my_switch6(deviceName_6, &RelayPin6);
- static Fan my_switch7(deviceName_7, &RelayPin7);
- static Fan my_switch8(deviceName_8, &RelayPin8);
- static TemperatureSensor my_switch9(deviceName_9);
- static TemperatureSensor my_switch10(deviceName_10);
- void sysProvEvent(arduino_event_t *sys_event)
- {
- switch (sys_event->event_id) {
- case ARDUINO_EVENT_PROV_START:
- #if CONFIG_IDF_TARGET_ESP32
- Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
- printQR(service_name, pop, "ble");
- #else
- Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
- printQR(service_name, pop, "softap");
- #endif
- break;
- case ARDUINO_EVENT_WIFI_STA_CONNECTED:
- Serial.printf("\nConnected to Wi-Fi!\n");
- digitalWrite(wifiLed, true);
- break;
- }
- }
- void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
- {
- const char *device_name = device->getDeviceName();
- const char *param_name = param->getParamName();
- if(strcmp(device_name, deviceName_1) == 0) {
- Serial.printf("Lightbulb = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_1 = val.val.b;
- (toggleState_1 == false) ? digitalWrite(RelayPin1, LOW) : digitalWrite(RelayPin1, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_2) == 0) {
- Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_2 = val.val.b;
- (toggleState_2 == false) ? digitalWrite(RelayPin2, LOW) : digitalWrite(RelayPin2, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_3) == 0) {
- Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_3 = val.val.b;
- (toggleState_3 == false) ? digitalWrite(RelayPin3, LOW) : digitalWrite(RelayPin3, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_4) == 0) {
- Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_4 = val.val.b;
- (toggleState_4 == false) ? digitalWrite(RelayPin4, LOW) : digitalWrite(RelayPin4, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_5) == 0) {
- Serial.printf("Lightbulb = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_5 = val.val.b;
- (toggleState_5 == false) ? digitalWrite(RelayPin5, LOW) : digitalWrite(RelayPin5, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_6) == 0) {
- Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_6 = val.val.b;
- (toggleState_6 == false) ? digitalWrite(RelayPin6, LOW) : digitalWrite(RelayPin6, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_7) == 0) {
- Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_7 = val.val.b;
- (toggleState_7 == false) ? digitalWrite(RelayPin7, LOW) : digitalWrite(RelayPin7, HIGH);
- param->updateAndReport(val);
- }
- } else if(strcmp(device_name, deviceName_8) == 0) {
- Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
- if(strcmp(param_name, "Power") == 0) {
- Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
- toggleState_8 = val.val.b;
- (toggleState_8 == false) ? digitalWrite(RelayPin8, LOW) : digitalWrite(RelayPin8, HIGH);
- param->updateAndReport(val);
- }
- }
- }
- void manual_control()
- {
- if (digitalRead(SwitchPin1) == LOW && SwitchState_1 == LOW) {
- digitalWrite(RelayPin1, LOW);
- toggleState_1 = 1;
- SwitchState_1 = HIGH;
- my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_1);
- Serial.println("Switch-1 on");
- }
- if (digitalRead(SwitchPin1) == HIGH && SwitchState_1 == HIGH) {
- digitalWrite(RelayPin1, HIGH);
- toggleState_1 = 0;
- SwitchState_1 = LOW;
- my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_1);
- Serial.println("Switch-1 off");
- }
- if (digitalRead(SwitchPin2) == LOW && SwitchState_2 == LOW) {
- digitalWrite(RelayPin2, LOW);
- toggleState_2 = 1;
- SwitchState_2 = HIGH;
- my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_2);
- Serial.println("Switch-2 on");
- }
- if (digitalRead(SwitchPin2) == HIGH && SwitchState_2 == HIGH) {
- digitalWrite(RelayPin2, HIGH);
- toggleState_2 = 0;
- SwitchState_2 = LOW;
- my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_2);
- Serial.println("Switch-2 off");
- }
- if (digitalRead(SwitchPin3) == LOW && SwitchState_3 == LOW) {
- digitalWrite(RelayPin3, LOW);
- toggleState_3 = 1;
- SwitchState_3 = HIGH;
- my_switch3.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_3);
- Serial.println("Switch-3 on");
- }
- if (digitalRead(SwitchPin3) == HIGH && SwitchState_3 == HIGH) {
- digitalWrite(RelayPin3, HIGH);
- toggleState_3 = 0;
- SwitchState_3 = LOW;
- my_switch3.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_3);
- Serial.println("Switch-3 off");
- }
- if (digitalRead(SwitchPin4) == LOW && SwitchState_4 == LOW) {
- digitalWrite(RelayPin4, LOW);
- toggleState_4 = 1;
- SwitchState_4 = HIGH;
- my_switch4.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_4);
- Serial.println("Switch-4 on");
- }
- if (digitalRead(SwitchPin4) == HIGH && SwitchState_4 == HIGH) {
- digitalWrite(RelayPin4, HIGH);
- toggleState_4 = 0;
- SwitchState_4 = LOW;
- my_switch4.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_4);
- Serial.println("Switch-4 off");
- }
- if (digitalRead(SwitchPin5) == LOW && SwitchState_5 == LOW) {
- digitalWrite(RelayPin5, LOW);
- toggleState_5 = 1;
- SwitchState_5 = HIGH;
- my_switch5.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_5);
- Serial.println("Switch-5 on");
- }
- if (digitalRead(SwitchPin5) == HIGH && SwitchState_5 == HIGH) {
- digitalWrite(RelayPin5, HIGH);
- toggleState_5 = 0;
- SwitchState_5 = LOW;
- my_switch5.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_5);
- Serial.println("Switch-5 off");
- }
- if (digitalRead(SwitchPin6) == LOW && SwitchState_6 == LOW) {
- digitalWrite(RelayPin6, LOW);
- toggleState_6 = 1;
- SwitchState_6 = HIGH;
- my_switch6.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_6);
- Serial.println("Switch-6 on");
- }
- if (digitalRead(SwitchPin6) == HIGH && SwitchState_6 == HIGH) {
- digitalWrite(RelayPin6, HIGH);
- toggleState_6 = 0;
- SwitchState_6 = LOW;
- my_switch6.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_6);
- Serial.println("Switch-6 off");
- }
- if (digitalRead(SwitchPin7) == LOW && SwitchState_7 == LOW) {
- digitalWrite(RelayPin7, LOW);
- toggleState_7 = 1;
- SwitchState_7 = HIGH;
- my_switch7.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_7);
- Serial.println("Switch-7 on");
- }
- if (digitalRead(SwitchPin7) == HIGH && SwitchState_7 == HIGH) {
- digitalWrite(RelayPin7, HIGH);
- toggleState_7 = 0;
- SwitchState_7 = LOW;
- my_switch7.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_7);
- Serial.println("Switch-7 off");
- }
- if (digitalRead(SwitchPin8) == LOW && SwitchState_8 == LOW) {
- digitalWrite(RelayPin8, LOW);
- toggleState_8 = 1;
- SwitchState_8 = HIGH;
- my_switch8.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_8);
- Serial.println("Switch-8 on");
- }
- if (digitalRead(SwitchPin8) == HIGH && SwitchState_8 == HIGH) {
- digitalWrite(RelayPin8, HIGH);
- toggleState_8 = 0;
- SwitchState_8 = LOW;
- my_switch8.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_8);
- Serial.println("Switch-8 off");
- }
- }
- void setup()
- {
- uint32_t chipId = 0;
- Serial.begin(115200);
- Timer.setInterval(500);
- // Set the Relays GPIOs as output mode
- pinMode(RelayPin1, OUTPUT);
- pinMode(RelayPin2, OUTPUT);
- pinMode(RelayPin3, OUTPUT);
- pinMode(RelayPin4, OUTPUT);
- pinMode(RelayPin5, OUTPUT);
- pinMode(RelayPin6, OUTPUT);
- pinMode(RelayPin7, OUTPUT);
- pinMode(RelayPin8, OUTPUT);
- pinMode(wifiLed, OUTPUT);
- // Configure the input GPIOs
- pinMode(SwitchPin1, INPUT_PULLUP);
- pinMode(SwitchPin2, INPUT_PULLUP);
- pinMode(SwitchPin3, INPUT_PULLUP);
- pinMode(SwitchPin4, INPUT_PULLUP);
- pinMode(SwitchPin5, INPUT_PULLUP);
- pinMode(SwitchPin6, INPUT_PULLUP);
- pinMode(SwitchPin7, INPUT_PULLUP);
- pinMode(SwitchPin8, INPUT_PULLUP);
- pinMode(gpio_reset, INPUT);
- // Write to the GPIOs the default state on booting
- digitalWrite(RelayPin1, !toggleState_1);
- digitalWrite(RelayPin2, !toggleState_2);
- digitalWrite(RelayPin3, !toggleState_3);
- digitalWrite(RelayPin4, !toggleState_4);
- digitalWrite(RelayPin5, !toggleState_5);
- digitalWrite(RelayPin6, !toggleState_6);
- digitalWrite(RelayPin7, !toggleState_7);
- digitalWrite(RelayPin8, !toggleState_8);
- digitalWrite(wifiLed, LOW);
- if (aht.begin()) {
- Serial.println("Found AHT10");
- } else {
- Serial.println("Didn't find AHT10");
- }
- Node my_node;
- my_node = RMaker.initNode("InDoor Control Unit");
- //Standard switch device
- my_switch1.addCb(write_callback);
- my_switch2.addCb(write_callback);
- my_switch3.addCb(write_callback);
- my_switch4.addCb(write_callback);
- my_switch5.addCb(write_callback);
- my_switch6.addCb(write_callback);
- my_switch7.addCb(write_callback);
- my_switch8.addCb(write_callback);
- //Add switch device to the node
- my_node.addDevice(my_switch1);
- my_node.addDevice(my_switch2);
- my_node.addDevice(my_switch3);
- my_node.addDevice(my_switch4);
- my_node.addDevice(my_switch5);
- my_node.addDevice(my_switch6);
- my_node.addDevice(my_switch7);
- my_node.addDevice(my_switch8);
- my_node.addDevice(my_switch9);
- my_node.addDevice(my_switch10);
- //This is optional
- RMaker.enableOTA(OTA_USING_PARAMS);
- //If you want to enable scheduling, set time zone for your region using setTimeZone().
- //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
- // RMaker.setTimeZone("Asia/Shanghai");
- // Alternatively, enable the Timezone service and let the phone apps set the appropriate timezone
- RMaker.enableTZService();
- RMaker.enableSchedule();
- //Service Name
- for(int i=0; i<17; i=i+8) {
- chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
- }
- Serial.printf("\nChip ID: %d Service Name: %s\n", chipId, service_name);
- Serial.printf("\nStarting ESP-RainMaker\n");
- RMaker.start();
- WiFi.onEvent(sysProvEvent);
- #if CONFIG_IDF_TARGET_ESP32
- WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
- #else
- WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
- #endif
- my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch3.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch4.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch5.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch6.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch7.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch8.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch9.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- my_switch10.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
- }
- void loop()
- {
- if(Timer.isReady()){
- Serial.println("Sending Sensor´s Data");
- Send_Sensor();
- Timer.reset();
- }
- // Read GPIO0 (external button to reset device
- if(digitalRead(gpio_reset) == LOW) { //Push button pressed
- Serial.printf("Reset Button Pressed!\n");
- // Key debounce handling
- delay(100);
- int startTime = millis();
- while(digitalRead(gpio_reset) == LOW) delay(50);
- int endTime = millis();
- if ((endTime - startTime) > 10000) {
- // If key pressed for more than 10secs, reset all
- Serial.printf("Reset to factory.\n");
- RMakerFactoryReset(2);
- } else if ((endTime - startTime) > 3000) {
- Serial.printf("Reset Wi-Fi.\n");
- // If key pressed for more than 3secs, but less than 10, reset Wi-Fi
- RMakerWiFiReset(2);
- }
- }
- //delay(100);
- if (WiFi.status() != WL_CONNECTED)
- {
- //Serial.println("WiFi Not Connected");
- digitalWrite(wifiLed, false);
- }
- else
- {
- //Serial.println("WiFi Connected");
- digitalWrite(wifiLed, true);
- }
- //manual_control();
- }
- void Send_Sensor()
- {
- sensors_event_t humidity, temp;
- aht.getEvent(&humidity, &temp);
- temperatura = temp.temperature;
- humedad = humidity.relative_humidity;
- Serial.print("Temperatura: ");
- Serial.println(temperatura);
- Serial.print("Humedad: ");
- Serial.println(humedad);
- my_switch9.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, temperatura);
- my_switch10.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, humedad);
- }
Re: ESP RainMaker Sensor Update Values
In the serial monitor i can see the variablesendlessparadigm wrote: ↑Sun Feb 20, 2022 11:50 pmHave you attached the callback to the device? Are you able to see serial print output?
this two:
Serial.println(temperatura);
and
Serial.println(humedad);
but i get null when y try to update to the app
my_switch9.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, temperatura);
my_switch10.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, humedad);
im using Rainmaker 2.0.3 because with 2.0.4 i had problems conecting with the app
- void Send_Sensor()
- {
- sensors_event_t humidity, temp;
- aht.getEvent(&humidity, &temp);
- temperatura = temp.temperature;
- humedad = humidity.relative_humidity;
- Serial.print("Temperatura: ");
- Serial.println(temperatura);
- Serial.print("Humedad: ");
- Serial.println(humedad);
- my_switch9.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, temperatura);
- my_switch10.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, humedad);
- }
-
- Posts: 32
- Joined: Tue Jul 26, 2022 10:08 am
Re: ESP RainMaker Sensor Update Values
Hello,ZANTERA wrote: ↑Wed Nov 30, 2022 3:42 amIn the serial monitor i can see the variablesendlessparadigm wrote: ↑Sun Feb 20, 2022 11:50 pmHave you attached the callback to the device? Are you able to see serial print output?
this two:
Serial.println(temperatura);
and
Serial.println(humedad);
but i get null when y try to update to the app
my_switch9.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, temperatura); my_switch10.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, humedad);
In the above code, you have passed ESP_RMAKER_DEF_POWER_NAME as a parameter name, but the device you've created is Temperature Sensor which does not have a parameter named "Power". If you want to update the temperature value of the sensor, pass ESP_RMAKER_DEF_TEMPERATURE_NAME instead.
Code: Select all
my_switch9.updateAndReportParam(ESP_RMAKER_DEF_TEMPERATURE_NAME, temperatura);
my_switch10.updateAndReportParam(ESP_RMAKER_DEF_TEMPERATURE_NAME, humedad);
Who is online
Users browsing this forum: No registered users and 34 guests