Posts

LED Brightness control - ESP8266

  Program const int ledPin = 2; //D4 void setup() {   } void loop() {   // increase the LED brightness   for(int dutyCycle = 0; dutyCycle < 255; dutyCycle++){        // changing the LED brightness with PWM     analogWrite(ledPin, dutyCycle);     delay(25);   }   // decrease the LED brightness   for(int dutyCycle = 255; dutyCycle > 0; dutyCycle--){     // changing the LED brightness with PWM     analogWrite(ledPin, dutyCycle);     delay(25);   } }

ESP8266- Rain drop Sensor Interfacing

Program #define DO_PIN    D2  // The ESP8266 pin connected to DO pin of the rain sensor void setup() {     Serial.begin(9600);     pinMode(DO_PIN, INPUT); } void loop() {    delay(10);                      // wait 10 milliseconds   int rain_state = digitalRead(DO_PIN);   if (rain_state == HIGH)     Serial.println("The rain is NOT detected");   else     Serial.println("The rain is detected");   delay(1000);  // pause for 1 sec to avoid reading sensors frequently to prolong the sensor lifetime }

Control LED using button switch- ESP 8266

Image
  Program int led = 5;     // LED pin D1 int button = 16; // push button is connected to D0 int temp = 0;    // temporary variable for reading the button pin status void setup() {   pinMode(led, OUTPUT);   // declare LED as output   pinMode(button, INPUT); // declare push button as input   Serial.begin(9600); } void loop() {   temp = digitalRead(button);            if (temp == HIGH) {         digitalWrite(led, HIGH);         Serial.println("LED Turned ON");         delay(1000);        }      else {         digitalWrite(led, LOW);         Serial.println("LED Turned OFF");         delay(1000);        } }

ESP 8266- DHT11 Interfacing

Image
  // Include the DHT11 library for interfacing with the sensor. #include <DHT11.h> DHT11 dht11(5); void setup() {     // Initialize serial communication to allow debugging and data readout.     // Using a baud rate of 9600 bps.     Serial.begin(9600);          // dht11.setDelay(500); // Set this to the desired delay. Default is 500ms. } void loop() {     int temperature = 0;     int humidity = 0;     // Attempt to read the temperature and humidity values from the DHT11 sensor.     int result = dht11.readTemperatureHumidity(temperature, humidity);     // Check the results of the readings.     // If the reading is successful, print the temperature and humidity values.     // If there are errors, print the appropriate error messages.     if (result == 0) {         Serial.print("Temperature: ");         Seri...

LED ON/OFF Using Blynk

 Program / #define BLYNK_AUTH_TOKEN "auth token" #define BLYNK_TEMPLATE_ID "template id" #define BLYNK_TEMPLATE_NAME "LED control " #define BLYNK_PRINT Serial #include <ESP8266WiFi.h>   #include <BlynkSimpleEsp8266.h>   char auth[] = BLYNK_AUTH_TOKEN; char ssid[] = "wifi name";  // Enter your Wifi Username char pass[] = "wifi password";  // Enter your Wifi password int ledpin = D0; void setup() {        Serial.begin(115200);   Blynk.begin(auth, ssid, pass);       pinMode(ledpin,OUTPUT); } void loop() {   Blynk.run();  }

Soil moisture sensor interfacing with ESP8266

Image
  Program const int sensor_pin = A0;  /* Connect Soil moisture analog sensor pin to A0 of NodeMCU */ void setup() {   Serial.begin(9600); /* Define baud rate for serial communication */ } void loop() {   float moisture_percentage;   moisture_percentage = ( 100.00 - ( (analogRead(sensor_pin)/1023.00) * 100.00 ) );   Serial.print("Soil Moisture(in Percentage) = ");   Serial.print(moisture_percentage);   Serial.println("%");   delay(1000); }

PIR Sensor Interfacing with ESP8266

Image
Program  #define pir D1  #define LED D2 void setup() {   Serial.begin(9600);   pinMode(pir, INPUT);   // declare pir sensor pin as input   pinMode(LED, OUTPUT);  // declare LED as output } void loop() {   long state = digitalRead(pir);     if(state == HIGH) {       Serial.println("Motion Detected");       digitalWrite (LED, HIGH);       delay(5000);     }     else {       Serial.println("Motion not detected");       digitalWrite (LED, LOW);       delay(1000);       } }