vilasrao
Published © LGPL

Monitor temp/humidity and control LED from anywhere!!

Attractive 'Remote control panel' with gauges to monitor data and buttons for LED control.

IntermediateFull instructions provided1,246
Monitor temp/humidity and control LED from anywhere!!

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
LED (generic)
LED (generic)
×4
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

circuit

Code

Sensor monitoring and LED control over internet (IoT )

C/C++
Sensor monitoring and LED control over internet (IoT ) is done via control panel .
#include "CavyIoT.h"
#include "DHT.h" // including the library of DHT11 temperature and humidity sensor
CavyIoT myIoTdevice; 
DHT dht(D3, DHT11);
#define LED1 D5
#define LED2 D6
#define LED3 D7
#define LED4 D8 
void setup()
  {
  pinMode(D5, OUTPUT);
  pinMode(D6, OUTPUT);
  pinMode(D7, OUTPUT);
  pinMode(D8, OUTPUT);
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  digitalWrite(LED3, LOW);
  digitalWrite(LED4, LOW);
  Serial.begin(9600);  
  WiFi.begin("WifiSSID","WiFiPASSWORD");//Internet access
   while (WiFi.status() != WL_CONNECTED)
       {
        delay(500);
        Serial.print(".");            
        }  
  myIoTdevice.begin("username","password","device"); //CavyIoT credentials
  dht.begin();
   }

void loop() {
 
  if(myIoTdevice.Update("temp",dht.readTemperature(),"humi",dht.readHumidity())!=ERROR)
    { 
    if( myIoTdevice.Button(0)=="LED1_ON"){ digitalWrite(LED1, HIGH); }else { digitalWrite(LED1, LOW); }
    if( myIoTdevice.Button(1)=="LED2_ON"){ digitalWrite(LED2, HIGH); }else { digitalWrite(LED2, LOW); }
    if( myIoTdevice.Button(2)=="LED3_ON"){ digitalWrite(LED3, HIGH); }else { digitalWrite(LED3, LOW); }
    if( myIoTdevice.Button(3)=="LED4_ON"){ digitalWrite(LED4, HIGH); }else { digitalWrite(LED4, LOW); }
    }
    else{
        Serial.println("communication failure !");
        }
   delay(5000);//Delay must be 5000 ,if it less than 5000 server may block your account
  }//End of loop

Credits

vilasrao

vilasrao

0 projects • 1 follower

Comments