Nodemcu and DHT11

coding

#include <dht.h>
#include <AdafruitIO_WiFi.h>
#include <ESP8266WiFi.h>
#include <Ticker.h>
#define DHT11_PIN 2
#define IO_USERNAME  "*******"//replace your user name
#define IO_KEY       "***********" //replace your key
#define WIFI_SSID       "********"//replace your hotspot name
#define WIFI_PASS       "********"//replace your hotspot password
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
dht DHT;

AdafruitIO_Feed *humidity = io.feed("*******");//replace your feed1 name
AdafruitIO_Feed *temperature = io.feed("*****");//replace your feed2 name

void setup(){
  Serial.begin(9600);  
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  Serial.print("Connecting to Adafruit IO");
  io.connect();
  
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println(io.statusText());

  humidity->get();
  temperature->get();
}
void loop()
{
  io.run();
  DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);//temperature
  temperature->save(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  humidity->save(DHT.humidity);
  delay(10000);
}

Comments

Post a Comment

Popular posts from this blog

programing part for petrol level measuring in tamil

using millis() in ultrasonic sensor program in tamil

how to make pic and pot robot (robotic arm) in tamil