Exp4 Skill Dev Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Experiment No.

4
Development of an IoT based Room Temperature Control System
1. Aim: To build and test an IoT based system to control room temperature

2. Components required:
• Arduino Uno board and USB cable for programming and power
• DHT-11 temperature and humidity sensor
• DC motor
• Single channel relay module
• 16 * 2 LCD display
• Breadboard
• Jumper wires
• PC for Arduino programming

3. Theory:
The Internet of Things (IoT) is a system where every day physical objects are connected to the Internet,
allowing them to collect, exchange, and process data. This technology allows for the collection and
sharing of data from a vast network of devices, creating opportunities for more efficient and automated
systems.
3.1 IoT Architecture:
The IoT architecture as shown in Fig.1. has following components (layers):
Sensors and actuators: This layer consists of physical devices that interact directly with the real world.
Sensors collect and transmit environmental data, such as temperature, humidity, pressure, acceleration,
sound etc. Examples of sensors include temperature gauges, motion detectors, and cameras. Actuators,
on the other hand, control and manipulate the physical environment based on the data received from
sensors. Stepper motors, DC motors, valves, relays are some examples of actuators.

Fig.1. IoT Architecture

Connectivity layer: This layer is responsible for the communication infrastructure that enables data
exchange between the sensor and actuator layer and the IoT cloud platform. Various communication
technologies can be used such as cellular networks (GSM), Wi-Fi, Bluetooth, ZigBee, 6LowPAN etc.
The choice of communication technology depends on the desired range and availability of power.
IoT cloud layer: In this layer, data collected from the sensors is transmitted for processing, storage, and
analysis. The IoT cloud platform serves as a centralized hub for managing and monitoring devices,
providing a comprehensive view of the entire IoT system. It can also host Artificial Intelligence/
Machine Learning algorithms to analyze data, identify patterns, predict outcomes, and optimize
operations. Some of the well-known clouds are Amazon Web Service (AWS), Microsoft Azure, Google
Cloud etc.

IoT analytics and data management layer: At this stage, sensor data undergoes intensive analysis to
extract valuable insights. Data management includes tasks such as filtering, organizing, and interpreting
data to generate reports and support informed decision-making. Business intelligence tools are used to
transform raw sensor data into actionable insights. Microsoft Power BI, Tableau, IBM Cognos
Analytics, Google Data Studio are few examples of the same.

User interface layer: This layer provides the communication channel for users (humans) to interact with
the IoT system. Users can monitor sensor data in real-time through dashboards or applications, control
actuators remotely, and receive alerts or notifications from the system. User interfaces can be web-
based applications, mobile applications, or physical control panels. Web applications are designed using
HTML, CSS, node.js, PHP etc while mobile applications are developed using iOS, Android studio,
Flutter, Figma etc.

3.2 Room Temperature Controller: System Description


In this system, a sensor senses the ambient temperature, converts it in digital format. Further processing
of this data happens in the microcontroller. The microcontroller and related peripheral components are
housed on the Arduino board.

Fig. 2. Room Temperature Controller System Design

The microcontroller compares the current temperature with the threshold temperature value. The
threshold value is set in the microcontroller via program. Arduino IDE is used to program the
microcontroller. The LCD display displays the current temperature.
If the ambient temperature goes beyond the threshold value the DC motor (fan) will start for cooling.
Once the temperature goes below the threshold, motor will stop.
3.2.1 Arduino
The Arduino is an IoT application development platform. It includes a microcontroller and related
circuitry plus microcontroller programming environment known as Integrated Development
Environment (IDE). There are several variations of Arduino like Uno, Nano, Mega, Lilypad etc.
Features of Arduino:

• Ardunio boards are inexpensive and simple to use.


• Arduino IDE can run on Windows, Macintosh and Linux operating systems.
• The Arduino software is published as an open-source tool, available for extension by
experienced programmers. The language can be expanded through C++ libraries.
• The plans of the Arduino boards are published under a Creative Commons license, so
experienced circuit designers can make their own version of the module, extending it and
improving it.
Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins
(of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection,
a power jack, an ICSP (In-circuit serial programming) header and a reset button. It contains everything
needed to support the microcontroller; simply connect it to a computer with a USB cable or power it
with an AC-to-DC adapter or battery to get started.
Arduino Uno Pin Diagram:

Fig.3. Arduino Uno Pin Diagram

Input and output


Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions.
In addition, some pins have specialized functions:

• Serial: Pins 0 (RX) and 1 (TX) are used to receive (RX) and transmit (TX) serial data.
These pins are connected to the corresponding TX/RX pins of the ATmega328.
• External interrupts: Pins 2 and 3. These pins can be configured to trigger an interrupt on a
low value, a rising or falling edge, or a change in value.
• PWM: 3, 5, 6, 9, 10, and 11 provide 8-bit PWM output with the analogWrite() function.
• SPI: The SPI (Serial Peripheral Interface) is another serial interface. The ATmega328 has
only one SPI module. Besides using it as a serial interface, it can also be used to program
the microcontroller using a standalone programmer. Pin 10 (SS), pin 11 (MOSI), pin 12
(MISO) and pin 13 (SCK) support SPI communication using the SPI library.
• LED: There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the
LED is on, when the pin is LOW, it’s off.
• The 6 analog inputs, labeled A0 through A5 provide 10 bits of resolution (i.e. 1024 different
values). By default they measure from ground to 5 volts, though is it possible to change the
upper end of their range using the AREF pin and the analogReference() function.
Additionally, some pins have specialized functionality as follows:
o TWI: The I2C or Two Wire Interface is an interface consisting of only two wires,
serial data, and a serial clock: SDA, SCL.
o AREF: Reference voltage for the analog inputs. Used with analogReference().
o Reset: Used to reset the microcontroller by pulling this pin low.

3.2.2 Sensor: DHT 11

Fig.4. DHT 11 Sensor

The DHT11 sensor is a digital temperature and humidity sensor widely employed in the initial stages
of Internet of Things (IoT) development due to its ease of use, affordability, and ability to measure two
critical environmental parameters temperature and humidity.
Pin Description:

• VCC: This pin is used to provide power to the sensor.


• DATA (Data Input/Output): The data pin is used for bidirectional communication between the
sensor and the microcontroller.
• GND (Ground): The ground pin is connected to the ground (0V) of the power supply

3.2.3 DC motor

Fig.5. DC motor

DC (Direct Current) motors are electromechanical devices that convert electrical energy into
mechanical motion through the interaction of magnetic fields. DC motors are low cost, minimum
maintenance and quick starting. They can be used in industrial as well as household applications.
To run the DC motor 5 V supply is needed which is given either through driver IC or transistor or
relay as higher current is required to drive the motor.

3.2.4 LCD display


The 16x2 LCDs can be found in many laboratory and industrial equipment. It can display up to 32
characters at a time. Each character segment is made up of 40 pixels that are arranged in a 5x8 matrix.
Alphanumeric characters and custom characters can be displayed by activating the corresponding
pixels.
Fig.6. 16*2 LCD Display Module

The display module as shown in Fig.6 has a 16-pin connector. The module can be used either in 4-bit
mode or in 8-bit mode. In 4-bit mode, 4 of the data pins are not used and in 8-bit mode, all the pins are
used. The pin functions are as follows:

• VSS: Ground pin.


• VDD: Power supply pin. To be connected to 5V
• Vo: Contrast adjustment. A potentiometer is connected to this pin. Rotating the potentiometer
knob forward and backwards will adjust the LCD contrast.
• RS: Selects command register when low, and data register when high
• R/W: Low to write to the register; High to read from the register
• E: Enable pin. Sends data to data pins when a high to low pulse is given.
• D0-D7: Data pins. LCD can be used in 4-bit or 8-bit mode.
• A: LED backlight to be connected to 5 Volts
• K: LED backlight to be connected to ground

3.2.5 Single channel relay module

Fig.7. Single Channel Relay Module Pins

A relay module is used when connecting a DC motor to an Arduino to allow the low-power
microcontroller to control a high-powered device like the motor. The relay provides isolation
between the Arduino board and the motor circuit. A single channel relay can be used to connect one
load to the Arduino board. Two-channel, eight-channel relays are also available.
A single-channel relay module has six pins divided into two groups. Input (V CC, GND and IN) and
output (COM, NO and NC) group. Input side is a low-voltage side which is connected to the
Arduino while output side is connected to the DC motor.
VCC is to be connected to power supply (5 Volts) while GND is to be connected to the ground. IN
receives activation from one of the Arduino output pins. COM and NO is used in Normally Open
mode while COM and NC are used in Normally Closed mode.
4. Circuit diagram:
(Students have to draw the circuit diagram here.)

5. Procedure

Fig. 8 Arduino IDE Editor

a) Open Arduino IDE editor. Type the Arduino code (sketch) in the editor as per the functionality
explained in section 3.2
b) Connect the Arduino board to the USB port of the PC/laptop.
c) Compile the sketch by selecting “Verify/Compile” in Sketch option in the menu. Remove the
errors if any.
d) Select the correct board and COM port from “Tools” option in the menu.
e) Select “upload” from the sketch option.
f) When the sketch uploading is complete, Output window will show “Uploading complete”
message.
g) Connect the remaining components to the Arduino board circuit as per the circuit diagram.
h) The LCD display will display current temperature. Try increasing the temperature by rubbing
your hands and touching the DHT-11 sensor gently. If the temperature goes beyond the set limit,
DC motor will start and will continue to run till the temperature goes down below the threshold.
i) Test the circuit for various temperatures.

6. Post-Experiment Exercise:
i. What components (hardware/software) will be required additionally in this system if the
temperature data is to be published on a web app?
ii. Write down min. 5 features of a Smart Home system which can be easily implemented
using IoT platform.
iii. Find out the approximate cost of the main components used in this system.

7. Conclusion:
Summarize the key takeaways from this experiment.

References:
Textbooks
[1] Internet of Things: A Hands-on-Approach, Arshdeep Bahga and Vijay Madisetti, Universities
Press, Reprint 2020
[2] Internet of Things: Architecture and Design Principles, Raj Kamal, McGraw Hill Education,
Reprint 2018
Web resources
[1] Arduino official site: https://www.arduino.cc/
[2] Arduino Uno Pin Diagram: https://components101.com/microcontrollers/arduino-uno
[3] Interfacing of 16*2 LCD: https://circuitdigest.com/microcontroller-projects/interfacing-16x2-
lcd-with-arduino
[4] Interfacing of relay: https://arduinogetstarted.com/tutorials/arduino-relay

You might also like