Automatic Thermostat System
Automatic Thermostat System
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.
Here are some key features and information about the DHT11 Sensor:
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
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
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.
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
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
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
#Setup DC fan
fan = Pin(PIN_FAN, Pin.OUT)
while True:
dht.measure()
temp = dht.temperature()
hum = dht.humidity()
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.
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
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.