top of page

Search Results

143 items found for ""

  • TCRT5000 IR Reflective Line Tracking sensor Interface with Arduino

    In this tutorial, you will learn how to find black and white line track color using TCRT5000 IR reflective sensor. This IR reflective sensor utilizes a TCRT5000 to detect color and distance. It emits IR and then detects if it receives the echo. This sensor is often used in line following robots, auto data logging on utility meters, because this module can sense if a surface is white or black. Circuit Diagram Components Required Arduino Uno - 1 no LCD16x2 with I²C module - 1no TCRT5000 sensor - 1 no TCRT5000 IR reflex Tracking Sensor Module The TCRT5000 Sensor is used to detect color and distance. The sensor emits an infrared wave and then receives it. TCRT5000 Infrared Reflective Sensor Module is often used in line following robots and object sorting Robots since this module can sense if a surface is white or black. The Module Adopts TCRT5000 photoelectric sensor and comparator. It is easy to use, has good stability and anti-interference ability. Its is Perfect for black & white line detection for smart car and has a Black line for low-level output, a white line for high-level output. Features: The working voltage: 5V The output format: digital signal (0 and 1) A fixed bolt hole for easy installation Small PCB board size: 3.5cm x 1cm A single weight: 4.5g Detector distance: 25mm Build-in Tcrt5000 Sensor NSOR Download Refer Datasheet Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino Code: int GND = 5; int VCC = 6; int OUT = 7; #define start 8 #include LiquidCrystal_I2C lcd(0x27,20,4); void setup() { // initialize serial communication at 9600 bits per second: pinMode(GND, OUTPUT); pinMode(VCC, OUTPUT); pinMode(OUT, INPUT); pinMode(start, INPUT); digitalWrite(GND, LOW); digitalWrite(VCC, HIGH); Serial.begin(9600); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); } void loop() { lcd.setCursor(0,0); lcd.print("TRACKING SENSOR "); int sensorValue = digitalRead(OUT); if ((sensorValue == 0)& (digitalRead(start) == HIGH)){ Serial.println("Black color"); lcd.setCursor(0,1); lcd.print(" BLACK COLOR "); delay(1000); } if ((sensorValue == 1)& (digitalRead(start) == HIGH)){ Serial.println("White color"); lcd.setCursor(0,1); lcd.print(" WHITE COLOR "); delay(1000); } else { lcd.setCursor(0,1); lcd.print("FIND PATH COLOR "); delay(100); } } After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and Open Serial monitor and see the result in Serial monitor.

  • Visitor Counter with Automatic light Control using IR sensor

    In this project, we will make a Arduino based Visitor Counter with an Automatic Light Control System using Infrared sensor. The pair of IR sensors can detect the visitor IN/OUT directions and display presence of Visitor inside the building or store. The device counts the total number of people presence and automatic light. When no people are inside the room, i.e. the total number of people presence is zero then the room light is turned off. Circuit Diagram Components Required Arduino Uno - 1 no LCD16x2 I²C - 1no Obstacle Avoidance IR sensor Module - 2 nos Relay 1 channel - 1 no Infrared Obstacle Avoidance IR Sensor Module The IR sensor module consists mainly of the IR Transmitter and Receiver, Opamp, Variable Resistor (Trimmer pot), output LED in brief. IR LED Transmitter IR LED emits light, in the range of Infrared frequency. IR light is invisible to us as its wavelength (700nm – 1mm) is much higher than the visible light range. IR LEDs have light emitting angle of approx. 20-60 degree and range of approx. few centimeters to several feet's, it depends upon the type of IR transmitter and the manufacturer. Some transmitters have the range in kilometers. IR LED white or transparent in colour, so it can give out amount of maximum light. Photodiode Receiver Photodiode acts as the IR receiver as its conducts when light falls on it. Photodiode is a semiconductor which has a P-N junction, operated in Reverse Bias, means it start conducting the current in reverse direction when Light falls on it, and the amount of current flow is proportional to the amount of Light. This property makes it useful for IR detection. Photodiode looks like a LED, with a black colour coating on its outer side, Black colour absorbs the highest amount of light. LM358 Opamp LM358 is an Operational Amplifier (Op-Amp) is used as voltage comparator in the IR sensor. the comparator will compare the threshold voltage set using the preset (pin2) and the photodiode’s series resistor voltage (pin3). Photodiode’s series resistor voltage drop > Threshold voltage = Opamp output is High Photodiode’s series resistor voltage drop < Threshold voltage = Opamp output is Low When Opamp's output is high the LED at the Opamp output terminal turns ON (Indicating the detection of Object). Variable Resistor(Preset POT) The variable resistor used here is a preset. It is used to calibrate the distance range at which object should be detected. How to Use IR Sensor Module? The 5 VDC supply input is given to the VCC pin and the supply negative is connected to the GND terminal of the module. When no object is detected within the range of the IR receiver, the output LED remains off. When a object is detected within the range of the IR sensor the LED glows. Applications Obstacle Detection Industrial safety devices Wheel encoder Pin Configuration Pin Name Description VCC Power Supply Input GND Power Supply Ground OUT Active High Output IR Sensor Module Features 5VDC Operating voltage I/O pins are 5V and 3.3V compliant Range: Up to 20cm Adjustable Sensing range Built-in Ambient Light Sensor 20mA supply current Mounting hole Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and Open Serial monitor and see the result in Serial monitor.

  • Arduino Based Gyroscope Accelerometer Controlled Servo Motor

    In this Project, we will measure an angle using MPU6050 Accelerometer and Gyroscope Sensor with an Arduino and control Servo Motors. The Accelerometer sends X, Y, and Z acceleration forces. We need to convert the forces into X, Y, Z 3D angle to determine the 3D Orientation of the sensor.The gyroscope measures rotational velocity or rate of change of the angular position over time, along the X, Y, and Z-axis. It uses MEMS technology and the Coriolis Effect for measuring. The outputs of the gyroscope are in degrees per second, so in order to get the angular position, we just need to integrate the angular velocity. The accelerometer can measure gravitational acceleration along the 3 axes and using some trigonometry math we can calculate the angle at which the sensor is positioned. So, if we use, or combine the MPU6050 accelerometer and gyroscope data we can get very accurate information about the sensor orientation. Circuit Diagram Components Required Arduino Uno - 1 no MPU6050 GY-521 - 1no LCD20x4 I²C - 1no Servo 180°- 3 no MPU6050 Accelerometer and Gyroscope Sensor The MPU6050 is a Micro Electro-Mechanical Systems (MEMS) which consists of a 3-axis Accelerometer and 3-axis Gyroscope inside it. This helps us to measure acceleration, velocity, orientation, displacement and many other motion related parameter of a system or object. This module also has a (DMP) Digital Motion Processor inside it which is powerful enough to perform complex calculation and thus free up the work for Microcontroller. The module also have two auxiliary pins which can be used to interface external IIC modules like an magnetometer, however it is optional. Since the IIC address of the module is configurable more than one MPU6050 sensor can be interfaced to a Microcontroller using the AD0 pin. This module also has well documented and revised libraries available hence it’s very easy to use with famous platforms like Arduino. So if you are looking for a sensor to control motion for your RC Car, Drone, Self balancing Robot, Humanoid, Biped or something like that then this sensor might be the right choice for you. The hardware of the module is very simple, it actually comprises of the MPU6050 as the main components as shown above. Since the module works on 3.3V, a voltage regulator is also used. The IIC lines are pulled high using a 4.7k resistor and the interrupt pin is pulled down using another 4.7k resistor. The MPU6050 module allows us to read data from it through the IIC bus. Any change in motion will be reflected on the mechanical system which will in turn vary the voltage. Then the IC has a 16-bit ADC which it uses to accurately read these changes in voltage and stores it in the FIFO buffer and makes the INT (interrupt) pin to go high. This means that the data is ready to be read, so we use a MCU to read the data from this FIFO buffer through IIC communication. Refer Project for More detail about MPU6050 sensor. https://www.dofbot.com/post/iot-based-object-angle-measure-using-mpu-6050-and-blynk Applications Used for IMU measurement Drones / Quad copters Self balancing robots Robotic arm controls Humanoid robots Tilt sensor Orientation / Rotation Detector Pinout: The MPU-6050 module has 8 pins: INT: Interrupt digital output pin. AD0: I2C Slave Address LSB pin. This is the 0th bit in the 7-bit slave address of the device. If connected to VCC then it is read as logic one and slave address changes. XCL: Auxiliary Serial Clock pin. This pin is used to connect other I2C interface enabled sensors SCL pin to MPU-6050. XDA: Auxiliary Serial Data pin. This pin is used to connect other I2C interface enabled sensors SDA pin to MPU-6050. SCL: Serial Clock pin. Connect this pin to the microcontrollers SCL pin. SDA: Serial Data pin. Connect this pin to the microcontrollers SDA pin. GND: Ground pin. Connect this pin to the ground connection. VCC: Power supply pin. Connect this pin to +5V DC supply. Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino code: Servo Sweep Test #include Servo myservo; // create servo object to control a servo Servo myservo1; // create servo object to control a servo Servo myservo2; // create servo object to control a servo // twelve servo objects can be created on most boards int pos = 0; // variable to store the servo position void setup() { myservo.attach(11); // attaches the servo on pin 9 to the servo object myservo1.attach(10); // attaches the servo on pin 9 to the servo object myservo2.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo1.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo1.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo2.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo2.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } After a successful upload, Press the “EN/RST” button on the Arduino Uno board. Arduino code: Main Code #include #include Servo servo0; Servo servo1; Servo servo2; #include LiquidCrystal_I2C lcd(0x27,20,4); const int MPU_addr=0x68; int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; int minVal=265; int maxVal=402; double x; double y; double z; void setup(){ Wire.begin(); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); Wire.beginTransmission(MPU_addr); Wire.write(0x6B); Wire.write(0); Wire.endTransmission(true); Serial.begin(9600); servo0.attach(10); servo1.attach(9); servo2.attach(11); } void loop(){ Wire.beginTransmission(MPU_addr); Wire.write(0x3B); Wire.endTransmission(false); Wire.requestFrom(MPU_addr,14,true); AcX=Wire.read()<<8|Wire.read(); AcY=Wire.read()<<8|Wire.read(); AcZ=Wire.read()<<8|Wire.read(); int xAng = map(AcX,minVal,maxVal,-90,90); int yAng = map(AcY,minVal,maxVal,-90,90); int zAng = map(AcZ,minVal,maxVal,-90,90); x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI); y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI); z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI); Serial.print("AngleX= "); Serial.println(x); Serial.print("AngleY= "); Serial.println(y); Serial.print("AngleZ= "); Serial.println(z); int servo0Value = map(x, 0, 360, 0, 180); int servo1Value = map(y, 0, 360, 0, 180); int servo2Value = map(z, 0, 360, 0, 180); delay(400); // Control the servos according to the MPU6050 orientation servo0.write(servo0Value); delay(100); servo1.write(servo1Value); delay(100); servo2.write(servo2Value); delay(100); Serial.println(servo0Value); Serial.println(servo1Value); Serial.println(servo2Value); Serial.println("-----------------------------------------"); lcd.setCursor(0,0); lcd.print("3Servo Angle Control"); lcd.setCursor(0,1); lcd.print("X angle : "); lcd.print(servo0Value); lcd.print(" "); lcd.setCursor(0,2); lcd.print("Y angle : "); lcd.print(servo1Value); lcd.print(" "); lcd.setCursor(0,3); lcd.print("Z angle : "); lcd.print(servo2Value); lcd.print(" "); delay(500); } After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and Open Serial Monitor and see the result in Serial Monitor.

  • Heart Beat Sensor Interface with Arduino and OLED display

    In this tutorial, you will learn how to monitor the Heartbeat rate or Heart Beats per minute using the Pulse Sensor, Arduino and OLED display. This sensor is not for medical use or FDA approved. Circuit Diagram Components Required Arduino Uno - 1 no Pulse Sensor -1no OLED 0.96inch I2C - 1 no LED - 1 no Resistor - 1no Pulse Sensor The working of the Pulse/Heart beat sensor is very simple. The sensor has two sides, on one side the LED is placed along with an ambient light sensor and on the other side we have some circuitry. This circuitry is responsible for the amplification and noise cancellation work. The LED on the front side of the sensor is placed over a vein in our human body. This can either be your Finger tip or you ear tips, but it should be placed directly on top of a vein. Now the LED emits light which will fall on the vein directly. The veins will have blood flow inside them only when the heart is pumping, so if we monitor the flow of blood we can monitor the heart beats as well. If the flow of blood is detected then the ambient light sensor will pick up more light since they will be reflect ted by the blood, this minor change in received light is analysed over time to determine our heart beats. How to use Pulse sensor Using the pulse sensor is straight forward, but positioning it in the right way matters. Since all the electronics on the sensor are directly exposed it is also recommended to cover the sensor with hot glue, vinyl tape or other non conductive materials. Also it is not recommended to handle these sensors with wet hands. The flat side of the sensor should be placed on top of the vein and a slight presser should be applied on top of it, normally clips or Velcro tapes are used to attain this pressure. To use the sensor simply power it using the Vcc and ground pins, the sensor can operate both at +5V or 3.3V system. Once powered connect the Signal pin to the ADC pin of the microcontroller to monitor the change in output voltage. If you are using a development board like Arduino then you can use the readily available code which will make things a lot easier. Refer the datasheet at the bottom of the page for more information on how to interface the sensor with Arduino and how to mount it. The schematics of the sensor, code and processing sketch can be obtained from the Sprakfun product page. Applications Sleep Tracking Anxiety monitoring Remote patient monitoring/alarm system Health bands Advanced gaming consoles Features Biometric Pulse Rate or Heart Rate detecting sensor Plug and Play type sensor Operating Voltage: +5V or +3.3V Current Consumption: 4mA Inbuilt Amplification and Noise cancellation circuit. Diameter: 0.625” Thickness: 0.125” Thick Connect pulse sensor VCC pin to Arduino 5V Pin and GND to GND. Connects its signal pin to Arduino Analog pin A0. Warning: This sensor is not medical or FDA approved. It is purely intended for hobby projects/demos and should not be use for health critical applications. 0.96″ I2C OLED Display: This is a 0.96 inch blue OLED display module. The display module can be interfaced with any microcontroller using SPI/IIC protocols. It is having a resolution of 128x64. The package includes display board, display,4 pin male header pre-soldered to board. OLED (Organic Light-Emitting Diode) is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays. Connect the VCC Pin of OLED Display to Arduino 3.3V pin and GND to GND. Connect its SDA & SCK pins to Arduino A4 & A5 pins respectively. Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Download Adafruit_SSD1306_Library , we need to use this library for OLED Download Adafruit_GFX_Library , we need to use this library for OLED Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino code with OLED: // Include Library #include #include #include #include // // Configure OLED screen size in pixels #define SCREEN_WIDTH 128 //--> OLED display width, in pixels #define SCREEN_HEIGHT 64 //--> OLED display height, in pixels // // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // // Variable Declarations unsigned long previousMillisGetHR = 0; //--> will store the last time Millis (to get Heartbeat) was updated. unsigned long previousMillisResultHR = 0; //--> will store the last time Millis (to get BPM) was updated. const long intervalGetHR = 20; //--> Interval for reading heart rate (Heartbeat) = 10ms. const long intervalResultHR = 10000; //--> The reading interval for the result of the Heart Rate calculation is in 10 seconds. int PulseSensorSignal; //--> Variable to accommodate the signal value from the sensor const int PulseSensorHRWire = 0; //--> PulseSensor connected to ANALOG PIN 0 (A0 / ADC 0). const int LED_A1 = A1; //--> LED to detect when the heart is beating. The LED is connected to PIN A1 on the Arduino UNO. int UpperThreshold = 550; //--> Determine which Signal to "count as a beat", and which to ingore. int LowerThreshold = 500; int cntHB = 0; //--> Variable for counting the number of heartbeats. boolean ThresholdStat = true; //--> Variable for triggers in calculating heartbeats. int BPMval = 0; //--> Variable to hold the result of heartbeats calculation. int x=0; //--> Variable axis x graph values to display on OLED int y=0; //--> Variable axis y graph values to display on OLED int lastx=0; //--> The graph's last x axis variable value to display on the OLED int lasty=0; //--> The graph's last y axis variable value to display on the OLED // // 'Heart_Icon', 16x16px // I drew this heart icon at : http://dotmatrixtool.com/ const unsigned char Heart_Icon [] PROGMEM = { 0x00, 0x00, 0x18, 0x30, 0x3c, 0x78, 0x7e, 0xfc, 0xff, 0xfe, 0xff, 0xfe, 0xee, 0xee, 0xd5, 0x56, 0x7b, 0xbc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00 }; // // void setup void setup() { pinMode(LED_A1,OUTPUT); //--> Set LED_3 PIN as Output. Serial.begin(9600); //--> Set's up Serial Communication at certain speed. // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally // Address 0x3C for 128x32 and Address 0x3D for 128x64. // But on my 128x64 module the 0x3D address doesn't work. What works is the 0x3C address. // So please try which address works on your module. if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); //--> Don't proceed, loop forever } // // Show initial display buffer contents on the screen // the library initializes this with an Adafruit splash screen. display.display(); delay(1000); // // Displays BPM value reading information display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 12); //--> (x position, y position) display.print(" Please wait"); display.setCursor(0, 22); //--> (x position, y position) display.print(" 10 seconds"); display.setCursor(0, 32); //--> (x position, y position) display.print(" to get"); display.setCursor(0, 42); //--> (x position, y position) display.print(" the Heart Rate value"); display.display(); delay(3000); // // Displays the initial display of BPM value display.clearDisplay(); //--> for Clearing the display display.drawBitmap(0, 47, Heart_Icon, 16, 16, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) display.drawLine(0, 43, 127, 43, WHITE); //--> drawLine(x1, y1, x2, y2, color) display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(20, 48); //--> (x position, y position) display.print(": 0 BPM"); display.display(); // Serial.println(); Serial.println("Please wait 10 seconds to get the BPM Value"); } // // void loop void loop() { GetHeartRate(); //--> Calling the GetHeartRate() subroutine } // // void GetHeartRate() // This subroutine is for reading the heart rate and calculating it to get the BPM value. // To get a BPM value based on a heart rate reading for 10 seconds. void GetHeartRate() { // Process of reading heart rate. unsigned long currentMillisGetHR = millis(); if (currentMillisGetHR - previousMillisGetHR >= intervalGetHR) { previousMillisGetHR = currentMillisGetHR; PulseSensorSignal = analogRead(PulseSensorHRWire); //--> holds the incoming raw data. Signal value can range from 0-1024 if (PulseSensorSignal > UpperThreshold && ThresholdStat == true) { cntHB++; ThresholdStat = false; digitalWrite(LED_A1,HIGH); } if (PulseSensorSignal < LowerThreshold) { ThresholdStat = true; digitalWrite(LED_A1,LOW); } DrawGraph(); //--> Calling the DrawGraph() subroutine } // // The process for getting the BPM value. unsigned long currentMillisResultHR = millis(); if (currentMillisResultHR - previousMillisResultHR >= intervalResultHR) { previousMillisResultHR = currentMillisResultHR; BPMval = cntHB * 6; //--> The taken heart rate is for 10 seconds. So to get the BPM value, the total heart rate in 10 seconds x 6. Serial.print("BPM : "); Serial.println(BPMval); display.fillRect(20, 48, 108, 18, BLACK); display.drawBitmap(0, 47, Heart_Icon, 16, 16, WHITE); //--> display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color) display.drawLine(0, 43, 127, 43, WHITE); //--> drawLine(x1, y1, x2, y2, color) display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(20, 48); //--> (x position, y position) display.print(": "); display.print(BPMval); display.print(" BPM"); display.display(); cntHB = 0; } // } // // Subroutines for drawing or displaying heart rate graphic signals void DrawGraph() { // Condition to reset the graphic display if it fills the width of the OLED screen if (x > 127) { display.fillRect(0, 0, 128, 42, BLACK); x = 0; lastx = 0; } // // Process signal data to be displayed on OLED in graphic form int ySignal = PulseSensorSignal; if (ySignal > 850) ySignal = 850; if (ySignal < 350) ySignal = 350; int ySignalMap = map(ySignal, 350, 850, 0, 40); //--> The y-axis used on OLEDs is from 0 to 40 y = 40 - ySignalMap; // // Displays the heart rate graph display.writeLine(lastx,lasty,x,y,WHITE); display.display(); // lastx = x; lasty = y; x++; } Arduino code (Serial Plotter) Here, We are going to interface a Pulse Sensor with Arduino. The pulse sensor we are going to use is a plug and play heart rate sensor. This sensor is quite easy to use and operate. Place your finger on top of the sensor and it will sense the heartbeat by measuring the change in light from the expansion of capillary blood vessels. Subscribe and Download code. #define USE_ARDUINO_INTERRUPTS true #include /* The format of our output. Set this to PROCESSING_VISUALIZER if you're going to run the Processing Visualizer Sketch. See https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer Set this to SERIAL_PLOTTER if you're going to run the Arduino IDE's Serial Plotter. */ const int OUTPUT_TYPE = SERIAL_PLOTTER; /* Pinout: PULSE_INPUT = Analog Input. Connected to the pulse sensor purple (signal) wire. PULSE_BLINK = digital Output. Connected to an LED (and 220 ohm resistor) that will flash on each detected pulse. PULSE_FADE = digital Output. PWM pin onnected to an LED (and resistor) that will smoothly fade with each pulse. NOTE: PULSE_FADE must be a pin that supports PWM. Do not use pin 9 or 10, because those pins' PWM interferes with the sample timer. */ const int PULSE_INPUT = A0; const int PULSE_BLINK = 13; // Pin 13 is the on-board LED const int PULSE_FADE = 5; const int THRESHOLD = 550; // Adjust this number to avoid noise when idle /* All the PulseSensor Playground functions. */ PulseSensorPlayground pulseSensor; void setup() { /* Use 115200 baud because that's what the Processing Sketch expects to read, and because that speed provides about 11 bytes per millisecond. If we used a slower baud rate, we'd likely write bytes faster than they can be transmitted, which would mess up the timing of readSensor() calls, which would make the pulse measurement not work properly. */ Serial.begin(115200); // Configure the PulseSensor manager. pulseSensor.analogInput(PULSE_INPUT); pulseSensor.blinkOnPulse(PULSE_BLINK); pulseSensor.fadeOnPulse(PULSE_FADE); pulseSensor.setSerial(Serial); pulseSensor.setOutputType(OUTPUT_TYPE); pulseSensor.setThreshold(THRESHOLD); // Now that everything is ready, start reading the PulseSensor signal. if (!pulseSensor.begin()) { /* PulseSensor initialization failed, likely because our particular Arduino platform interrupts aren't supported yet. If your Sketch hangs here, try PulseSensor_BPM_Alternative.ino, which doesn't use interrupts. */ for(;;) { // Flash the led to show things didn't work. digitalWrite(PULSE_BLINK, LOW); delay(50); digitalWrite(PULSE_BLINK, HIGH); delay(50); } } } void loop() { /* Wait a bit. We don't output every sample, because our baud rate won't support that much I/O. */ delay(20); // write the latest sample to Serial. pulseSensor.outputSample(); /* If a beat has happened since we last checked, write the per-beat information to Serial. */ if (pulseSensor.sawStartOfBeat()) { pulseSensor.outputBeat(); } } After a successful upload, open the Serial Monitor at a baud rate of 115200. Press the “EN/RST” button on the Arduino Uno board and Open Serial plotter and see the result in Serial plotter.

  • Arduino Based BMP280 Pressure, Temperature and Altitude Measure

    In this tutorial shows how to connect BMP280 barometric pressure ,temperature and altitude sensor interface to Arduino UNO board with 4 line LCD display. It is ideally used for environment-related applications where pressure is a very critical parameter to work with. It is further useful in drones where pressure, temperature, and altitude can be useful to monitor and make further observations. Circuit Diagram Components Required Arduino Uno - 1 no LCD 20x4 I2C - 1 no BMP/BME 280 - 1no BMP280 Pressure Sensor Module: The GY-BMP280 Barometer Sensor is a breakout board for Bosch BMP280 high-precision and low-power digital barometer. It can be used to measure temperature and atmospheric pressure accurately. It can be connected to a microcontroller with I2C. Features The GY-BMP280 module comes with BMP280 sensor, which is an environmental sensor with temperature, barometric pressure that is the next generation upgrade to the BMP085/BMP180/BMP183. This sensor is great for all sorts of weather sensing and can even be used in both I2C and SPI. This precision sensor is the best low-cost, precision sensing solution for measuring barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy. Because pressure changes with altitude and the pressure measurements are so good, you can also use it as an altimeter with ±1 meter accuracy Pin pitch: 2.54mm Module size: 11.5mm*15mm Electrical specifications of GY-BMP280 Module Model: GY-BMP280-3.3 Chip: BMP280 Power supply: 3V/3.3V DC Peak current: 1.12mA Air pressure range : 300-1100hPa (equi. to +9000…-500m above sea level) Temperature range: -40 … +85 °C Digital interfaces: I²C (up to 3.4 MHz) and SPI (3 and 4 wire, up to 10 MHz) Current consumption of sensor BMP280: 2.7µA @ 1 Hz sampling rate How to use GY-BMP280 Module? The GY-BMP280 module operates from 3.3V so requires 3.3V power and must be driven with 3.3V logic levels. If needed to operate at 5V, it can be done using voltage regulator and level shifters as it doesn’t contain one. It is typically recommended to operate it on 3.3V and maximum at 3.6VDC. The module GY-BMP280 module simply supports both I²C and SPI interfaces and comes with default I²C address of 0x76. The Chip Select (CSB) and Serial Data Output (SDO) pins of the BMP 280 are necessary only when SPI-based (four-wire) communication is applied. I2C is a two wire interface SDA SCK. Leave pin 6 of the module (SDO) unconnected to set the I²C address to 0x76 – the on-board resistor pulls the SDO pin low setting the address to 0x76. To change the I²C address to 0x77, connect pin 6 of the module (SDO) to Vcc which would typically be the 3.3V supply. Pin 5 of the module (CSB) must be connected to Vcc to select the I²C interface. This is already done by an on-board pull-up resistor, so pin 5 can be left disconnected when using the I²C interface. Applications of GY-BMP280 Module Enhancement of GPS navigation (e.g. time-to-first-fix improvement, dead-reckoning, slope detection) Indoor navigation (floor detection, elevator detection) Outdoor navigation, leisure and sports applications Weather forecast, Home weather stations Health care application (e.g. sirometry) Vertical velocity indication (e.g. risk/sink speed) Handsets such as mobile phones, tablet PCs, GPS devices Flying toys Watches Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Download Adafruit_BMP280_Library , we need to use this library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino code: #include #include #include #include LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display Adafruit_BMP280 bmp; // I2C Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor(); Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor(); //Adafruit_BMP280 bmp(BMP_CS); // hardware SPI //Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK); void setup() { Serial.begin(9600); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); Serial.println(F("BMP280 test")); //if (!bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID)) { if (!bmp.begin()) { Serial.println(F("Could not find a valid BMP280 sensor, check wiring or " "try a different address!")); while (1) delay(10); } /* Default settings from datasheet. */ bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ Adafruit_BMP280::FILTER_X16, /* Filtering. */ Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ bmp_temp->printSensorDetails(); } void loop() { sensors_event_t temp_event, pressure_event; bmp_temp->getEvent(&temp_event); bmp_pressure->getEvent(&pressure_event); Serial.print(F("Temperature = ")); Serial.print(bmp.readTemperature()); Serial.println(" *C"); Serial.print(F("Pressure = ")); Serial.print(pressure_event.pressure); Serial.println(" hPa"); Serial.print(F("Approx altitude = ")); Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */ Serial.println(" m"); Serial.println(); lcd.setCursor(0,0); lcd.print("BMP 280 Live Monitor"); lcd.setCursor(0,1); lcd.print("T ("); lcd.print((char)223); lcd.print("C): "); lcd.print(bmp.readTemperature()); lcd.print(" "); lcd.setCursor(0,2); lcd.print("P(hPa): "); lcd.print(pressure_event.pressure); lcd.print(" "); lcd.setCursor(0,3); lcd.print("A (m): "); lcd.print(bmp.readAltitude(1013.25)); lcd.print(" "); delay(2000); } After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and see the result in monitor.

  • Interfacing APDS-9930 Ambient Light Sensor(ALS) with Arduino Uno

    This module consists of ambient light , IR and proximity sensors. The detection distance is up to 100 mm. The APDS-9930 sensor measures the ambient light. This sensor can also detect 0.01 Lux brightness in the dark. It can also be used behind dark glass like a mobile screen. For example, it turns off the touch screen during voice calls when your ear is close to the screen. This sensor can be used to adjust the brightness of mobile backlight and the appropriate light response for various applications. Circuit Diagram Components Required Arduino Uno - 1 no LCD 16x2 I2C - 1 no APDS-9930 - 1no APDS-9930 Non-contact proximity and Ambient Light sensor APDS-9930 is a digital I2C compatible interface ambient light sensor (ALS) and proximity sensor with IR LED in a single 8-pin package. The ambient light sensor utilizes dual photodiodes to approximate the human eye response with a low lux performance at 0.01 lux. This high sensitivity allows for the device to operate behind a darkened glass. The proximity sensor is fully calibrated to detection of objects to 100 mm thus eliminating the need for factory calibration of the end equipment or sub-assembly. The proximity detection feature operates well from bright sunlight to dark rooms. The addition of the micro-optics lenses within the module, provide highly efficient transmission and reception of infrared energy which lowers overall power dissipation. In addition, an internal state machine provides the ability to put the device into a low power mode in between ALS and proximity measurements providing very low average power consumption Specifications and Features : Optical modules integrated with ALS, infrared LEDs and proximity detectors Ambient Light Sensing (ALS) Approximate human visual response Programmable interrupt capability with upper and lower thresholds Up to 16-bit resolution High sensitivity operation behind dark glass 01lux low lumen performance Proximity detection Fully calibrated to 100 mm detection Integrated infrared LED and synchronous LED driver Eliminates factory calibration of the proximity sensor Programmable wait timer Wait state power consumption – 90μA typical Programmable range from 2.7 ms to more than 8 seconds I2C interface compatible Up to 400kHz (I2C fast mode) Dedicated interrupt pin Sleep Mode Power – 2.2μA typical Small package 3.94 (L) x 2.36 (W) x 1.35 (H) mm Applications : Adjustable light mobile phone back light Notebook / display security automatically enabled hands-free mode Automatic menu pop up Digital camera eye sensor Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. You need to install the following library –Download This is an ambient light example, there are also proximity examples Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino code: #define DUMP_REGS #include #include // Global Variables APDS9930 apds = APDS9930(); float ambient_light = 0; // can also be an unsigned long uint16_t ch0 = 0; uint16_t ch1 = 1; #include LiquidCrystal_I2C lcd(0x27,16,2); void setup() { //analogReference(EXTERNAL); // Initialize Serial port Serial.begin(9600); Serial.println(); Serial.println(F("--------------------------------")); Serial.println(F("APDS-9930 - Ambient light sensor")); Serial.println(F("--------------------------------")); // Initialize APDS-9930 (configure I2C and initial values) if ( apds.init() ) { Serial.println(F("APDS-9930 initialization complete")); } else { Serial.println(F("Something went wrong during APDS-9930 init!")); } // Start running the APDS-9930 light sensor (no interrupts) if ( apds.enableLightSensor(false) ) { Serial.println(F("Light sensor is now running")); } else { Serial.println(F("Something went wrong during light sensor init!")); } #ifdef DUMP_REGS /* Register dump */ uint8_t reg; uint8_t val; for(reg = 0x00; reg <= 0x19; reg++) { if( (reg != 0x10) && \ (reg != 0x11) ) { apds.wireReadDataByte(reg, val); Serial.print(reg, HEX); Serial.print(": 0x"); Serial.println(val, HEX); } } apds.wireReadDataByte(0x1E, val); Serial.print(0x1E, HEX); Serial.print(": 0x"); Serial.println(val, HEX); #endif // Wait for initialization and calibration to finish delay(500); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); } void loop() { // Read the light levels (ambient, red, green, blue) if ( !apds.readAmbientLightLux(ambient_light) || !apds.readCh0Light(ch0) || !apds.readCh1Light(ch1) ) { Serial.println(F("Error reading light values")); } else { Serial.print(F("Ambient: ")); Serial.print(ambient_light); Serial.print(F(" Ch0: ")); Serial.print(ch0); Serial.print(F(" Ch1: ")); Serial.println(ch1); lcd.setCursor(0,0); lcd.print("amb Light:"); lcd.print(ambient_light); lcd.setCursor(0,1); lcd.print("ch0:"); lcd.print(ch0); lcd.setCursor(8,1); lcd.print("ch1:"); lcd.print(ch1); } // Wait 1 second before next reading delay(1000); } After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and see the result in monitor.

  • Temperature Controlled Fan using DS18B20 and Arduino

    In this to learn step by step guide and we will show you how to make a temperature-controlled fan using Arduino, DS18B20 and interface with LCD display, and DC fan that is controlled by using PWM. The most important part is to set the variables temp Min and temp Max with your desired values. temp Min is the temperature at which the fan starts to spin and temp Max is the temperature when the red led lights warning you that the maximum temp was reached. For example if you set temp Min at 20 and temp Max at 40 then the fan will start spinning (0%) at 20°C and reach its maximum speed (100%) at 40°C. Example: If current Temperature 35°C, then Fan Speed 85%. Circuit Diagram: Components Required Arduino Uno - 1 no LCD display 16x1- I2C- 1 no DS18B20 with Probe - 1 no Fan 5VDC - 1 no Transistor 2N2222- 1 no Resistor 220E- 1 no DS18B20 Refer Project : https://www.dofbot.com/post/nodemcu-based-ds18b20-temperature-server Arduino UNO (PWM) Working on this project is very simple. We have created PWM at D8 pin of arduino and applied it at base terminal of the transistor. Then transistor creates a voltage according to the PWM input. PWM is a technique by using we can control the voltage or power. Formula for duty cycle given below: Duty Cycle= Ton/T Where T= total time or Ton+Toff And Ton= On time of pulse (means 1 ) And Toff= Off time of pulse (means 0) For generating PWM we have used “analogWrite(pin, PWM value)” fuction in 8 bit. Mean if PWM value is equivalent of analog value. So if we need to generate 100% of duty cycle then we pass 255 value as PWM in “analogWrite” Function. A low-frequency pulse-width modulation (PWM) signal, whose duty cycle is varied to adjust the fan’s speed is used. An inexpensive, single transistor-like 2N222 or BD139 can be used to drive a small DC Fan. Installing the Arduino Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Installing Libraries for DS18B20 To interface with the DS18B20 temperature sensor, you need to install the One Wire library . Follow the next steps to install those libraries. 1. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open. 2. Type “onewire” in the search box and install the OneWire library by Paul Stoffregen. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino code: include // OneWire DS18S20, DS18B20, DS1822 Temperature Example // http://www.pjrc.com/teensy/td_libs_OneWire.html OneWire ds(5); // on pin 10 (a 4.7K resistor is necessary) #include LiquidCrystal_I2C lcd(0x27,16,2); int Fan = 11; // the pin where fan is int led = 8; // led pin int temp; int tempMin = 20; // the temperature to start the fan 0% int tempMax = 40; // the maximum temperature when fan is at 100% int fanSpeed; int FanPWM; void setup(void) { Serial.begin(9600); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); pinMode(Fan, OUTPUT); pinMode(led, OUTPUT); } void loop(void) { byte i; byte present = 0; byte type_s; byte data[12]; byte addr[8]; float celsius, fahrenheit; if ( !ds.search(addr)) { Serial.println("No more addresses."); Serial.println(); ds.reset_search(); delay(250); return; } Serial.print("ROM ="); for( i = 0; i < 8; i++) { Serial.write(' '); Serial.print(addr[i], HEX); } if (OneWire::crc8(addr, 7) != addr[7]) { Serial.println("CRC is not valid!"); return; } Serial.println(); // the first ROM byte indicates which chip switch (addr[0]) { case 0x10: Serial.println(" Chip = DS18S20"); // or old DS1820 type_s = 1; break; case 0x28: Serial.println(" Chip = DS18B20"); type_s = 0; break; case 0x22: Serial.println(" Chip = DS1822"); type_s = 0; break; default: Serial.println("Device is not a DS18x20 family device."); return; } ds.reset(); ds.select(addr); ds.write(0x44, 1); // start conversion, with parasite power on at the end delay(1000); // maybe 750ms is enough, maybe not // we might do a ds.depower() here, but the reset will take care of it. present = ds.reset(); ds.select(addr); ds.write(0xBE); // Read Scratchpad Serial.print(" Data = "); Serial.print(present, HEX); Serial.print(" "); for ( i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); Serial.print(data[i], HEX); Serial.print(" "); } Serial.print(" CRC="); Serial.print(OneWire::crc8(data, 8), HEX); Serial.println(); // Convert the data to actual temperature // because the result is a 16 bit signed integer, it should // be stored to an "int16_t" type, which is always 16 bits // even when compiled on a 32 bit processor. int16_t raw = (data[1] << 8) | data[0]; if (type_s) { raw = raw << 3; // 9 bit resolution default if (data[7] == 0x10) { // "count remain" gives full 12 bit resolution raw = (raw & 0xFFF0) + 12 - data[6]; } } else { byte cfg = (data[4] & 0x60); // at lower res, the low bits are undefined, so let's zero them if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms //// default is 12 bit resolution, 750 ms conversion time } celsius = (float)raw / 16.0; fahrenheit = celsius * 1.8 + 32.0; Serial.print(" Temperature = "); Serial.print(celsius); Serial.print(" Celsius, "); Serial.print(fahrenheit); Serial.println(" Fahrenheit"); lcd.setCursor(0,0); lcd.print("C:"); lcd.print(celsius); lcd.setCursor(9,0); lcd.print("F:"); lcd.print(fahrenheit); ///// temp = celsius; // get the temperature Serial.print( temp ); if(temp < tempMin) // if temp is lower than minimum temp { fanSpeed = 0; // fan is not spinning analogWrite(Fan, fanSpeed); FanPWM=0; digitalWrite(Fan, LOW); } if((temp >= tempMin) && (temp <= tempMax)) // if temperature is higher than minimum temp { fanSpeed = temp;//map(temp, tempMin, tempMax, 0, 100); // the actual speed of fan//map(temp, tempMin, tempMax, 32, 255); fanSpeed=1.5*fanSpeed; FanPWM = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD100 analogWrite(Fan, fanSpeed); // spin the fan at the fanSpeed speed } if(temp > tempMax) // if temp is higher than tempMax { digitalWrite(led, HIGH); // turn on led } else // else turn of led { digitalWrite(led, LOW); } lcd.setCursor(0,1); // move cursor to next line lcd.print("FAN SPEED: "); lcd.print(FanPWM); // display the fan speed lcd.print("%"); lcd.print(" "); delay(200); //lcd.clear(); } After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and see the result in monitor.

  • Arduino Temperature Measure using (Thermistor -NTC)

    In this article, I’ll explain how thermistors work, then I’ll show you how to set up a basic thermistor circuit with an Arduino that will output temperature readings to the LCD. Thermistors are simple, inexpensive, and accurate components that make it easy to get temperature data for your projects. Remote weather stations, home automation systems, and equipment control and protection circuits are some applications where thermistors would be ideal. They’re analog sensors, so the code is relatively simple compared to digital temperature sensors that require special libraries and lots of code. Circuit Diagram: Components Required Arduino Uno - 1 no LCD display 16x1- I2C- 1 no Thermistor (NTC) KY-013 Module- 1 no Thermistor NTC stands for “Negative Temperature Coefficient. Thermistors are temperature-sensing elements made of semiconductor material that has been sintered in order to display large changes in resistance in proportion to small changes in temperature. This resistance can be measured by using a small and measured direct current, or dc, passed through the thermistor in order to measure the voltage drop produced. These solid state temperature sensors actually act like electrical resistors that are temperature sensitive. That is where the name, a clear combination of the words thermal and resistor, comes from. Specifications The temperature sensor is a NTC thermistor Multi-point temperature measurement Measures temperatures: -55°C / +125°C Accuracy: + / – 0.5°C Material: mixed material Dimensions: 3 x 1.5 x 0.6cm Weight : 2g Arduino Connection with KY-013 Temperature sensor Arduino pin analog A0 to KY-013 Module S (Signal) Arduino pin GND to KY-013Module –Pin Arduino pin 5+ to KY-013 Module +Pin Arduino Code for KY-013 Temperature sensor The analog sensor acts as a variable resistor. As temperature increases, the sensor will decrease it’s voltage output. Once we can measure the voltage output, we can calibrate the sensor and convert the output in voltage to temperature. The major problem NTC thermistor is the calibration, that is, to establish a function between electrical resistance and temperature. The variation in its electrical resistance with temperature is non-linear it may be seen as an exponential function according to equation Steinhart-Hart. As the thermistor brings me some information on the data sheet can use the Beta parametter of the Steinhart-Hart equation to get the temperature reading on the sensor. This can be solved for the temperature: R (Rout) = read resistance in the sensor β = defines the temperature differential to calibrate the sensor using the initial temperature and final temperature T1, T2 and their resistances. R∞ = models the exponential function. It seems a little hard, but all the values we need are tabulated only fitting the micro controller to do the calculations and deliver the read temperature. Defining values (temperatures in Celsius C) To calibrate the sensor is used at the temperatures T1 (initial) = 0 ° C, T2 (end) = 100 °, T0 = 25 ° C this and ambient operating temperature, such T1 and T2 temperatures have been set to the environment to be used, since T0 is the thermistor resistance value by default 10Kohm, the RT1 and RT2 of value are in Datasheet sensor. The code this commented, but follows some observations The code shows the value of the temperature in Celsius (C) and Fahrenheit (F) put all the calculations are made with the temperature in Kelvin (K). not being recommended to calculate the value in C or F, so in the beginning of the code I insert the K values TempK the variable returns the value of the temperature in K shortly after calculating. TempC converts K to C ((* TempC 9) / 5 + 32); this code converts C to F Installing the Arduino Library LiquidCrystal_I2C.h : you need to Downloadand install the LiquidCrystal_I2C library. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Arduino code: #include LiquidCrystal_I2C lcd(0x27,16,2); float Vin=5.0; // [V] float Rt=10000; // Resistor t [ohm] float R0=10000; // value of rct in T0 [ohm] float T0=298.15; // use T0 in Kelvin [K] float Vout=0.0; // Vout in A0 float Rout=0.0; // Rout in A0 // use the datasheet to get this data. float T1=273.15; // [K] in datasheet 0º C float T2=373.15; // [K] in datasheet 100° C float RT1=35563; // [ohms] resistence in T1 float RT2=549; // [ohms] resistence in T2 float beta=0.0; // initial parameters [K] float Rinf=0.0; // initial parameters [ohm] float TempK=0.0; // variable output float TempC=0.0; // variable output void setup() { Serial.begin(9600); lcd.begin(16,2); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); pinMode(0, INPUT); //parâmetros beta=(log(RT1/RT2))/((1/T1)-(1/T2)); Rinf=R0*exp(-beta/T0); } void loop() { Vout=Vin*((float)(analogRead(0))/1024.0); // calc for ntc Rout=(Rt*Vout/(Vin-Vout)); TempK=(beta/log(Rout/Rinf)); // calc for temperature TempC=TempK-273.15; lcd.setCursor(0,0); lcd.print("Temperature NTC"); lcd.setCursor(0,1); lcd.print(TempC); lcd.write(0xdf); // to display ° lcd.print("C "); lcd.print((TempC * 9)/5 + 32); // C to F lcd.write(0xdf); lcd.print("F"); delay(1200); }

  • IoT Based Battery Voltage Level Monitoring using TP-4056 and Thingspeak

    In this tutorial we learn Battery voltage monitor for solar panel Circuit, Car, Electronic Device etc. The measuring voltage of your solar panel battery, ups and other daily use batteries consumes a lot of time and Battery maintenance is also important. So that we make An IoT Based Battery Voltage Monitoring using Thingspeak Iot Platform. Battery is the most important component for any device as it powers the whole system. And it is important to monitor the voltage level of the battery as improper charging and discharging of a lithium battery may lead to a big safety issue. In this project, we will also build an IoT based Battery Monitoring System includes monitor the volts and Level status of the battery and data stores in IoT cloud. Circuit diagram Components Required ESP 12E NodeMCU - 1 no LiPo Charger (TP4056) - 1no Resistors 100K - 2nos Lithium Polymer Battery - 1no Solar Panel 5V - 1 no (Optional) or Micro USB charger 5V NodeMCU NodeMCU ESP8266-12E MCU is a development board with one analogue and many general-purpose input output (GPIO) pins. It has 4MB flash memory, and can operate at a default clock frequency of 80MHz. In this project, Analogl pin A0 of NodeMCU is used to read Data of Battery Voltage. Lithium-ion A lithium-ion battery or Li-ion battery is a type of rechargeable battery. Lithium-ion batteries are commonly used for portable electronics and electric vehicles. In this battery, lithium ions move from the negative electrode through an electrolyte to the positive electrode during discharge, and back when charging. The batteries have a high energy density, no memory effect and low self-discharge. Nominal, Maximum & Cut-off Voltage These are the few Lithium-Ion batteries that I have been using for very long for many of my projects. Some of the batteries has a simple attached Battery Management System Circuit for over-voltage protection, balanced charging, short-circuit protection etc. Most of the Lithium-Ion batteries have a nominal voltage of 3.7V. When the battery charges to full the maximum voltage are 4.2±0.5. If you see the manufacturer datasheet then it is clearly mentioned that the cut-off voltage is 3V and varies depending upon the battery type and applications. The battery I am using has a discharge cut-off voltage of 2.8V. You can also get some batteries with cut-off voltage of 2.5V. Voltage Divider Network Calculations The Battery Maximum voltage is 4.2V and the cut of voltage is 2.8V. Anything lesser than 3.3V will be easily supported by ESP12E Analog Pin A0. We have to first step down the upper voltage level. The source voltage is 4.2V and there is a pair of 100K resistors. This will give an output of 2.1V. Similarly, the minimum voltage is 2.8V as a cutoff voltage which steps down to 1.4V using the same voltage divider network. Hence, both the upper and lower voltage is supported by ESP12E Analog Pin. TP4056 This TP4056 1A Li-ion Lithium Battery Charging Module with Current Protection – Mini USB is a tiny module, perfect for charging single cell 3.7V 1 Ah or higher lithium ion (Li-Ion) cells such as 16550s that don’t have their own protection circuit. Based on the TP4056 charger IC and DW01 battery protection IC this module will offer 1A charge current then cut off when finished. The TP4056 is a complete constant-current/constant-voltage linear charger for single cell lithium-ion batteries. Its SOP package and low external component count make the TP4056 ideally suited for portable applications. Furthermore, the TP4056 can work within USB and wall adapter. Download Datasheet. Module Usage Connect mini USB cable for power, or 5V DC to pads marked IN+ and IN- on the left-hand side of the module Connect cell to charge to B+/B- pads on the right-hand side of the module. A load (something for the battery to power) can be connected to the OUT+/OUT- pads on the right-hand side Important! Disconnect load when charging The red LED indicates charging in progress, a green LED indicates charging has finished. Never charge your battery at a rate greater than 1C. Note: Ampere meter can only be connected to a 5v input end of the module. It is better than the charging current is 37% of the battery capacity. If you charge the battery of 1000mAh, a current of 400mAh is enough. The connection wire should not be too thick. Make sure the connect point is good. If the input voltage is too high, like 5.2v, the current will be less than 1000mA, it is normal. It is protection function, auto-subtract the charging current to avoid burn damage to the chip. NO Reverse polarity. Thingspeak ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. You can send data to ThingSpeak from your devices, create instant visualization of live data, and send alerts. https://thingspeak.com/ Create an account or simply sign in if you created the account earlier. Then create a new channel. Arduino code Subscribe and Get code. #include //SSID and Password of your WiFi router const char* ssid = "xxxxxxxxxx"; // replace with your SSID const char* password = "xxxxxxxxxxxxxx"; // Replace with Wifi Password String apiKey = "xxxxxxxxxxxxxxxxx"; const char* server = "api.thingspeak.com"; int analogInPin = A0; // Analog input pin int sensorValue; // Analog Output of Sensor float calibration = 0.05; // Accuracy int bat_percentage; WiFiClient client; void setup() { Serial.begin(115200); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(100); Serial.print("*"); } Serial.println(""); Serial.println("WiFi connected"); } void loop() { sensorValue = analogRead(analogInPin); float voltage = (((sensorValue * 3.3) / 1024) * 2 + calibration); //multiply by two as voltage divider network is 100K & 100K Resistor bat_percentage = mapfloat(voltage, 2.8, 4.2, 0, 100); //2.8V as Battery Cut off Voltage & 4.2V as Maximum Voltage if (bat_percentage >= 100) { bat_percentage = 100; } if (bat_percentage <= 0) { bat_percentage = 1; } Serial.print("Analog Value = "); Serial.print(sensorValue); Serial.print("\t Output Voltage = "); Serial.print(voltage); Serial.print("\t Battery Percentage = "); Serial.println(bat_percentage); delay(1000); if (client.connect(server, 80)) { String postStr = apiKey; postStr += "&field1="; postStr += String(voltage); postStr += "&field2="; postStr += String(bat_percentage); postStr += "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); delay(100); client.print("Host: api.thingspeak.com\n"); delay(100); client.print("Connection: close\n"); delay(100); client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n"); delay(100); client.print("Content-Type: application/x-www-form-urlencoded\n"); delay(100); client.print("Content-Length: "); delay(100); client.print(postStr.length()); delay(100); client.print("\n\n"); delay(100); client.print(postStr); delay(100); } client.stop(); Serial.println("Sending...."); delay(15000); } float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } Then, upload the code to your NodeMCU board. Make sure you have selected the right board and COM port. Also, make sure you’ve inserted your WiFi Credentials in the code. After a successful upload, open the Serial Monitor at a baud rate of 115200. Press the “EN/RST” button on the ESP8266 board.

  • Iot Based Fire Alarm Notification using Blynk

    In this article we interface Flame Sensor with NodeMCU and learn all the steps to build Fire Alarm notification using Blynk IoT Platform. Circuit diagram Components Required ESP 12E- NodeMCU - 1 no IR Flame sensor module - 1 no Buzzer Flame Sensor The flame sensor detects and responses to the presence of fire or flame. The module is based on the IR receiver and basically detects the presence of flammable gases likes nitrogen, hydrogen, carbon mono oxide. The sensor can be directly interfaced with I/O pins of processors and controllers. It works in the wavelength of the range between 760 nm to 1100 nm in the light source. Specification Voltage supply: 3.3-5V Signal detection capacity: adjustable Wavelength range: 760 nm-1100 nm Detection angle: up to 60 degree Fast response time Easy to use Applications of flame sensors Fire alarm Firefighting robot Home security system Blynk Is an IoT platform to connect your devices to the cloud, design apps to control them, analyze telemetry data, and manage your deployed products at scale. Blynk IoT Setup: First of all, open the blynk application. Click on the create a new project Click on Choice Tools and select NodeMCU ESP8266. Make sure the connection type is set to WIFI. Watch video for further setup. Finally, click on the create button, a verification token will be sent to your email ID, which will be used in the Program CODE. Click anywhere on the screen, and search for the Notification Widget. Now Your designed IoT Fire Control application is ready to use. Installing Library Download these libraries from the given links. Blynk Download - Blynk Library can connect any hardware over Ethernet, WiFi, or GSM, 2G, 3G, LTE, etc. After downloading the .zip files, add the libraries in Arduino IDE by clicking on To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Subscribe and download code. Arduino code: #define BLYNK_PRINT Serial #include #include BlynkTimer timer; //SSID and Password of your WiFi router const char* ssid = "xxxxx"; // replace with your SSID const char* password = "xxxxx"; // Replace with Wifi Password char auth[] = " xxxxxxxxxxxxxxxxxxxxxxxx"; //Auth code sent via Email int flag=0; void notifyOnFire() { int isButtonPressed = digitalRead(D1); if (isButtonPressed==1 && flag==0) { Serial.println("KY-026 : Fire Detected"); Blynk.notify("Fire Alert Message: Take Action Immediately"); flag=1; } else if (isButtonPressed==0) { flag=0; } } void setup() { Serial.begin(9600); Blynk.begin(auth, ssid, password ); pinMode(D1,INPUT_PULLUP); timer.setInterval(1000L,notifyOnFire); } void loop() { Blynk.run(); timer.run(); } Then, upload the code to your NodeMCU board. Make sure you have selected the right board and COM port. Also, make sure you’ve inserted your WiFi Credentials in the code. After a successful upload, open the Serial Monitor at a baud rate of 9600.

  • IoT Based Servo Control (Pan Tilt) Using Blynk app

    In this tutorial we will learn how to control a PTZ mini-kit (Pan-Tilt) based Blynk app and SG90 servo motor. For this project, you can use your official Blynk account (and use some energy) or install a local Blynk server and enjoy unlimited energy. Circuit diagram Components Required ESP8266 12e- NodeMCU - 1 no PTZ SG90 (Pan-Tilt) - 1 no Servo SG90- 2 no PTZ SG90 mini kit Pan and tilt systems used in today's robotics applications for security, industrial, and military applications have to move faster, smoother, and more accurately than ever before. At the same time, these systems need to be cost effective, easy to program. Refer sssembly : https://www.dofbot.com/post/pan-tilt-servo-control-using-nodemcu Connecting the Servo Motor to the ESP8266 Servo motors have three wires: power, ground, and signal. Servo Wire Color Power-Red GND-Black, or brown Signal-Yellow, orange, or white When using a small servo like the SG90 as shown in the figure below, you can power it directly from the ESP8266. If you’re using a small servo like the SG90, you need to connect: GND -> ESP8266 GND pin; Power -> ESP8266 Vin pin; Signal -> D5 and D6 (or any PWM pin). Blynk App Is an IoT platform to connect your devices to the cloud, design apps to control them, analyze telemetry data, and manage your deployed products at scale Blynk IoT Setup: First of all, open the blynk application. Click on the create a new project Click on Choice Tools and select NodeMCU ESP8266. Make sure the connection type is set to WIFI. Watch video for further setup. Installing Library Download these libraries from the given links. Blynk Download - Blynk Library can connect any hardware over Ethernet, WiFi, or GSM, 2G, 3G, LTE, etc. After downloading the .zip files, add the libraries in Arduino IDE by clicking on To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Subscribe and download code. Arduino code: #define BLYNK_PRINT Serial #include #include #include //SSID and Password of your WiFi router const char* ssid = "xxxxxxxxx"; // replace with your SSID const char* password = "xxxxxxx"; // Replace with Wifi Password //Blynk Token char auth[] = "xxxxxxxx"; Servo pan; Servo tilt; BLYNK_WRITE(V0) { Serial.print("move Pan to "); Serial.println(param.asInt()); pan.write(param.asInt()); } BLYNK_WRITE(V1) { Serial.print("move Tilt to "); Serial.println(param.asInt()); tilt.write(param.asInt()); } void setup() { Serial.begin(115200); // See the connection status in Serial Monitor Blynk.begin(auth, ssid, password); pan.attach(D5); tilt.attach(D6); } void loop() { Blynk.run(); } Then, upload the code to your NodeMCU board. Make sure you have selected the right board and COM port. Also, make sure you’ve inserted your WiFi Credentials in the code. After a successful upload, open the Serial Monitor at a baud rate of 115200.

  • Web Server Based Weather Monitor using DHT 11 & Rain Sensor

    In this project, we’ll learn how to make a featured weather station using an ESP8266, DHT11 and Rain sensors. The rain sensor module is Vary easy tool for rain detection. It can be used as a switch when raindrop falls through the raining board and also for measuring rainfall intensity. The module features, a rain board and the control board that is separate for more convenience, power indicator LED and an adjustable sensitivity though a potentiometer. Raindrop sensor is basically a board on which nickel is coated in the form of lines. It works on the principal of resistance. When there is no rain drop on board. Resistance is high so we gets high voltage according to V=IR. When rain drop present it reduces the resistance because water is conductor of electricity and presence of water connects nickel lines in parallel so reduced resistance and reduced voltage drop across it. It consists of two parts one is a black board with nickel layers on it and other is an integrated chip provided with some output pins.Board has 2 output pin and chip has 6 pin. The analog output is used in detection of drops in the amount of rainfall. Connected to 3,3V power supply, the LED will turn Off when induction board has no rain drop, and output is Low. When dropping a little amount water, output is High, the switch indicator will turn on. Brush off the water droplets, and when restored to the initial state, outputs high level.When no rain digital output is 1 and analog output gives 1023 max value. When rain is present digital output is 0 and analogue output is much less than 1023. Hygrometer (DHT11)- A hygrometer measures relative humidity. Relative humidity is the quantity or percentage of water vapor (water in gas form) in the air. Humidity influences environmental factors and calculations like precipitation, fog, dew point and heat index. In addition, maintaining proper humidity indoors has implications for your health and home. Circuit Diagram Components Required ESP8266 12E- 1 no DHT11 - 1 no Rain sensor - 1 no Rain drop Sensor Module Raindrop Sensor is a tool used for sensing rain. It consists of two modules, a rain board that detects the rain and a control module, which compares the analog value, and converts it to a digital value. The raindrop sensors can be used in the automobile sector to control the windshield wipers automatically, in the agriculture sector to sense rain and it is also used in home automation systems. Pin Configuration of Rain Sensor: Pin Name Function 1 VCC Connects supply voltage- 5V 2 GND Connected to ground 3 D0 Digital pin to get digital output 4 A0 Analog pin to get analog output he control module of the raindrop sensor has 4 outputs. VCC is connected to a 5V supply. The GND pin of the module is connected to the ground. The D0 pin is connected to the digital pin of the microcontroller for digital output or the analog pin can be used. To use the analog output, the A0 pin can be connected to the ADC pin of a microcontroller. In the case of Arduino, it has 6 ADC pins, so we can use any of the 6 pins directly without using an ADC converter. The sensor module consists of a potentiometer, LN393 comparator, LEDs, capacitors and resistors. The pinout image above shows the components of the control module. The rainboard module consists of copper tracks, which act as a variable resistor. Its resistance varies with respect to the wetness on the rainboard. The below fig shows the rain board module. The circuit diagram of a raindrop sensor module The R1 resistor and the rain board module will act as a voltage divider. Capacitors C1 and C2 are used as a biasing element. The input for the Non-inverting terminal is taken from the connection point of the R1, and rain board module. Another point is taken from this connection and connected to the A0 terminal of the control module. The input to the inverting terminal of the LM393 is taken from the potentiometer (R2). The R2 resistor acts as a voltage divider, and by varying R2 we can vary the input voltage to the inverting terminal, which in turn affects the sensitivity of the control module. The connections are shown in the above fig. The resistors R3 and R4 will act as current limiting resistors, while resistor R5 will act as a pull-up resistor to keep the bus in a high state when not in use. Working of Rain Sensor: Case1: When the input of the inverting terminal is higher than the input of the non-inverting terminal. Case2: If the input of the inverting terminal is lower than the input of the non-inverting terminal. The input to the inverting terminal is set to a certain value by varying the potentiometer and the sensitivity is set. When the rain board module’s surface is exposed to rainwater, the surface of the rainboard module will be wet, and it offers minimum resistance to the supply voltage. Due to this, the minimum voltage will be appearing at the non-inverting terminal of LM393 Op-Amp. The comparator compares both inverting and non-inverting terminal voltages. If the condition falls under case(1), the output of the Op-Amp will be digital LOW. If the condition falls under case(2), the output of the Op-Amp will be digital HIGH. The below diagram shows the equivalent circuit of both the conditions. When the A0 pin is connected to the microcontroller, an additional analog to digital converter (ADC) circuit is used. In the case of Arduino, it consists of 6 ADC pins, which can be directly used for calculation purposes. Applications of Rain sensor: Automatic windshield wipers Smart Agriculture Home-Automation Download datasheet DHT11–Temperature and Humidity Sensor The DHT11 is a commonly used Temperature and humidity sensor. The sensor comes with a dedicated NTC to measure temperature and an 8-bit microcontroller to output the values of temperature and humidity as serial data. The sensor is also factory calibrated and hence easy to interface with other microcontrollers. The sensor can measure temperature from 0°C to 50°C and humidity from 20% to 90% with an accuracy of ±1°C and ±1%. So if you are looking to measure in this range then this sensor might be the right choice for you. Download datasheet NodeMCU Code for Weather Station Program is divided in two parts. first part contains ESP8266 WiFi and Hardware related functions i.e. .ino file. Second part is HTML and user interface GUI. it is index.h file. The index.h files copy here below. const char MAIN_page[] PROGMEM = R"=====( 21 March Temperature 23 °C LIVE WEATHER STATION TEMPERATURE 21 °C HUMIDITY 23% RAIN 0% )====="; Weather Station Software Working Software consists of following parts. Connecting to WiFi Server Creation Getting Data from Sensors Sending GUI to user Updating Sensors values on web page Weather Station Hardware Hardware part is simple we are using only two sensors DHT11 and Rain Sensor. You can add more sensors like BMP180 barometric pressure sensor. Rain sensor analog output is connected to Analog input of ESP8266 through a voltage divider. which drops the output of rain sensor to suit ESP8266 analog input maximum range. DHT11 gives us humidity and temperature readings. It is digital sensor gives output in serial stream of data. For this sensor interfacing we are using DHTesp library which takes care of all communication with DHT11 sensor. DHT11 is connected to NodeMCU pin D5 which is GPIO14. Connecting to WiFi Connection to you wifi is made by ESP8266 using below code. First we define wifi ssid and password. const char* ssid = "xxxxx"; const char* password = "xxxxx"; Then we try to connect with wifi using WiFi.begin(ssid, password) and wait until connection successful using while (WiFi.status() != WL_CONNECTED). Once we connect to wifi successfully we print IP address assigned by you WiFi Router on Serial monitor using WiFi.localIP() function. Next part is to create web server on ESP8266. for this we are including web server library #include Then we create server instance using below function. Web uses default port 80, so we defined it as port 80. ESP8266WebServer server(80); //Server on port 80 After this in setup() we create client request handling functions, one for displaying GUI and another which sends the sensor data to user using AJAX and JSON. AJAX is part of web page. server.on("/", handleRoot); //Which routine to handle at root location. This is display page server.on("/readADC", handleADC); //This page is called by java Script AJAX server.begin(); //Start server Serial.println("HTTP server started"); When user enters ESP8266 IP it requests root page. That request is served by handleRoot() function. It sends web page (HTML) to user (web browser). void handleRoot() { String s = MAIN_page; //Read HTML contents server.send(200, "text/html", s); //Send web page } Once the web page is loaded it contains javascript with AJAX code which sends data request to ESP8266 webserver at /readADC. This readADC request is handled by handleADC() function. as shown below. Handled ADC sends data first to web client and after that it reads DHT11 sensor to prevent data lags. In this you can clearly see data variable holds the JSON of sensor values. Many escape characters are uses as we are using double quotes in JSON. void handleADC() { int rain = analogRead(A0); //Create JSON data String data = "{\"Rain\":\""+String(rain)+"\", \"Temperature\":\""+ String(temperature) +"\", \"Humidity\":\""+ String(humidity) +"\"}"; digitalWrite(LED,!digitalRead(LED)); //Toggle LED on data request ajax server.send(200, "text/plane", data); //Send ADC value, temperature and humidity JSON to client ajax request //Get Humidity temperatue data after request is complete //Give enough time to handle client to avoid problems delay(dht.getMinimumSamplingPeriod()); humidity = dht.getHumidity(); temperature = dht.getTemperature(); Installing the arduino Library Download DHT sensor library for ESPx After downloading the .zip files, add the libraries in Arduino IDE by clicking on To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Subscribe and download code. Arduino Code: #include #include #include #include "index.h" //Our HTML webpage contents with javascripts #include "DHTesp.h" //DHT11 Library for ESP #define LED 2 //On board LED #define DHTpin 14 //D5 of NodeMCU is GPIO14 DHTesp dht; // Replace with your SSID and Password here const char* ssid = "XXXXX"; const char* password = "XXXXXXXX"; ESP8266WebServer server(80); //Server on port 80 void handleRoot() { String s = MAIN_page; //Read HTML contents server.send(200, "text/html", s); //Send web page } float humidity, temperature; void handleADC() { int rain = analogRead(A0); //Create JSON data String data = "{\"Rain\":\""+String(rain)+"\", \"Temperature\":\""+ String(temperature) +"\", \"Humidity\":\""+ String(humidity) +"\"}"; digitalWrite(LED,!digitalRead(LED)); server.send(200, "text/plane", data); delay(dht.getMinimumSamplingPeriod()); humidity = dht.getHumidity(); temperature = dht.getTemperature(); Serial.print("H:"); Serial.println(humidity); Serial.print("T:"); Serial.println(temperature); //dht.toFahrenheit(temperature)); Serial.print("R:"); Serial.println(rain); } void setup() { Serial.begin(115200); Serial.println(); dht.setup(DHTpin, DHTesp::DHT11); //for DHT11 Connect DHT sensor to GPIO 17 WiFi.begin(ssid, password); //Connect to your WiFi router Serial.println(""); pinMode(LED,OUTPUT); // Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); //IP address assigned to your ESP server.on("/", handleRoot); //Which routine to handle at root location. This is display page server.on("/readADC", handleADC); //This page is called by java Script AJAX server.begin(); //Start server Serial.println("HTTP server started"); } void loop() { server.handleClient(); //Handle client requests } After uploading open serial monitor and get the ip address. Open IP address in Web Browser. After opening it in web browser, you will see that on board blue LED will Blink. this led toggles when it receives http request from web browser.

bottom of page