Posts

Soil Moisture Monitoring using ESP8266 and Blynk

 #define BLYNK_TEMPLATE_ID "template id" #define BLYNK_TEMPLATE_NAME "template name" #define BLYNK_AUTH_TOKEN "Auth token" #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> const int sensor_pin = A0;  /* Connect Soil moisture analog sensor pin to A0 of NodeMCU */ char ssid[] = "Wifi name"; char pass[] = "Wifi password"; BlynkTimer timer; //that creates a timer object used to run functions at fixed time intervals void sendSensor() // function for reading and sending sensor data. {   int moisture_percentage;   moisture_percentage = ( 100.00 - ( (analogRead(sensor_pin)/1023.00) * 100.00 ) ); // For zero moisture, we get the maximum value of 10-bit ADC, i.e. 1023.   Serial.print("Soil Moisture(in Percentage) = ");   Serial.print(moisture_percentage);   Serial.println("%");   delay(1000);       // You can send any value at any time.   // Please don't send more that 10 val...

DHT 11 Interfacing with ESP8266 and Blynk

     /* Fill-in information from Blynk Device Info here */ #define BLYNK_TEMPLATE_ID "TMPL3Kw9eDR4C" #define BLYNK_TEMPLATE_NAME "DHT11" #define BLYNK_AUTH_TOKEN "q_4_vmsWXHzDY3w5ll-C_5aXwFjy3qSs" #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <DHT.h> // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "wifi name"; char pass[] = "wifi password"; #define DHTPIN 2          // digital pin we're connected to D4 #define DHTTYPE DHT11     // DHT 11 //#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321 //#define DHTTYPE DHT21   // DHT 21, AM2301 DHT dht(DHTPIN, DHTTYPE); // creates and configures a DHT sensor object BlynkTimer timer; // This function sends Arduino's up time every second to Virtual Pin (5). void sendSensor() {   float h = dht.readHumidity();   float t = dht.readTemperature(); // or dht.readTemperatur...

Heart beat sensor (KY 039) Interfacing with ESP8266

  Program const int heartbeatSensorPin = A0; // Analog pin connected to the Heartbeat Sensor module void setup() {   pinMode(heartbeatSensorPin, INPUT); // Set the Heartbeat Sensor pin as INPUT      Serial.begin(9600); // Initialize serial communication for debugging (optional) } void loop() {   int heartbeatValue = analogRead(heartbeatSensorPin); // Read the analog value from the Heartbeat Sensor   int heartbeatRate = map(heartbeatValue, 0, 1023, 40, 220); // Map the sensor value to a heartbeat rate range (40 to 220 BPM)   Serial.print("Heartbeat Rate (BPM): ");   Serial.println(heartbeatRate); //  }

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); // connect dht11 to pin D1 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: "); ...