IOT
IOT
IOT
Prerequis
ite:
In-Lab:
OBJECTIVE:To Blink an On-Board LED on NodeMCU .
SOFTWARE REQUIREMENTS:1)uPycraft.
Or
2) Arduino IDE.
PRE-LAB WORK:
NodeMCU is an open source IoT platform.It includes firmware which runs on the ESP8266 Wi-
Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.The ESP8266
NodeMcu is a complex device, which combines some features of the ordinary Arduino board with
the possibility of connecting to the internet.
Features:
It is a Tensilica 32-bit RISC CPU Xtensa LX106 Microcontroller.
Its Operating Voltage is 3.3V & Input Voltage is 7-12V.
Its having 16 Digital I/O Pins & 1 Analog Input Pin (ADC).
Its having Flash Memory of 4MB & SRAM 64KB. NodeMCUhaving clock speed of 80
Mhz.
Operating temperature range -40C ~ 125C.
Modes of operation: Client, Access point, Client + Access point.
10-bit ADC, SDIO 2.0, (H) SPI, UART, I2C, I2S, IR Remote Control, PWM, GPIO.
The interface of the module is mainly divided into two parts including both Firmware
and Hardware where former runs on the ESP8266 Wi-Fi SoC and later is based on the ESP-12 module.
Pin Diagram:
Pin Description:
1)Power Pin:There are four power pins viz. one VIN pin & three 3.3V pins. The VIN pin can be
used to directly supply the ESP8266 and its peripherals, if you have a regulated 5V voltage source.
The 3.3V pins are the output of an on-board voltage regulator.These pins can be used to supply
power to external components.
3)I2C Pins:I2C Pins are used to hook up all sorts of I2C sensors and peripherals in your project.
Both I2C Master and I2C Slave are supported. I2C interface functionality can be realized
programmatically, and the clock frequency is 100 kHz at a maximum.It should be noted that I2C
clock frequency should be higher than the slowest clock frequency of the slave device.
4)GPIO Pins:ESP8266 NodeMCU has 17 GPIO pins which can be assigned to various functions
such as I2C, I2S, UART, PWM, IR Remote Control, LED Light and Button programmatically.Each
digital enabled GPIO can be configured to internal pull-up or pull-down, or set to high impedance.
When configured as an input, it can also be set to edge-trigger or level-trigger to generate CPU
interrupts.
5)ADC Channel:The NodeMCU is embedded with a 10-bit precision SAR ADC. The two
functions can be implemented using ADC viz. Testing power supply voltage of VDD3P3 pin and
testing input voltage of TOUT pin. However, they cannot be implemented at the same time.
6)UART Pins:ESP8266 NodeMCU has 2 UART interfaces, i.e. UART0 and UART1, which
provide asynchronous communication (RS232 and RS485), and can communicate at up to 4.5 Mbps.
UART0 (TXD0, RXD0, RST0 & CTS0 pins) can be used for communication.It supports fluid
control. However, UART1 (TXD1 pin) features only data transmit signal so, it is usually used for
printing log.
7)SPI Pins:ESP8266 features two SPIs (SPI and HSPI) in slave and master modes. These SPIs
also support the following general-purpose SPI features:
4 timing modes of the SPI format transfer.
Up to 80 MHz and the divided clocks of 80 MHz.
Up to 64-Byte FIFO.
8)SDIO Pins:ESP8266 features Secure Digital Input/Output Interface (SDIO) which is used to
directly interface SD cards. 4-bit 25 MHz SDIO v1.1 and 4-bit 50 MHz SDIO v2.0 are supported.
9)PWM Pins:The board has 4 channels of Pulse Width Modulation (PWM). The PWM output can
be implemented programmatically and used for driving digital motors and LEDs. PWM frequency
range is adjustable from 1000 μs to 10000 μs, i.e., between 100 Hz and 1 kHz.
10)Control Pins:Control Pins are used to control ESP8266. These pins include Chip Enable pin
(EN), Reset pin (RST) and WAKE pin.EN pin – The ESP8266 chip is enabled when EN pin is pulled
HIGH. When pulled LOW the chip works at minimum power.RST pin – RST pin is used to reset the
ESP8266 chip.WAKE pin – Wake pin is used to wake the chip from deep-sleep.
POST-LAB REQUIREMENTS:
Observe the OUTPUT and note down the readings carefully.
Apply this concepts to make our projects or Applications.
Submit practical report in next lab for correction.
CODE:
import time
from machine import Pin
led=Pin(4,Pin.OUT)
while True:
led.value(1)
time.sleep(0.5)
led.value(0)
time.sleep(0.5)
CIRCUIT DIAGRAM:
PROCEDURE:
1. Make the connections as per the circuit diagram.
2. Check the ground connection precisely before switching on the power supply.
3. Connect Micro USB Cable to PC .
4. Write the Code in Python or C/C++ accordingly .
5. Run the code through Arduino IDE or uPycraft IDE and Observe the output.
PRECAUTIONS:
1.Check the sensor is working properly.
2.Check the connections are properly connected.
3.See that there are no errors in the code.
4. Check whether Ground and VCC connections are connected properly.
NODEMCU
PREREQUIST:-
In-Lab:-
OBJECTIVE:-
To design and implement a circuit to detect Gas using MQ-135 with the help of NODEMCU.
COMPONENTS REQUIRED:-
MQ-135
NODEMCU
Connecting Wires
Buzzer, Breadboard
USB Cable
PRE-LAB WORK:-
GAS SENSOR(MQ-135):-
In this project we will learn about Gas Level Using NODEMCU & Gas Sensor
Module(MQ135). We will measure the quantity of gas in percentage.If the gas percentage increases
then the buzzer rings and led glows.
The MQ-135 gas sensor senses the gases like ammonia nitrogen, oxygen, alcohols,
aromatic compounds, sulfide and other harmful smoke. The MQ-3 gas sensor has a lower
conductivity to clean the air as a gas sensing material. In the atmosphere we can find polluting
gases, but the conductivity of gas sensor increases as the concentration of polluting gas increases.
MQ-135 gas sensor can be implementation to detect the smoke, benzene, steam and other
harmful gases. It has potential to detect different harmful gases. It is with low cost and particularly
suitable for Air quality monitoring application.
MQ-135
PIN DESCRIPTION:-
The MQ135 sensor is a signal output indicator instruction. It has two outputs: analog output
and TTL output. The TTL output is low signal light which can be accessed through the IO ports on
the Microcontroller. The analog output is an concentration, i.e. increasing voltage is directly
proportional to increasing concentration.
This sensor has a long life and reliable stability as well. It has high Sensitivity to detect
Ammonia, Sulfide and Benze.It can detect at a range of: 10 – 300 ppm NH3, 10 – 1000 ppm
Benzene, 10 – 300 Alcohol. It is operated at voltage of 5.0V.It is of low cost.
NODEMCU:-
NodeMCU is an open source IoTplatform.It includes firmware which runs on the ESP8266
Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.The
ESP8266 NodeMcu is a complex device, which combines some features of the ordinary Arduino
board with the possibility of connecting to the internet.
NodeMCU
CIRCUIT DIAGRAM:-
PROCEDURE:-
CODE:-
int buzzer = 8;
intsensorThres = 100;
void setup()
pinMode(buzzer, OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);
void loop() {
intanalogSensor = analogRead(smokeA0);
Serial.println(analogSensor);
if (analogSensor-50 >sensorThres)
else
noTone(buzzer);
delay(500);
PRECAUTIONS:-
RESULT:-
Hence the gas sensor senses the harmful gases present around it, by using NODEMCU
microcontroller.
POST LAB:-
PREREQUISTE:
General idea of microcontrollers like Arduino
General idea how a sensor works.
IN LAB:-
OBJECTIVE:-
To know the amount pressure using BMP180 with the help of ESP32 .
COMPONENTS REQUIRED:-
o BMP180
o Breadboard
o ESP32
o Connecting wires
o USB Cable
PRE-LAB WORK:-
In this project we will learn about amount of Pressure Using ESP32 & Pressure
Sensor Module(BMP180). We will measure the amount of pressure applied. If the increases then
the buzzer rings.
PRESSURE SENSOR(BMP180):
The BMP180is a digital pressure sensor and it measures the absolute pressure of the air
around it. It features a measuring range from 300 to 1100hPa with an accuracy down to 0.02 hPa.
Because temperature affects the pressure, the sensor comes with a temperature sensor to give
temperature compensated pressure readings. Additionally, because the pressure changes with
altitude, you can also estimate the altitude based on the current pressure measurement.
There are only two pins present to communicate with the module. The BMP180 barometric sensor
uses I2C communication protocol. So, you need to use the SDA and SCL pins of the ESP32.It has
capable to read pressure, temperature, altitude parameters also. The data is sent to the module or
received from the module though I2C interface. So we have to get the information of barometric
pressure and temperature through this interface.
FEATURES OF BMP180:-
Can measure temperature and altitude.
Pressure range: 300 to 1100hPa.
High relative accuracy of ±0.12hPa.
Can work on low voltages.
3.4Mhz I2C interface.
Low power consumption (3uA)
Pressure conversion time: 5msec.
Potable size.
ESP32(MICRO CONTROLLER):-
ESP32 is a series of low-cost, low-power system on a chipmicrocontrollers with integrated Wi-
Fi and dual-mode Bluetooth. The ESP32 series employs a Tensilica Xtensa LX6 microprocessor in
both dual-core and single-core variations and includes built-in antenna switches, power amplifier,
low-noise receive amplifier, filters, and power-management modules. ESP32 is created and
developed by Espressif Systems, a Shanghai-based Chinese company, and is manufactured
by TSMC using their 40nm process.
PIN DESCRIPTION:-
The ESP32 chip comes with 48 pins with multiple functions. 18 Analog-to-Digital Converter
(ADC) channels, 3 SPI interfaces, 3 UART interfaces,2-I2C interfaces, 16 PWM output channels, 2
Digital-to-Analog Converters (DAC), 2 I2S interfaces, 10 Capacitive sensing GPIOs. ESP32 is
capable of functioning reliably in industrial environments, with an operating temperature ranging
from –40°C to +125°C.
CIRCUIT DIAGRAM:-
PROCEDURE:-
1. Make the connections as per the circuit diagram.
2. Check the ground connection precisely before switching on the power supply.
3. Connect Micro USB Cable to PC .
4. Write the Code in Python or C/C++ accordingly.
5. Run the code through Arduino IDE or uPycraft IDE and Observe the output.
CODE:-
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;
void setup() {
Serial.begin(9600);
if (!bmp.begin()) {
while (1) {}
void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");
Serial.print(bmp.readSealevelPressure());
Serial.println(" Pa");
Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(102000));
Serial.println(" meters");
Serial.println();
delay(500);
PRECAUTIONS:-
RESULT:-
Hence the pressure sensor calculates the amount of pressure using barometer(BMP180) with
the help of ESP32.
POST LAB:-
In-Lab:
OBJECTIVE:
To design and implement controlling of servo motor with the ESP32.
COMPONENTS REQUIRED:
ESP32
SERVO MOTOR
JUMPER WIRES
POWER SUPPLY
CONNECTING WIRES
SORFTWARE REQUIRED:
1. uPycraft
or
2. Arduino ide
PRELAB WORK:
ESP32 MICROCONTROLLER
ESP32 is in the series of low power and low cost on chip
microcontroller. It comes up with already integrated dual mode Bluetooth and Wi-Fi. ESP32
comes up with a USB port so we can say that it is a plug and play device i.e. just plug in
cable and your device is turned on and you are able to program it just like Arduino
development boards.
Features:
• Built in Wi-Fi module of standard 802.11 and Wi-Fi module operate in range of 2.4 GHz –
2.5 GHz.
SERVO MOTOR :
A servo motor is an electronic device which can push or rotate an object with great pression.
If motors uses dc power then it is called dc servo motor, and if it is uses ac power supply
then it is called ac servo motor
Servo motors works on pwm principle
Its angle of rotation is controlled by the duration of pulse applied to its control pin.
CIRCUIT DIAGRAM:
POST-LAB
LAB REQUIREMENTS:
Observe the OUTPUT and note down the readings carefully.
Apply this concepts to make our projects or Applications.
Submit practical report in next lab for correction.
CODE:
void loop(){
servo_1.write (45); // Servo will move to 45 degree angle.
delay (1000);
servo_1.write (90); // servo will move to 90 degree angle.
delay (1000);
Servo_1.write(135); //servo will move to 135 degree angle.
Delay(1000);
Servo_1.write(180); //servo will move to 180 degree angle.
}
PROCEDURE:
1.) Make the connections as per the circuit diagram.
2.) Connect the Vcc pin of the servo motor to the Vcc pin of esp32
3.) Connect input pin of the servo motor to the digital input pins of the esp32
PRECAUTIONS:
1. Check the sensor is working properly.
2. Check the connections are properly connected.
3. See that there are no errors in the code.
4. Check whether Ground and VCC connections are connected properly.
AIM:
To control the servo motor using ESP-32(BLUETOOTH MODULE)
COMPONENTS REQUIRED:
ESP 32
Few Jumper Wires
Servo Motor(We can use any type of servo motor within the current limit of ESP32)
PRE-LAB WORK:
SERVOMOTOR
A servo motor is an electrical device which can push or rotate an object with great precision.
If you want to rotate and object at some specific angles or distance, then you use servo motor.
It is just made up of simple motor which run through servo mechanism.
WORKING PRINCIPLE OF SERVO MOTOR
A servo consists of a Motor (DC or AC), a potentiometer, gear assembly and a controlling
circuit. First of all we use gear assembly to reduce RPM and to increase torque of motor. Say
at initial position of servo motor shaft, the position of the potentiometer knob is such that there
is no electrical signal generated at the output port of the potentiometer. Now an electrical
signal is given to another input terminal of the error detector amplifier. Now difference
between these two signals, one comes from potentiometer and another comes from other
source, will be processed in feedback mechanism and output will be provided in term of error
signal. This error signal acts as the input for motor and motor starts rotating. Now motor shaft
is connected with potentiometer and as motor rotates so the potentiometer and it will generate a
signal. So as the potentiometer’s angular position changes, its output feedback signal changes.
After sometime the position of potentiometer reaches at a position that the output of
potentiometer is same as external signal provided. At this condition, there will be no output
signal from the amplifier to the motor input as there is no difference between external applied
signal and the signal generated at potentiometer, and in this situation motor stops rotating.
Servo motor works on PWM (Pulse width modulation) principle, means its angle of rotation
is controlled by the duration of applied pulse to its Control PIN. Basically servo motor is made
up of DC motor which is controlled by a variable resistor (potentiometer) and some gears.
High speed force of DC motor is converted into torque by Gears. We know that WORK=
FORCE X DISTANCE, in DC motor Force is less and distance (speed) is high and in Servo,
force is High and distance is less. Potentiometer is connected to the output shaft of the Servo,
to calculate the angle and stop the DC motor on required angle.
ESP32
As you might know, the ESP32 is an incredibly feature-packed module that has not only WiFi
but also Bluetooth Low Energy (BLE).
BLUETOOTH LOW ENERGY(BLE)
ESP32 not just supports the latest BLE Bluetooth 4.2, it also supports classic bluetooth. It basically
means it can speak to old and new bluetooth phones/tables. This could one of the best features
especially, if you're designing a device that needs to work with existing as well as new
phones/tablets in the market. The ESP32 Bluetooth Radio and Baseband supports the following
features:
Class-1, class-2 and class-3 transmit output powers and over 30 dB dynamic control range
π/4 DQPSK and 8 DPSK modulation
High performance in NZIF receiver sensitivity with over 98 dB dynamic range
Class-1 operation without external PA
Internal SRAM allows full speed data transfer, mixed voice and data, and full piconet operation
Logic for forward error correction, header error control, access code correlation, CRC,
demodulation, encryption bit stream generation, whitening and transmit pulse shaping
ACL, SCO, eSCO and AFH
A-law, µ-law and CVSD digital audio CODEC in PCM interface
SBC audio CODEC
Power management for low power applications
PAJ7620
The PAC7620 integrates gesture recognition function with general I2C interface into a single chip
forming an image analytic sensor system. It can recognize 9 human hand gesticulations such as
moving up, down, left, right, forward, backward, circle-clockwise, circle-counter clockwise, and
waving. It also offers built-in proximity detection in sensing approaching or departing object from
the sensor. The PAC7620 is designed with great flexibility in power-saving mechanism, well suit
for low power battery operated HMI devices. The PAJ7620 is packaged into module form in-built
with IR LED and optics lens as a complete sensor solution
CODE:
constintxpin = A0; // x-axis of the accelerometer
constintypin = A3; // y-axis
constintzpin = A4; // z-axis
void setup()
{
Serial.begin(9600);
}
void loop()
{
int x = analogRead(xpin); //read from xpin
delay(1); //
int y = analogRead(ypin); //read from ypin
delay(1);
int z = analogRead(zpin); //read from zpin
RESULT:
LAB SESSION 06:GREETINGS MESSAGETHROUGH
WEBPAGEWITH ESP AS SERVER
Prerequisite:
General idea of microcontrollers like Arduino.
General idea how a NodeMCU works.
In-lab:
AIM:To send a message through webpage with ESP as server
APPARATUS:
ESP32 board
PAJ7620
Arduino IDE
Breadboard
Connecting wires
USB Cable
PRE-LAB WORK:
ESP32:
ESP32 is a single 2.4 GHz Wi-Fi-and-Bluetooth combo chip designed with the TSMC
ultra-low-power 40 nm technology. It is designed to achieve the best power and RF performance,
showing robustness, versatility and reliability in a wide variety of applications and power scenarios.
The ESP32 series of chips includes ESP32-D0WDQ6, ESP32-D0WD, ESP32-D2WD, and ESP32-
S0WD. For details on part numbers and ordering information.
ESP32 is designed for mobile, wearable electronics, and Internet-of-Things (IoT) applications.
It features all the state-of-the-art characteristics of low-power chips, including fine-grained clock
gating, multiple power modes, and dynamic power scaling. For instance, in a low-power IoT sensor
hub application scenario, ESP32 is woken up periodically and only when a specified condition is
detected. Low-duty cycle is used to minimize the amount of energy that the chip expends. The
output of the power amplifier is also adjustable, thus contributing to an optimal trade-off between
communication range, data rate and power consumption.
ESP32 is a highly-integrated solution for Wi-Fi-and-Bluetooth IoT applications, with
around 20 external components. ESP32 integrates an antenna switch, RF balun, power amplifier,
low-noise receive amplifier, filters, and power management modules. As such, the entire solution
occupies minimal Printed Circuit Board (PCB) area. ESP32 uses CMOS for single-chip fully-
integrated radio and baseband, while also integrating advanced calibration circuitries that allow the
solution to remove external circuit imperfections or adjust to changes in external conditions. As
such, the mass production of ESP32 solutions does not require expensive and specialized Wi-Fi
testing equipment.
1. Wi-Fi Key Features:
• 802.11 b/g/n • 802.11 n (2.4 GHz), up to 150 Mbps • WMM • TX/RX A-MPDU, RX A-MSDU •
Immediate Block ACK • Defragmentation • Automatic Beacon monitoring (hardware TSF) • 4 ×
virtual Wi-Fi interfaces • Simultaneous support for Infrastructure Station, SoftAP, and
Promiscuous modes
Note that when ESP32 is in Station mode, performing a scan, the SoftAP channel will be changed. •
Antenna diversity
Because the ESP32 is the heart of the module, it should be possible to program your ESP32-DOIT
board with any environment supported by the ESP32. As usual, the most practical environment is
the Arduino (another offer that has a lot of support is MicroPython). One of the things that makes
the board so easy to use is that it already has a micro-USB port. Besides, the board includes built-in
buttons and LEDs, which is very useful for getting started without the need to connect to external
hardware. Thus, to program it, you just need a USB cable, and you don’t need to solder anything to
get started and create your first program. Yes, you can start playing with the board without needing
to solder anything, as long as you don’t need to use the GPIOs or other peripherals. There are plenty
of things to try, such as the Wi-Fi/Bluetooth functionalities or the different programming
environments, just to name a few. If you are running Arduino on Windows, you can read the below
instructions (if you’ve never connected an FTDI device to your computer before, you may need to
install drivers for the USB-to-Serial converter)
PROCEDURE:
. Before run and compile the program we have the ESP32 IN ARDUINO IDE
3. Open the Boards Manager. Go to Tools > Board > Boards Manager…
4. Search for ESP32 and press install button for the “ESP32 by Espressif Systems“:
5. That’s it. It should be installed after a few seconds.
2. Select the Port (if you don’t see the COM Port in your Arduino IDE, you need to install
the CP210x USB to UART Bridge VCP Drivers):
3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan
. write the code on ARUDINO IDE and compile it
. and dump the code
. then send a message to server
Code:
#include"esp_http_client.h"
#include<WiFi.h>
#include"Arduino.h"
constchar*ssid="NSA";
constchar*password="Orange";
boolinternet_connected=false;
voidsetup()
{
Serial.begin(115200);
boolinit_wifi()
{
intconnAttempts=0;
Serial.println("\r\nConnecting to: "+String(ssid));
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED){
delay(500);
Serial.print(".");
if(connAttempts>10)returnfalse;
connAttempts++;
}
returntrue;
}
esp_err_t_http_event_handler(esp_http_client_event_t*evt)
{
switch(evt->event_id){
caseHTTP_EVENT_ERROR:
Serial.println("HTTP_EVENT_ERROR");
break;
caseHTTP_EVENT_ON_CONNECTED:
Serial.println("HTTP_EVENT_ON_CONNECTED");
break;
caseHTTP_EVENT_HEADER_SENT:
Serial.println("HTTP_EVENT_HEADER_SENT");
break;
caseHTTP_EVENT_ON_HEADER:
Serial.println();
Serial.printf("HTTP_EVENT_ON_HEADER, key=%s, value=%s",evt->header_key,evt-
>header_value);
break;
caseHTTP_EVENT_ON_DATA:
Serial.println();
Serial.printf("HTTP_EVENT_ON_DATA, len=%d",evt->data_len);
if(!esp_http_client_is_chunked_response(evt->client)){
// Write out data
// printf("%.*s", evt->data_len, (char*)evt->data);
}
break;
caseHTTP_EVENT_ON_FINISH:
Serial.println("");
Serial.println("HTTP_EVENT_ON_FINISH");
break;
caseHTTP_EVENT_DISCONNECTED:
Serial.println("HTTP_EVENT_DISCONNECTED");
break;
}
returnESP_OK;
}
staticesp_err_tpost_something()
{
esp_err_tres=ESP_OK;
esp_http_client_handle_thttp_client;
esp_http_client_config_tconfig_client={0};
config_client.url=post_url;
config_client.event_handler=_http_event_handler;
config_client.method=HTTP_METHOD_POST;
http_client=esp_http_client_init(&config_client);
esp_http_client_set_post_field(client,post_data,strlen(post_data));
esp_err_terr=esp_http_client_perform(http_client);
if(err==ESP_OK){
Serial.print("esp_http_client_get_status_code: ");
Serial.println(esp_http_client_get_status_code(http_client));
}
esp_http_client_cleanup(http_client);
}
voidloop()
{
if(conditionmet){
post_something();
}
}
On the server side assuming you are using PHP you use this code to name and save files:
1 $received = file_get_contents('php://input');
2 $fileToWrite = "upload - ".time().".jpg";
3 file_put_contents($fileToWrite, $received);
This code below will send a received file to your email address. You need to update the email
address in lines 6 and 27. If you are not sending a JPG you need to change line 20 to reflect the
content type.
$received = file_get_contents('php://input');
$timeNow = date("F j, Y, g:i a");
$subject = "Email Subject - ".time();
$bound_text = "----*%$!$%*";
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
VIVA:
1. What is a server?
2. What is the library file is used in ARDUINO IDE for ESP32 and how to install it?
3. Why we must install new libraries in ARDUINO IDE?
4. How the ESP32 works?
5. How many pins in ESP32 and how many PWM pins and how many analogue pins?
LAB SESSION 07 : SERVO MOTOR
CONTROL WITH WEBPAGE
Prerequisite:
General idea of microcontrollers like Arduino.
General idea how a NodeMCU works.
In-Lab:
3 UART interfaces
3 SPI interfaces
2 I2C interfaces
2 I2S interfaces
SERVO MOTOR:
You can position the servo’s shaft in various angles from 0 to 180º. Servos are controlled using
a pulse width modulation (PWM) signal. This means that the PWM signal sent to the motor
will determine the shaft’s
ft’s position.Servo motors have three wires: power, ground, and signal.
The power is usually red, the GND is brown, and the signal wire is usually orange
GND -> ESP32 GND pin;
Power -> ESP32 VIN pin;
Signal -> GPIO 13 (or any PWM pin).
CIRCUIT DIAGRAM :
:
Fig:circuit diagram of servo motor interfacing with ESP32
CODE :
#include<WiFi.h>
#include<Servo.h>
void setup()
{
Serial.begin(115200);//define serial commuination with baud rate of 115200
ObjServo.attach(ServoGPIO);// it will attach the ObjServo to ServoGPIO pin which is 13
Serial.print("Making connection to ");// it will display message on serial monitor
Serial.println(ssid);
WiFi.begin(ssid, password);
while(WiFi.status()!= WL_CONNECTED){
delay(500);
Serial.print(".");
}
// These lines prints the IP address value on serial monitor
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();// It will start the servo motor with given position value.
}
void loop(){
WiFiClient client =server.available();// Listen for incoming clients
if(client)
{// If a new client connects,
// Web Page
client.println("</head><body><h1>ESP32 with Servo</h1>");
client.println("<p>Position: <span id=\"servoPos\"></span></p>");
client.println("<input type=\"range\" min=\"0\" max=\"180\" class=\"slider\" id=\"servoSlider\"
onchange=\"servo(this.value)\" value=\""+valueString+"\"/>");
client.println("</body></html>");
header ="";
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
WEBPAGE CODE :
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<style>
body {
text-align: center;
font-family: "Trebuchet MS", Arial;
margin-left:auto;
margin-right:auto;
}
.slider {
width: 300px;
}
</style>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<h1>ESP32 with Servo</h1>
<p>Position: <span id="servoPos"></span></p>
<input type="range" min="0" max="180" class="slider" id="servoSlider"
onchange="servo(this.value)"/>
<script>
var slider = document.getElementById("servoSlider");
varservoP = document.getElementById("servoPos");
servoP.innerHTML = slider.value;
slider.oninput = function() {
slider.value = this.value;
servoP.innerHTML = this.value;
}
$.ajaxSetup({timeout:1000});
function servo(pos) {
$.get("/?value=" + pos + "&");
{Connection: close};
}
</script>
</body>
</html>
PROCEDURE :
Download the ESP32 libraries for ARDUINO IDE SOFTWARE, after add
the library connect the board
Write the code in ARDUINO IDE then compile the program and dump in to
the ESP32 board
Make the connection as per circuit diagram
Signal wire connect to PWM pin,Vcc connect to vin and GND connect to
GND
Now go to online HTML compiler and compile the code given above then
created a wedpage
Webpage have a slider which is from 0 to 180 degrees by using the slider we
can control servo motor angle
Observe the shaft of servo motor
PRECAUTIONS :
Download library before uploading code and as well as check board and
ports in tools
Make connections after dumped the code in ESP32
Connect the siginal wire to only PWM pins
POST LAB :
Prerequis
ite:
General idea of microcontrollers like Arduino.
General idea how a DHT11 Sensor works.
In-Lab:
OBJECTIVE:To monitor Temperature and Humidity using esp32 in cloud platform.
PRE-LAB WORK:
ESP32 is in the series of low power and low cost on chip microcontroller. It
comes up with already integrated dual mode Bluetooth and Wi-Fi. ESP32 comes up with a USB port
so we can say that it is a plug and play device i.e. just plug in cable and your device is turned on and
you are able to program it just like Arduino development boards.
Features:
Built in Wi-Fi module of standard 802.11 and Wi-Fi module operate in range of 2.4 GHz – 2.5
GHz.
Three modes of operation: 1. Access point. 2. Client. 3. Access point + station.
Dual core microprocessor of 32 – bit.
Operating voltage is 3.3 V and Clock frequency from 80 MHz and goes up to 240 MHz.
SRAM memory is of 512 KB and ROM memory is 448 KB.
External flash memory is supported and is up to 32 Mb i.e. 4MB.
It has 36 general purpose input / output pins.
General purpose input / output pins comes up with PWM / I2C and SPI functionality.
Bluetooth version 4.2 is available and Bluetooth low energy (BLE) version and its having 2 to
3.6 V operating voltage.
Pin Diagram:
Pin Description:
The ESP32 chip comes with 48 pins with multiple functions. 18 Analog-to-
Digital Converter (ADC) channels, 3 SPI interfaces, 3 UART interfaces,2-I2C interfaces, 16 PWM
output channels, 2 Digital-to-Analog Converters (DAC), 2 I2S interfaces, 10 Capacitive sensing
GPIOs.
After clicking on “New Channel”, enter the Name and Description of the data you want to upload on this
channel. For example I am sending DHT11 sensor data (temperature and humidity), so I named it as
“DHT11”.
Enter the name of your data ‘Temperature’ in Field1 and ‘Humidity’ in Field2. If you want to use more than
one Field you can check the box next to Field option and enter the name and description of your data.
After this click on save channel button to save your details.
POST-LAB REQUIREMENTS:
Observe the OUTPUT and note down the readings carefully.
Apply this concepts to make our projects or Applications.
Submit practical report in next lab for correction.
CODE:
#include <DHT.h>
#include <ESP8266WiFi.h>
String apiKey = "Your API KEY"; // Enter your Write API key here
WiFiClient client;
void setup()
Serial.begin(115200);
delay(10);
dht.begin();
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
delay(550);
Serial.print(".");
Serial.println("");
Serial.println("WiFi connected");
}
void loop()
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
return;
if (client.connect(server,80))
postStr +="&field1=";
postStr += String(t);
postStr +="&field2=";
postStr += String(h);
postStr += "\r\n\r\n";
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(h);
client.stop();
Serial.println("Waiting...");
delay(10000);
CIRCUIT DIAGRAM:
PROCEDURE:
6. Make the connections as per the circuit diagram.
7. Check the ground connection precisely before switching on the power supply.
8. Connect Micro USB Cable to PC .
9. Write the Code in Python or C/C++ accordingly .
10. Run the code through Arduino IDE or uPycraft IDE and Observe the output.
PRECAUTIONS:
1. Check the sensor is working properly.
2. Check the connections are properly connected.
3. See that there are no errors in the code.
4. Check whether Ground and VCC connections are connected properly.
Prerequisite:
General idea of microcontrollers like Arduino.
General idea about Wifi cloud and analysis.
In-Lab:
OBJECTIVE:
To build a WiFI weather station using ESP8266 (NodeMCU) &Blynk app
COMPONENTS REQUIRED:
NodeMCU
DHT11 sensor
Breadboard
Connecting wires
MicroUSB cable
SOFTWARE REQUIRED:
Arduino IDE, Blynk app
PRE-LAB WORK:
NodeMCU
NodeMCU is an open source IoT platform.It includes firmware which runs on
the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12
module.The ESP8266 NodeMcuisa complex device, which combines some features of the ordinary
Arduino board with the possibility of
connecting to the internet.
NodeMCU is a Tensilica 32-bit RISC CPU Xtensa LX106 Microcontroller. Its Operating
Voltage is 3.3V & Input Voltage is 7-12V. Its having 16 Digital I/O Pins & 1 Analog
Input Pin (ADC). Its having Flash Memory of 4MB & SRAM 64KB. NodeMCU having clock
speed of 80 Mhz.
The interface of the module is mainly divided into two parts including both Firmware and
Hardware where former runs on the ESP8266 Wi-Fi SoC and later is based on the ESP-12 module.
PIN DIAGRAM:
PIN DISCRIPTION:
1) Power Pin: There are four power pins viz. one VIN pin & three 3.3V pins. The VIN
pin can be used to directly supply the ESP8266 and its peripherals, if you have a regulated
5V voltage source. The 3.3V pins are the output of an on-board voltage regulator.These pins
can be used to supply power to external components.
2) GND : GND is a ground pin of ESP8266 NodeMCU development board.
3) I2C Pins: I2C Pins are used to hook up all sorts of I2C sensors and peripherals in your
project. Both I2C Master and I2C Slave are supported. I2C interface functionality can be
realized programmatically, and the clock frequency is 100 kHz at a maximum. It should be
noted that I2C clock frequency should be higher than the slowest clock frequency of the
slave device.
4) GPIO Pins: ESP8266 NodeMCU has 17 GPIO pins which can be assigned to various
functions such as I2C, I2S, UART, PWM, IR Remote Control, LED Light and Button
programmatically. Each digital enabled GPIO can be configured to internal pull-up or pull-
down, or set to high impedance. When configured as an input, it can also be set to edge-
trigger or level-trigger to generate CPU interrupts.
5) ADC Channel: The NodeMCU is embedded with a 10-bit precision SAR ADC. The two
functions can be implemented using ADC viz. Testing power supply voltage of VDD3P3
pin and testing input voltage of TOUT pin. However, they cannot be implemented at the
same time.
6) UART Pins: ESP8266 NodeMCU has 2 UART interfaces, i.e. UART0 and UART1, which
provide asynchronous communication (RS232 and RS485), and can communicate at up to
4.5 Mbps. UART0 (TXD0, RXD0, RST0 & CTS0 pins) can be used for
communication. It supports fluid control. However, UART1 (TXD1 pin) features only data
transmit signal so, it is usually used for printing log.
7) SPI Pins: ESP8266 features two SPIs (SPI and HSPI) in slave and master modes. These
SPIs also support the following general-purpose SPI features:
a) 4 timing modes of the SPI format transfer.
b) Up to 80 MHz and the divided clocks of 80 MHz.
c) Up to 64-Byte FIFO.
8) SDIO Pins: ESP8266 features Secure Digital Input/Output Interface (SDIO) which is used
to directly interface SD cards. 4-bit 25 MHz SDIO v1.1 and 4-bit 50 MHz SDIO v2.0 are
supported.
9) PWM Pins: The board has 4 channels of Pulse Width Modulation (PWM). The PWM
output can be implemented programmatically and used for driving digital motors and LEDs.
PWM frequency range is adjustable from 1000 μs to 10000 μs, i.e., between 100 Hz and 1
kHz.
10) Control Pins: Control Pins are used to control ESP8266. These pins include Chip Enable
pin (EN), Reset pin (RST) and WAKE pin. EN pin – The ESP8266 chip is enabled when
EN pin is pulled HIGH. When pulled LOW the chip works at minimum power. RST pin –
RST pin is used to reset the ESP8266 chip. WAKE pin – Wake pin is used to wake the chip
from deep-sleep.
DHT11:
DHT11 digital temperature and humidity sensor is a calibrated digital signal output of the
temperature and humidity combined sensor. It uses a dedicated digital modules capture technology
and the temperature and humidity sensor technology to ensure that products with high reliability
and excellent long-term stability. Sensor includes a resistive element and a sense of wet NTC
temperature measurement devices, and with a high-performance 8-bit microcontroller connected .
The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a
capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital
signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful
timing to grab data.
The DHT11 calculates relative humidity by measuring the electrical resistance between two
electrodes. The humidity sensing component of the DHT11 is a moisture holding substrate with the
electrodes applied to the surface.
A humidity sensor (or hygrometer) senses, measures and reports both moisture and
air temperature. ... Relative humidity becomes an important factor, when looking for comfort. A
sample humidity sensor. Humidity sensors work by detecting changes that alter electrical currents
or temperature in the air
DHT11 uses only one wire for communication. The voltage levels with certain time value
defines the logic one or logic zero on this pin.
The communication process is divided in three steps, first is to send request to DHT11
sensor then sensor will send response pulse and then it starts sending data of total 40 bits to
the microcontroller.
Communication process
Data format:
The 8bit humidity integer data + 8bit the Humidity decimal data +8 bit temperature
temperatur integer
data + 8bit fractional temperature data +8 bit parity bit.
Parity bit data definition
“8bit humidity integer data + 8bit humidity decimal data +8 bit temperature integer data +
8bit temperature fractional data” 8bit checksum is equal to the res
results
ults of the last eight.
Example 1:
BLYNK :
Blynk was designed for the Internet of Things. It can control hardware remotely, it can
display sensor data, it can store data, vizualize it and do many other cool things.
There are three major components in the platform:
Blynk App - allows to you create amazin
amazing
g interfaces for your projects using various widgets we
provide.
Blynk Server - responsible for all the communications between the smartphone and hardware.
You can use our Blynk Cloud or run your private Blynk server locally. It’s open-source,
open could
easily handle thousands of devices and can even be launched on a Raspberry Pi.
Blynk Libraries - for all the popular hardware platforms - enable communication with the
server and process all the incoming and out coming commands.
Now imagine every time you press a Button in the Blynk app, the message travels to theBlynk
Cloud, where it magically finds its way to your hardware. It works the same in the opposite
direction and everything happens in a blynk of an eye.
Getting Started With TheBlynk App
1) Create a Blynk Account
2) Create a new project
3) Choose your hardware
4) Auth Token
5) Add a widget
6) Run the project
CIRCUIT DIAGRAM :
PROCEDURE:
CODE:
* theTechnowright
* Complete Project Details www.youtube.com/thetechnowright
*/
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
display.flipScreenVertically();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
dht.begin(); // initialize dht
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)){
display.clear(); // clearing the display
display.drawString(5,0, "DHT Failed!");
return;
}
display.clear();
display.drawString(30, 0, "Weather");
display.drawString(0, 20, "Humidity: " + String(h) + "%\t");
display.drawString(0, 40, "Temp: " + String(t) + "°C");
//Uncomment to get temperature in farenheit
//display.drawString(0, 40, "Temp: " + String(f) + "°F");
}
void loop(){
Blynk.run(); // Running the blynk code
displayWeather(); //Calling back the displayWeather function
display.display();
timer.run();
}
voidsendSensor()
{
float h = dht.readHumidity(); //Read the humidity
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
RESULT:
We have successfully designed the weather station using NodeMCU and the Blynk app
LAB SESSION 10: Temperature and Humidity Monitoring with
Raspberry Pi
Prerequisite:
In-Lab:
OBJECTIVE:To display the temperature and humidity in pc screen
COMPONENTS REQUIRED:
connecting wires
micro USB cable
pc
DTH11 Sensor
Rasspberry pi.
Pre-Lab Work:
Raspberry Pi 3 Model B was released in February 2016 with a 1.2 GHz 64-bit quad core processor,
on-board 802.11n Wi-Fi, Bluetooth and USB boot capabilities. On Pi Day 2018 the Raspberry Pi 3
Model B+ was launched with a faster 1.4 GHz processor and a three-times faster gigabit
Ethernet (throughput limited to ca. 300 Mbit/s by the internal USB 2.0 connection) or 2.4 /
5 GHz dual-band 802.11ac Wi-Fi (100 Mbit/s). Other features are Power over Ethernet (PoE), USB
boot and network boot (an SD card is no longer required).
An SD card inserted into the slot on the board acts as the hard drive for the Raspberry Pi. It is
powered by USB and the video output can be hooked up to a traditional RCA TV set, a more
modern monitor, or even a TV using the HDMI port.
Raspbian comes preloaded with Python, the official programming language of the Raspberry Pi and
IDLE 3, a Python Integrated Development Environment.
Pin description:
The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive
humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the
data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab
data
The DHT11 calculates relative humidity by measuring the electrical resistance between two
electrodes. The humidity sensing component of the DHT11 is a moisture holding substrate with the
electrodes applied to the surface.
A humidity sensor (or hygrometer) senses, measures and reports both moisture and air temperature.
... Relative humidity becomes an important factor, when looking for comfort. A sample humidity
sensor. Humidity sensors work by detecting changes that alter electrical currents or temperature in
the air
Code:
import RPi.GPIO as GPIO
import dht11
import time
# initialize GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
#GPIO.cleanup()
while True:
result = instance.read()
if result.is_valid():
print("Temp: %d C" % result.temperature +' '+"Humid: %d %%" % result.humidity)
time.sleep(1)
Circuit Diagram:
Procedure:
Make the connections as per the circuit diagram.
Check the ground connection precisely before switching on the power supply.
Connect Micro USB Cable to PC .
Write the Code in Python or C/C++ accordingly .
Run the code through Arduino IDE or uPycraft IDE and Observe the output.
Post-Lab Requirements:
Observe the OUTPUT and note down the readings carefully.
Apply the required voltage for the board.
LAB SESSION 11: TEMPERATUREAND HUMIDITY
MONITORINGWITH RASPBERRY Pi AND SERVO MOTOR
Prerequisite:
General idea of microcontrollers like Arduino.
General idea about motor.
In-Lab:
OBJECTIVE:
To open a window by using DTH11 sensor at certain temperature by using servo motor.
COMPONENTS REQUIRED:
1) Raspberry Pi Model B
2) DHT11 sensor
3)micro USB cable
4)connecting wires
5)servo motor
6) pc
PRE-LAB WORK:
Raspberry Pi 3 Model B was released in February 2016 with a 1.2 GHz 64-bit quad core processor,
on-board 802.11n Wi-Fi, Bluetooth and USB boot capabilities. On Pi Day 2018 the Raspberry Pi 3
Model B+ was launched with a faster 1.4 GHz processor and a three-times faster gigabit
Ethernet (throughput limited to ca. 300 Mbit/s by the internal USB 2.0 connection) or 2.4 /
5 GHz dual-band 802.11ac Wi-Fi (100 Mbit/s). Other features are Power over Ethernet (PoE), USB
boot and network boot (an SD card is no longer required).
An SD card inserted into the slot on the board acts as the hard drive for the Raspberry Pi. It is
powered by USB and the video output can be hooked up to a traditional RCA TV set, a more
modern monitor, or even a TV using the HDMI port.
Raspbian comes preloaded with Python, the official programming language of the Raspberry Pi and
IDLE 3, a Python Integrated Development Environment.
Pin description:
The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive
humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the
data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab
data
The DHT11 calculates relative humidity by measuring the electrical resistance between two
electrodes. The humidity sensing component of the DHT11 is a moisture holding substrate with the
electrodes applied to the surface.
A humidity sensor (or hygrometer) senses, measures and reports both moisture and
air temperature. ... Relative humidity becomes an important factor, when looking for comfort. A
sample humidity sensor. Humidity sensors work by detecting changes that alter electrical
currents or temperature in the air
A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or
linear position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for
position feedback. ... Servomotors are used in applications such as robotics, CNC machinery or
automated manufacturing.
About:
To open a window, I use a servo with a longer wooden staff attached to the axis. In the initial state,
the angle should be 0°. If you are unsure, you should set the servo once per script to 0° and then
attach.
The temperature value is used for control purposes. For this, we still have to connect the DHT11
temperature sensor to GPIO 27, while the servo motor is connected to GPIO 22. Since the engine
probably needs more than 3.3V (see the data sheet, if you are unsure), we connect it to the 5V
voltage.
I have the DHT sensor simply attached to the water resistant housing (next point). To change the
temperature at which the hatch is to be opened, you can change the initial settings.
CODE:
defcheckWindow():
# read remperature
humidity, temperature = Adafruit_DHT.read_retry(SETTINGS["DHT_SENSOR"],
SETTINGS["DHT_GPIO"])
GPIO.setup(SETTINGS["SERVO_GPIO"],
(SETTINGS["SERVO_GPIO"], GPIO.OUT)
pwm = GPIO.PWM(SETTINGS["SERVO_GPIO"], 50)
CIRCUIT DIAGRAM:
PROCEDURE:
Make the connections as per the circuit diagram.
Check the ground connection precisely before switching on the power supply.
Connect Micro USB Cable to PC .
Motor is to be in inverted position.
Write the Code in Python or C/C++ accordingly .
Run the code through Arduino IDE or uPycraft IDE and Observe the output.
Prerequis
ite:
General idea of microcontrollers like Arduino.
General idea how a gyroscope works.
In-Lab:
OBJECTIVE:To Control a 3d model with reference to MPU6050 Orientation
SOFTWARE REQUIREMENTS:1)uPycraft.
Or
2) Arduino IDE.
3)Processing 3
PRE-LAB WORK:
The Arduino Integrated Development Environment is a cross-platform application that is written in
functions from C and C++. It is used to write and upload programs to Arduino compatible boards. The
MPU-6050 devices combine a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die, together
with an onboard Digital Motion Processor™ (DMP™), which processes complex 6-axis Motion Fusion
algorithms. The device can access external magnetometers or other sensors through an auxiliary master I²C
bus, allowing the devices to gather a full set of sensor data without intervention from the system processor.
Features:
Microcontroller: ATmega328
Operating Voltage: 5V
Input Voltage (recommended): 7-12V
Input Voltage (limits): 6-20V
Digital I/O Pins: 14 (of which 6 provide PWM output)
Analog Input Pins: 6
DC Current per I/O Pin: 40 mA
DC Current for 3.3V Pin: 50 mA
Flash Memory: 32 KB of which 0.5 KB used by bootloader
b
SRAM: 2 KB (ATmega328)
EEPROM: 1 KB (ATmega328)
Clock Speed: 16 MHz
Pin Diagram:
Pin Description:
ARDUINO:-
Arduino Uno comes with USB interface, 6 analog input pins, 14 I/O digital ports that are used to connect
with external electronic circuits.
Out of 14 I/O ports, 6 pins can be used for PWM output.
MPU6050:-
Vcc: -Provides power for the module, can be +3V to +5V. Typically +5V is used
Ground: -Connected to Ground of system
Serial Clock (SCL):-Used for providing clock pulse for I2C Communication
Serial Data (SDA):-Used for transferring Data through I2C communication
Auxiliary Serial Data (XDA):-Can be used to interface other I2C modules with MPU6050. It is
optional
Auxiliary Serial Clock (XCL):-Can be used to interface other I2C modules with MPU6050. It is
optional
AD0:-If more than one MPU6050 is used a single MCU, then this pin can be used to vary the address
Interrupt (INT):-Interrupt pin to indicate that data is available for MCU to read.
POST-LAB REQUIREMENTS:
Observe the OUTPUT and note down the readings carefully.
Apply this concept to make projects or Applications.
Submit practical report in next lab for correction.
CODE:
CIRCUIT DIAGRAM:
PROCEDURE:
PRECAUTIONS:
1.Check the sensor is working properly.
2.Check the connections are properly connected.
3.See that there are no errors in the code.
4. Check whether Ground and VCC connections are connected properly.