0% found this document useful (0 votes)
63 views10 pages

Chapter 3

The document describes the construction of an IoT-based digital thermometer using a NodeMCU microcontroller and an LM35 temperature sensor. It includes block diagrams of the system components and their connections. The LM35 sensor measures temperature and outputs a voltage proportional to the temperature in Celsius. The NodeMCU reads the LM35 output and connects to WiFi to transmit the temperature readings to a user interface via a web browser. The document provides code to initialize the system components, read the LM35 output, convert it to Celsius and Fahrenheit temperatures, and transmit the readings over WiFi through an HTTP server to a web browser.

Uploaded by

Adekunle Adewole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views10 pages

Chapter 3

The document describes the construction of an IoT-based digital thermometer using a NodeMCU microcontroller and an LM35 temperature sensor. It includes block diagrams of the system components and their connections. The LM35 sensor measures temperature and outputs a voltage proportional to the temperature in Celsius. The NodeMCU reads the LM35 output and connects to WiFi to transmit the temperature readings to a user interface via a web browser. The document provides code to initialize the system components, read the LM35 output, convert it to Celsius and Fahrenheit temperatures, and transmit the readings over WiFi through an HTTP server to a web browser.

Uploaded by

Adekunle Adewole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter Three

3.1 Construction of IoT based Digital Thermometer


The block diagram of an IoT based digital thermometer using NodeMCU and LM35 temperature
sensor consists of the following blocks, LM35 Temperature Sensor, NodeMCU microcontroller,
Access Point, User Interface and 5v power supply. The explanation of each of the block for
constructing an IoT-based digital thermometer using explained in subsequent sections. The block
diagram of the IoT based digital thermometer is shown in figure 1.

Figure 1 Block Diagram of IoT based digital thermometer

3.1.1 LM35 Temperature Sensor


The LM35 temperature sensor is a precision analog sensor that measures temperature in Celsius. It
converts the ambient temperature into an analog voltage proportional to the temperature. Figure 2
shows LM 35 temperature sensor.

Figure 2 LM35 Tempearature Sensor

The LM35 is a widely used analog temperature sensor known for its accuracy and linear output. It
can measure temperatures ranging from -55°C to +150°C with a typical accuracy of ±0.5°C. The
sensor has a linear transfer function of 10 mV/°C, meaning the output voltage changes by 10
millivolts for every degree Celsius change in temperature. It requires minimal external components,
operates on a single supply voltage, and consumes low power. The LM35 is commonly employed in
applications such as environmental monitoring, HVAC systems, industrial temperature control,
weather stations, medical devices, and IoT-based temperature sensing systems. Overall, it is a
reliable and easy-to-use temperature sensor with various practical applications.
3.1.2. NodeMCU Microcontroller
The NodeMCU is an open-source development board based on the ESP8266 Wi-Fi module. It
combines a microcontroller with Wi-Fi capabilities, making it suitable for IoT projects. It has GPIO
pins for interfacing with electronic components, can be programmed using IDEs like Arduino. The
board offers USB connectivity and is known for its affordability, ease of use, and strong community
support. The pin out diagram of nodeMcu is shown in figure 3

Figure 3. NodeMcu Microcontroller Pin out


3.1.3 Access Point
Access Point is the Wi-Fi link for communicating between the nodemcu with the mobile device. A
Wi-Fi hotspot, also known as a wireless hotspot, is a location or device that provides internet access
to other devices using Wi-Fi technology. It allows multiple devices, such as smartphones, laptops,
or tablets, to connect to the internet wirelessly within a certain range. To set up a Wi-Fi hotspot,
there need a device that supports Wi-Fi connectivity and acts as a hotspot, such as a smartphone, a
portable hotspot device, or a computer with hotspot capabilities.

3.1.4 User Interface


A user interface (UI) refers to the visual and interactive elements that allow users to interact with a
software application, website, or device. It encompasses all the components, such as buttons,
menus, forms, and screens, that enable users to provide input, receive feedback, and navigate
through the system. The primary goal of a user interface is to provide a user-friendly and intuitive
experience, making it easy for users to interact with the system and achieve their desired tasks
efficiently. A well-designed user interface considers usability, accessibility, and aesthetics to create a
seamless and engaging user experience. In this design the web browser is needed to display the
temperature meased in real time.

3.1.5 Power Supply


A 5V power supply for an IoT digital thermometer refers to the power source that provides a stable
5V DC (Direct Current) voltage to power the various components of the thermometer system, such
as the microcontroller (e.g., NodeMCU), sensors, and any other circuitry involved. Here are some
key points to understand about a 5V power supply for an IoT digital thermometer.

I. Voltage Requirement: The components used in the thermometer system, including the
microcontroller and sensors, typically operate at a voltage level of 5V. Therefore, it is crucial to
provide a power supply that can deliver a steady 5V DC output.

III. Power Supply Options: There are various options for obtaining a 5V power supply for the IoT
digital thermometer, depending on the specific requirements and constraints of the project

III. Battery Power: require a portable or battery-powered thermometer, you can use a battery pack
or rechargeable battery
In our case we used a ready made power supply that can deliveree upto 1A of current at 5v.

Figure 4. A 5v Dc Power
supply

3.2 The Circuit Connection


Figure 5. Circuit diagram of Digital Thermometer

The circuit for an IoT digital thermometer using NodeMCU, LM35 sensor, and a 5V power supply
is shown in figure 5. Here is a step-by-step guide on how we construct the circuit.
3.2.1 Components Required
I. NodeMCU (ESP8266 development board)
II. LM35 temperature sensor
III. Verooard
4. Jumper wires
5. 5V power supply (USB charger or power bank)
6. Soldering Iron

3.2.2 Circuit Construction Steps

I. We connect the NodeMCU to the breadboard. Ensuring that the NodeMCU is properly positioned
across the middle gap of the veroboard, with half the pins on each side.
II. Then connect the 5V power supply to the NodeMCU. Use a USB cable to connect the 5V power
supply (e.g., USB charger) to the NodeMCU. Connect the USB cable's positive (red) wire to the
"Vin" pin of the NodeMCU and the negative (black) wire to the "GND" pin of the NodeMCU.
III. Also, we connect the LM35 sensor to the NodeMCU. The LM35 sensor has three pins: VCC,
GND, and OUT.
- Connected the LM35's VCC pin to the 3.3V pin of the NodeMCU.
- Connected the LM35's GND pin to the GND pin of the NodeMCU.
- Connected the LM35's OUT pin to any of the analog input pins (e.g., A0) of the NodeMCU.
IV. Connect a 10kΩ resistor between the LM35's OUT pin and the 3.3V pin of the NodeMCU. This
resistor is used as a pull-up resistor to stabilize the voltage output from the LM35.
IV. Finally, connect the NodeMCU to your computer using a USB cable to power it up.
We successfully constructed the circuit for the IoT digital thermometer using NodeMCU and the
LM35 temperature sensor. The NodeMCU can now read the temperature data from the LM35
sensor and transmit it to an IoT platform or any internet browser in order perform any other desired
actions based on the temperature readings.

3.3 Software Implementation


There is need to write code that reads temperature data from a sensor, communicates with the IoT
platform or browser, and performs any necessary data processing or transmission. Here is how you
can approach the software implementation in Arduino IDE.

3.3.1 Algorithmn Implemented


Start

Initialize serial communication


Initialize A0 pin as input for LM35 sensor

Connect to Wi-Fi network


While Wi-Fi is not connected:
Wait for connection

Start server
Print local IP address

Loop:
Read analog value from A0 pin
Convert analog value to temperature in Celsius
Convert temperature to Fahrenheit

Print temperature values to serial monitor

Listen for client connection


If client is connected:
Send HTTP response headers
Send HTML page with temperature values
Delay for 1 second

End

3.3.2 Program Code


#include <ESP8266WiFi.h>

const char* ssid = "itel A60s";


const char* password = "27051977";
float temp_celsius = 0;

float temp_fahrenheit = 0;

WiFiServer server(80);

void setup() {

Serial.begin(115200);

pinMode(A0, INPUT);

Serial.println();

Serial.println();

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);

Serial.print(".");

Serial.println("");

Serial.println("WiFi is connected");

server.begin();

Serial.println("Server started");

Serial.println(WiFi.localIP());

void loop() {

temp_celsius = (analogRead(A0) * 330 *13) / 1024.0; // To convert analog values to Celsius We


have 3.3 V on our board and we know that output voltage of LM35 varies by 10 mV to every degree
Celsius rise/fall. So , (A0*3300/10)/1023 = celsius

temp_fahrenheit = temp_celsius * 1.8 + 32.0;

Serial.print(" Temperature = ");

Serial.print(temp_celsius);

Serial.print(" Celsius, ");

Serial.print(temp_fahrenheit);

Serial.println(" Fahrenheit");
WiFiClient client = server.available();

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println("Connection: close"); // the connection will be closed after completion of the


response

client.println("Refresh: 10"); // update the page after 10 sec

client.println();

client.println("<!DOCTYPE HTML>");

client.println("<html>");

client.print("<p style='text-align: center;'><span style='font-size: x-large;'><strong>Digital


Thermometer</strong></span></p>");

client.print("<p style='text-align: center;'><span style='color: #0000ff;'><strong style='font-size:


large;'>Temperature (*C)= ");

client.println(temp_celsius);

client.print("<p style='text-align: center;'><span style='color: #0000ff;'><strong style='font-size:


large;'>Temperature (F) = ");

client.println(temp_fahrenheit);

client.print("</p>");

client.println("</html>");
delay(1000);

3.3.2 Explanation of the code


The code is an Arduino sketch that implements a digital thermometer using an LM35 temperature
sensor and an ESP8266 Wi-Fi module. Here's a breakdown of the code:

1. Including the necessary libraries:


- The code begins by including the "ESP8266WiFi.h" library, which provides the necessary
functions for Wi-Fi communication using the ESP8266 module.

2. Defining variables and objects:


- The code defines variables for the Wi-Fi network credentials (`ssid` and `password`), as well as
variables to store the temperature in Celsius (`temp_celsius`) and Fahrenheit (`temp_fahrenheit`).
- An instance of the `WiFiServer` object named `server` is created to handle incoming client
connections.

3. Setting up the setup() function:


- The `setup()` function is called once when the Arduino board starts up.
- Serial communication is initialized with a baud rate of 115200.
- The analog pin A0 is set as an input pin using `pinMode()` to read the LM35 sensor's output.
- Wi-Fi connection is established using the provided network credentials. The code waits until a
connection is made by repeatedly checking `WiFi.status()`.
- Once connected, the server is started using `server.begin()`.
- The local IP address of the ESP8266 module is printed to the serial monitor.

4. Setting up the loop() function:


- The `loop()` function is the main loop of the code, executed repeatedly.
- The LM35 sensor's output voltage is converted to temperature in Celsius using the formula
`(analogRead(A0) * 330 * 13) / 1024.0`.
- The temperature in Celsius is then converted to Fahrenheit using the formula `temp_celsius * 1.8
+ 32.0`.
- The temperature values are printed to the serial monitor.
- The code listens for client connections using `server.available()`.
- Once a client is connected, an HTTP response is sent back with the temperature values in both
Celsius and Fahrenheit. The response includes HTML tags to format the data.
- The loop delays for 1 second before repeating.

The code continuously reads the LM35 sensor's output, calculates the temperature in both Celsius
and Fahrenheit, and provides the temperature values via a web server running on the ESP8266. This
allows you to access the temperature data by accessing the IP address of the ESP8266 module in a
web browser.

You might also like