DHT11 and LED control with Nodemcu

Hi
This is a dual purpose project. Temperature and humidity is measured using DHT11 and monitored in the dashboard. In addition, there is an LED (which can be a relay or light etc. for custom applications) that can be controlled through the dashboard. The project uses Nodemcu programmed by arduino ide.

with This plan we can control the things around us while the local sensors information is at our disposal.



#include <SPI.h>
#include <ESP8266WiFi.h>       //ESP8266 WiFi connection library
#include <ThingerESP8266.h>    //THINGER.IO library
#include "DHT.h" 
#define DHTPIN D7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Thinger.io connection parameters
#define user "******"
#define device_Id "******"
#define device_credentials "******"
ThingerESP8266 thing(user, device_Id, device_credentials);

void setup() {
  pinMode(5,OUTPUT);
  // Setup WiFi
  thing.add_wifi("****", "****");
  // Define the 'thing' with a name and data direction
    thing["LED"] << [](pson& in){
    if(in.is_empty()){
      in = (bool) digitalRead(5);
      }
    else{
      digitalWrite(5, in ? HIGH : LOW);
      }
    };
  thing["dht11"] >> [](pson& out){
    // Add the values and the corresponding code
    out["humidity"] = dht.readHumidity();
    out["celsius"] = dht.readTemperature();
  };
  
}

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

Nice project @ali_ht97, thanks for sharing it with us!

1 Like

سلام.ممنونم از شما بابت این پست جالب

1 Like

Thank you :heart:

سلام.جناب مهندس
وقت بخیر .لطفا بفرمایید که چطوری میشه شرطی گذاشت تا هر وقت دما به اندازه ی تعیین شده رسید یک ایمیل یا پیامک بفرسته
البته در قسمت (نقاط پایانی) و در قسمت ایمیل چیزایی بود ولی موفق نشدم.به محض اتصال به وای فای ،ایمیل ارسال میشه.