0% found this document useful (0 votes)
15 views

Automatic Thermostat System

Uploaded by

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

Automatic Thermostat System

Uploaded by

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

2021-1-DE02-KA220-ADU-000033587

Automatic thermostat system


1. Introduction
Automatic thermostats offer numerous benefits. With them, you can effortlessly regulate
the climate in your home without the need for manual adjustments. Whether you're inside
your house or away, these thermostats enable you to maintain the ideal room temperature
with ease. This not only enhances your comfort but also helps you save energy and reduce
utility costs.
In this tutorial, we present an approach to temperature control using a smart thermostat
system. The core components of this system include:

 The DHT11 sensor to accurately measure temperature and humidity, enabling


precise environmental monitoring.
 The integration of a DC motor fan to offer effective heating or cooling to
maintain your desired indoor climate based on sensor readings.
 Utilizing the TIP-120 module and diodes, this system ensures efficient
temperature control, guaranteeing comfort and energy efficiency.

1.1. Learning Objectives

 Understand the DHT sensor and its characteristics.


 Work with a DC motor, TIP-120 module, and diode for fan control.
 Create an automatic temperature control system.
 Integrate the thermostat system into the SmartHome4Seniors house model.

1.2. What do I need?

Software

So that you can carry out the installations shown in this tutorial you should have
downloaded the Thonny programming environment on your device. Also, you need to
have installed the firmware of MicroPython on your Raspberry Pi Pico. The extended
modifications (see p 42 in manual) including the extra components and their connectivity
must also be made on the breadboard.
Electrical Hardware

 1x Raspberry Pi Pico
 1x Full size breadboard
 1x Micro-USB cable
 several male-to-male jumper wires

This project has been funded with support from the European Commission. This publication [communication] 1
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

 1x DHT11 sensor
 1x Fan (DC motor)
 1x Diode
 1x TIP-120 transitor
To attach components at SmartHome4Seniors house model
• 9x Bolts
• 9x Nuts
Ability
As regards physical skills you should be able to count off holes on the breadbord and
insert components to it.

2. Learning content
2.1. Theoretical background

To understand the content of this tutorial well, you will now get an introduction to the
most important terms and contexts.

1.2.1 What is a DHT11 Sensor?


The DHT11 Sensor is a compact digital temperature and humidity sensor, widely used for
accurate readings in weather stations, home automation, and environmental monitoring.

Figure 1 DHT11 Sensor

Here are some key features and information about the DHT11 Sensor:

1. Detection Method: The DHT11 sensor utilizes a combination of a capacitive


humidity sensor and a thermistor to detect temperature and humidity in the
surrounding environment.
2. Operating Principle: When in operation, the DHT11 sensor provides both digital
and analog signals. The analog signal represents the temperature, while the digital
signal encodes both temperature and humidity information. This output can be
interfaced with microcontrollers for further processing.
3. Accuracy and Calibration: The DHT11 sensor is designed for reasonable accuracy
in measuring temperature and humidity. It's crucial to note that, like any sensor, its

This project has been funded with support from the European Commission. This publication [communication] 2
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

accuracy may be influenced by factors such as calibration, environmental


conditions, and manufacturing tolerances.
4. Compatibility: The DHT11 sensor is compatible with various microcontroller
platforms, including popular ones like Arduino and Raspberry Pi. This versatility
makes it a go-to choice for hobbyist projects and DIY applications.
5. Integration with Microcontrollers: To use the DHT11 sensor, you'll typically connect
it to a microcontroller through its designated pins. The sensor's datasheet or
documentation provides detailed information on the pin configuration, ensuring
accurate wiring.
6. LED Indicator: Unlike the KY-026 flame sensor, the DHT11 sensor does not come
with an integrated LED indicator. Instead, the data output is processed by the
connected microcontroller, which can be programmed to indicate the sensor's
status through other means like LEDs or displays.
7. Use Cases: Common applications for the DHT11 sensor include weather stations,
climate control systems, and home automation projects where monitoring
temperature and humidity is essential for decision-making.
When working with the DHT11 sensor, connecting it to a microcontroller is a typical
requirement. Writing code to interpret the sensor's output and trigger appropriate actions
based on temperature and humidity readings is necessary. The specifics of wiring and
code will depend on the chosen microcontroller and project requirements. Always refer to
the DHT11 sensor's datasheet and documentation for precise information on its usage,
pin configuration, and integration details.

1.2.2 What is a DC Motor (Fan)?


A DC motor fan is a vital electronic component used for converting electrical energy into
rotational motion, generating airflow to cool electronic components, computers, and
appliances.

Figure 2 DC Motor (fan)

Operating on a direct current (DC) voltage, typically around 5 volts, the fan's blades initiate
rotation, creating a flow of air. This functional design positions DC motor fans as essential
contributors to preventing overheating and maintaining optimal operational temperatures
in various electronic systems. With diverse sizes and configurations, these fans find
widespread application in electronic devices and appliances, offering efficient cooling
capabilities tailored to specific system requirements. Users can adjust the voltage applied
to the fan, allowing for flexibility in controlling airflow and rotational speed to meet distinct
cooling needs in different applications. As a result, the DC motor fan stands as a
cornerstone in electronic thermal management.

This project has been funded with support from the European Commission. This publication [communication] 3
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

1.2.3 What is a TIP-120 Module?


The TIP-120 module is a pivotal electronic component known for its role as an NPN
(negative-positive-negative) power transistor. Widely utilized as a switch, the TIP-120
module excels in controlling high-power devices such as DC motors, solenoids, and high-
intensity LEDs. Its functionality relies on the amplification and control of current flow
through a load by applying a small current at its base. This mechanism enables precise
control over high-power components, making the TIP-120 module a go-to choice for
electronic circuits and projects demanding accurate control.

Figure 3 TIP-120 Module

With its versatile applications, the TIP-120 module finds a place in various electronic
systems where the need for controlled power distribution is paramount. Its capability to
manage high-power devices efficiently positions it as a valuable asset in projects requiring
sophisticated control over electrical components. When integrated into circuits, the TIP-
120 module ensures reliable and precise control, enhancing the overall performance of
electronic systems. As with any electronic component, it's imperative to consult the
manufacturer's datasheet or specifications to ensure proper usage and adherence to
recommended operating parameters.

2.2 Step-by-step guide


Now let's move on to the implementation of the before mentioned scenario. To do this,
take the SmartHome4Seniors house model or just look at the instructions and
recordings.
To make everything work, you have to
- First: attach the components to the SmartHome4Seniors house model
- Secondly: Connect the electronics
- Thirdly: write a program code

2.2.1 Attach the components to the SmartHome4Seniors house model

This project has been funded with support from the European Commission. This publication [communication] 4
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

There is one electronics that needs to be mounted on the back-side wall. This the
DHT11 temperature and humidity sensor. You need to use the following items:

 DHT11: 2 x bolt and 2 x nut. You need to bend the sensor (blue part) forward to
access the mounting holes. Then mount the sensor through the top left and top
right mounting holes.

Temperature sensor

On the left-side piece you will need to mount a DC fan and an LED light. For the DC fan
you will use the bolts and nuts that come in its package (4 x bolts and 4 x nuts). Insert
the LED to the mounting hole and friction will keep it in place.

This project has been funded with support from the European Commission. This publication [communication] 5
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

LED

DC Fan

2.2.2 Connect the electronics


To connect all the components, please follow the wiring diagram below and read the
instrcutions.
Connect the electronics as follows:
DHT11:

- Connect VCC (red cable) to 3v3 rail (+)


- Connect GND (black cable) to GND rail (-)
- Connect S (green cable) to GPIO8 pin
Fan:
- Connect red cable to 5V rail (+)
- Connect black cable from the fan to the middle pin of the TIP-120 transistor
- Connect black cable from the TIP-120 transistor to GND rail (-)
- Connect diode from the middle pin of the TIP-120 transistor to the GND rail (-)
- Connect yellow cable to GPIO9 pin

This project has been funded with support from the European Commission. This publication [communication] 6
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

2.2.3 Write the MicroPython code


Finally, we have to tell our Raspberry Pi, how to transform the information from the
sensors into action.
For this, open Thonny from your device. Then go to File -> Save as…, choose
Raspberry Pi Pico, and save your file under the name thermostat.py.

You can either develop your own Python program or use existing libraries available online.
Downloading an existing library can simplify the process. Ensure to save the library with
the same name on your microcontroller.
Copy the program code for temperature and humidity sensing using the DHT11 sensor
and DC motor and MicroPython below, or simply write it yourself to practice. Then save
the program by clicking the Save icon on the top left-hand side, or by pressing Ctrl+S on
your keyboard.
The code presented here contains the information to continuously measure the
temperature and humidity using the DHT sensor, and then prints the values. It checks if
the temperature is above a certain threshold (25 degrees Celsius in this case) and turns
the fan on or off accordingly. It sleeps for 3 seconds before repeating the loop.

thermostat.py
from machine import Pin
from time import sleep
from dht import DHT11

This project has been funded with support from the European Commission. This publication [communication] 7
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

#Define pins for each component


PIN_DHT = 8
PIN_FAN = 9

#Setup DHT sensor


dht = DHT11(PIN_DHT)

#Setup DC fan
fan = Pin(PIN_FAN, Pin.OUT)

while True:
dht.measure()
temp = dht.temperature()
hum = dht.humidity()

print("Room Temp:", temp, "°C")


print("Room Humidity:", hum, "%")

# Adjust the temperature threshold as needed


temperature_threshold = 25

if temp > temperature_threshold:


fan.value(1)
print("Fan ON")
else:
fan.value(0)
print("Fan OFF")
sleep(3)

The code performs the following steps:


1. Preparation (Python libraries and pin setup)
2. A (endless) loop is started, where the temperature is measured continously
3. If the temperature is higher than the selected threshold (this is preconfigured at
25°C but you can change it to your liking), the fan is started (fan.value(1)). If not, it
is stopped (fan.value(0)).

This project has been funded with support from the European Commission. This publication [communication] 8
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

3. Application on SmartHome
Now it is time to test your code and circuit on your SmartHome. Click the Play button in
Thonny. If you are in a room with a room temperature of more than 25 degrees, the fan
should switch itself off. Otherwise it will remain on.
Check out the video tutorial on how you can implement the automatic thermostat system
on your SmartHome wooden model.

***Video showing application on SmartHome***

4. Summary
In this tutorial, we present an innovative approach to temperature control within your home
using a smart thermostat system. The core components of this system include:

This project has been funded with support from the European Commission. This publication [communication] 9
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.
2021-1-DE02-KA220-ADU-000033587

 The DHT11 sensor to accurately measure temperature and humidity, enabling


precise environmental monitoring.
 The integration of a DC motor fan to offer effective heating or cooling to
maintain your desired indoor climate based on sensor readings.
 Utilizing the TIP-120 module and diodes, this system ensures efficient
temperature control, guaranteeing comfort and energy efficiency.
This guide takes you through the installation, connection, and programming steps to set
up the thermostat system within your home.

5. Self-assessment
1. Does the DHT11 sensor measure both temperature and humidity?
a. Yes
b. No
c. It depends on the sensor model
2. How is the fan controlled in the thermostat system?
a. The fan is always ON.
b. The fan is always OFF.
c. The fan is controlled based on the room temperature, urning ON when the
temperature exceeds a threshold and OFF otherwise.

References
n/a

This project has been funded with support from the European Commission. This publication [communication] 10
reflects the views only of the author, and the Commission cannot be held responsible for any use which may be
made of the information contained therein.

You might also like