Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Via Youtube : EMAKERZ
- // https://youtu.be/RlCMN_pL1cw
- //Télécharger les différentes librairies
- #define BLYNK_TEMPLATE_ID "(mettre votre template BlynkIOT)"
- #define BLYNK_DEVICE_NAME "(mettre votre nom d'appareil)"
- #define BLYNK_FIRMWARE_VERSION "0.1.0"
- #define BLYNK_PRINT Serial
- #define APP_DEBUG
- #include "BlynkEdgent.h"
- #include <DHT.h>
- #define DHTPIN 2
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- BlynkTimer timer;
- void setup()
- {
- pinMode(5, OUTPUT); //D1
- pinMode(14, OUTPUT);//D5
- pinMode(2, INPUT);//D4
- Serial.begin(115200);
- delay(100);
- BlynkEdgent.begin();
- dht.begin();
- timer.setInterval(1000L, sendSensor);
- }
- BLYNK_WRITE(V0) { //lumière
- if (param.asInt() == 1) {
- digitalWrite(5, HIGH);
- Serial.println("1");
- }
- else {
- digitalWrite(5, LOW);
- Serial.println("0");
- }
- }
- BLYNK_WRITE(V1) { //Brumisateur
- if (param.asInt() == 1) {
- digitalWrite(14, HIGH);
- Serial.println("1");
- }
- else {
- digitalWrite(14, LOW);
- Serial.println("0");
- }
- }
- void loop() {
- BlynkEdgent.run();
- timer.run();
- }
- void sendSensor() // capteur DHT11
- {
- float h = dht.readHumidity();
- float t = dht.readTemperature();
- if (isnan(h) || isnan(t)) {
- Serial.println("aucune réception du capteur DHT11");
- return;
- }
- Blynk.virtualWrite(V5, h);
- Blynk.virtualWrite(V6, t);
- }
Advertisement
Add Comment
Please, Sign In to add comment