Hi all, I am trying to read DHT22 sensor data and activate LED through on/off button.
My hardware configuration is using arduino mega + esp 8266 though GSMlibrary using AT commands.
I find that sometimes the value widget display my sensor value and sometime don’t. This is the same for the button widget and I can’t figure out why. I tried to make my loop function as simple as possible and change my wifi connection to use my phone hotspot, still the same.
This is my code
#define DEBUG
#include <ThingerESP8266AT.h>
#include <ESP8266_Lib.h>
#include <DHT.h>
#define DHTPIN A0
#define DHTTYPE DHT22
#define USERNAME "wxin"
#define DEVICE_ID "humidity"
#define DEVICE_CREDENTIAL "humid7"
#define SSID "Realme C1"
#define SSID_PASSWORD "12345678"
DHT dht(DHTPIN,DHTTYPE);
// Emulate Serial1 on pins 10/11 if HW is not present (use interrupt pins for better performance)
#ifndef HAVE_HWSERIAL1
#define EspSerial Serial1
#endif
ThingerESP8266AT thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL, Serial1);
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
dht.begin();
thing.add_wifi(SSID, SSID_PASSWORD);
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
pinMode(40, OUTPUT);
thing["LED"] << digitalPin(40);
// resource output example (i.e. reading a sensor value)
thing["humidity"] >> outputValue(dht.readTemperature());
//thing["millis"] >> [](pson& out){ out = millis(); };
}
void loop() {
thing.handle();
}
This is my simple dashboard with widget.