//#define _DEBUG_ //toujours mettre en premier et mettre Serial.begin(115200); dans setup */ #include <ThingerESP8266.h> #include "DHT.h" #define USERNAME "xxxxxxxxxxxxxxxx" #define DEVICE_ID "xxxxxxxxxxxxxxxxxxxx" #define DEVICE_CREDENTIAL "xxxxxxxxxxxxxx" #define SSID "xxxxxxxxxxxxx" #define SSID_PASSWORD "xxxxxxxxxxxxxxxxx" #define pinS0 5 //pin D1, les pin sont mises avec leur n° GPIO, c'est les 3 pins qui actionne le CD4051 pour qu'il sache quelle entrée lire #define pinS1 4 //pin D2 #define pinS2 0 //pin D3 ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); DHT dht(D4, DHT11); int v1, v4; void setup() { pinMode(D7, OUTPUT);//led verte pinMode(D8, OUTPUT);//led rouge pinMode(D5, INPUT);//pushbutton pinMode(D4, INPUT);//DHT11 pinMode(pinS0, OUTPUT); pinMode(pinS1, OUTPUT); pinMode(pinS2, OUTPUT); dht.begin(); thing.add_wifi(SSID, SSID_PASSWORD); //thing["led"] << invertedDigitalPin(D4); // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) thing["ledrouge"] << digitalPin(D7); // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) thing["ledverte"] << digitalPin(D8); // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) thing["potar1"] >> outputValue(v1); thing["light_sensor"] >> outputValue(v4); thing["temperature"] >> outputValue(dht.readTemperature()); thing["Humidity"] >> outputValue(dht.readHumidity()); thing["push_button"] >> [](pson & out) { out = digitalRead(D5) == HIGH ? "OFF" : "ON"; }; } void loop() { digitalWrite(pinS2, LOW); //pour lire l'entrée Y0 du CD4051 digitalWrite(pinS1, LOW); digitalWrite(pinS0, LOW); v1 = analogRead(0); delay(20); digitalWrite(pinS2, LOW); //pour lire l'entrée Y3 du CD4051 digitalWrite(pinS1, HIGH); digitalWrite(pinS0, HIGH); v4 = 1024 - analogRead(0); delay(20); thing.handle(); }