My thinger.io read data one time

hi, guys, I’m working with Arduino Uno WiFi Rev2 using DHTT sensors to read Temperature and Humidity levels. However, I’m trying to send my data to the thinger.io my device connect but it shows me just one data and then doesn’t update it.

this is the code im working with:

#include <WiFiNINA.h>
#define _DISABLE_TLS_
#define _DEBUG_
#include "dht.h"
#define dht_apin A0
dht DHT;

#include <SPI.h>
#include <ThingerWifi.h>

#define USERNAME "USERNAME"
#define DEVICE_ID "DEVICE_ID"
#define DEVICE_CREDENTIAL "DEVICE_CREDENTIAL"

#define SSID "SSID"
#define SSID_PASSWORD "SSID_PASSWORD"

ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);


void setup() {
Serial.begin(9600);
DHT.read11(dht_apin);


// configure wifi network
thing.add_wifi(SSID, SSID_PASSWORD);

thing["TempC"] >> outputValue(DHT.temperature);                                        
thing["Humidity"] >> outputValue(DHT.humidity);



}



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

Hello @Sara_baiker

I’m not pretty sure about how does that DHT library works but, it seems that DHT-read11(); instruction needs to be executed eventually to upgrade the values.

to make sure about the behavior I recommend you using other resource structure, including this instruction in the callback of the resource (you can also include some serial printing to be sure):

void setup() {
 Serial.begin(9600);
 // configure wifi network
 thing.add_wifi(SSID, SSID_PASSWORD);

 thing["environmental"]>>[](pson & out){
  DHT.read11(dht_apin);
  out["TempC"] =DHT.temperature;                                        
  out["Humidity"] =DHT.humidity;
 };
}

By doing this you will be able to store both variables into the same Data Bucket too.

Hope it helps!

1 Like

thanks, it’s working now