Thanks a lot Jiri.
I was testing with the information/modification you give me. And for the first time here in thinger.io, very interesting platform.
To control the Led On/Off I need to put a delay about 500ms, without a delay it is very instable.
I can´t read any value in thinger.io, from my sensor/thing, only few times.
The code I test is:
#include <WiFiEsp.h>
#include <ThingerWifiEsp.h>
#include <SoftwareSerial.h>
SoftwareSerial Serial1(7, 8);
#define PhotoR_Pin A1 //define a pin for Photo resistor
#define USERNAME "*****"
#define DEVICE_ID "*****"
#define DEVICE_CREDENTIAL "*****"
#define SSID "*****"
#define SSID_PASSWORD "*****"
int status = WL_IDLE_STATUS;
int light;
ThingerWifiEsp thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(9600);
// initialize ESP module
WiFi.init(&Serial1);
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(SSID);
// Connect to WPA/WPA2 network
status = WiFi.begin(SSID, SSID_PASSWORD);
}
pinMode(2, OUTPUT);
// pin control example (i.e. turning on/off a light, a relay, etc)
thing["led"] << digitalPin(2);
// resource output example (i.e. reading a sensor value, a variable, etc)
thing["Photoresistor"] >> outputValue(light);
// more details at http://docs.thinger.io/arduino/
}
void loop() {
light=analogRead(PhotoR_Pin);
thing.handle();
Serial.println(light);
delay(500);
}
I already see that Alvarolb update the Wifi library in Github. I will test it!