This project is about driving a two speed fan with an Arduino, based on the environment’s temperature.
The project has been designed to help automating an existing fire-based heating system. The idea is that the environment will be warmed faster, by driving heated air into the room with a multi speed fan, while the fire is hot and the surrounding environment not yet.
I wanted to make it a little more interesting by adding a LCD display to show temperature, humidity and fan status, and four buttons to increase and decrease the two temperature values that drive the fan speeds.
When the temperature is below the lowest temperature threshold, the fan will be running at full speed. With temperatures between the lowest and the highest threshold the fan will be running at half speed and with temperatures above the highest threshold the fan will be off.
This project demonstrates the use of an Arduino (or compatible) micro controller with a temperature and humidity sensor to drive outputs, it demonstrates the usage of a LCD display, push buttons and EEPROM memory storage.
Below I made a short video demo of the resulting prototype.
For the electronic components of the project we need:
- Arduino or similar (eg: Arduino Mini)
- DHT22 temperature sensor
- LCD display
- A two channels relay module
- Four push buttons
- Six resistors – Four 10kΩ as pull-down for the buttons and two resistors for the LCD brightness. In my case the LCD resistors were 1kΩ with 4.7kΩ, with a different LCD and setup I used a 1.5kΩ resistor instead of the 4.7kΩ, it might depend on the LCD manufacturer and on the environment. Alternatively, a potentiometer can be used.
For the software I used four libraries, two of them need to be installed:
For libraries installation please refer to Arduino’s official guide.
EasyButton is helpful to read buttons and complete an automatic de-bounce. It is not strictly necessary as it is possible to read and de-bounce buttons manually, but it requires a bit more coding.
DHTlib helps reading the temperature and humidity values of the DHT22 sensor.
Additionally we use the EEPROM library to store the thresholds into the Arduino’s EEPROM, so that even if the Arduino is powered off, the values can be re-loaded at boot.
Finally we use the LiquidCrystal library to drive the LCD display.
To build (and eventually modify the project) you would need to connect all the components according to the schema and load the code into the Arduino microcontroller.
If no text is visible on your LCD display, you can connect a potentiometer to GND, LCD V0 (3rd pin of LCD) and Vcc, instead of the two fixed resistors of the schema, so that the screen brightness can be adjusted if/when needed.
The code built and used on this project can be found on the GitHub gist below: