Smart Bluetooth Thermostat Arduino, Airing and Lights Control
by Gyula Ősi in Circuits > Arduino
1322 Views, 12 Favorites, 0 Comments
Smart Bluetooth Thermostat Arduino, Airing and Lights Control
Just connect and control the Heater, Airing, and Lights via Bluetooth!
An intelligent thermostat routine controls the heater gas boiler, and the system switches my kitchen lights and my bathroom airing fan with relays – can be controlled by buttons and Android device or computer via Bluetooth.
Target temperature stored in the EEPROM memory.
Celsius and Fahrenheit version also available!
All parts are handmade.
Heater working ways
1: One Time Heating (15 mins) timed mode, useful at spring/autumn evenings
2: Thermostat mode (higher priority), the adjusted target temperature stored in EEPROM memory
Thermostat Routine - Boiler save algorithm
Frequent, short-term switching would cut short the lifetime of the heater gas boiler, to keep avoid it, the program uses correction values – these declares the degree of overheating and cooling back. Lower temperature demands greater correction values, because the walls are colder and adsorb better the warmth from the freshly heated-up air, so the above described effect would stronger.
Open window detection
The program detects if a window is open, thus the temperature drops at least -0, 2°C (-0, 36°F) in one minute – the heater stops or won’t start, and the airing fan will turn on in order to help refresh the air. When the air became warmer at least +0, 12°C (+0, 216°F) due to the heat capacity of the environment, the system will switch back to normal mode, and the ‘Window Alert’ event will be dismissed.
Error detection
Measured temperature under 0°C (32°F) or above 40°C (104°F) will be evaluated as malfunction or other problem (error, broken window, fire, etc.), and all devices will shut down.
Supplies
Developed on Arduino Nano (or higher) board, uses Dallas DS18B20 temperature sensor, HC-05/06 Bluetooth adapter, I2C 128X64 bicolor OLED display– you can choose different LCD/OLED display, the u8glib supports a lot of types.
Libraries: DallasTemperature, elapsedMillis, OneWire, SoftwareSerial, olikraus/u8glib
Video
The video shows all the important working ways, gives you ideas how to build the project from the beginning.
How to Use It
Bluetooth communication
The Android GUI app has 8 buttons, sends upper and lower case letters in order to turn on (‘A’), or turn off (‘a’) the timed heater, ‘B’ and ‘b’ turns the airing, ‘C’ and ‘c’ the lights…
The other strength of my project is the nerd-friend Bluetooth serial terminal usage. Just chat with the system via Bluetooth using a serial terminal – it can be an Android app, but even a normal PC will do – for example the Serial Monitor of the Arduino IDE.
The controller sends temperature reports in every minutes automatically, and instant reports about all events, such as an attached device has been turned on/off, the thermostat routine activated, and so on.
Blue: sent code, Green: received message
Control codes
It accepts control codes and sends confirmation messages. My command structure based on two digit numbers like ‘XY’ – where ‘X’ is the device code, and ‘Y’ is the opcode:
30, 31, 32: lighting Off / On / flip logical state
40, 41, 42: airing Off / On / flip logical state
50, 51, 52: one time heater program Off / On / flip logical state
10 – 24 numbers will be accepted as Target Temperature for the Thermostat routine
‘r’ – report about working state of controlled devices
‘w’ – manually disables the “window alert” event, if you don’t want to wait for its automated dismission
‘A, a… H, h’ – letters are accepted as the GUI app would have sent
Fahrenheit version
I was converted all the correction variables, reference and ratio values, so the system kept its calculation and working particularities.
Only a few modification. The new device codes of the Fahrenheit version:
1x - Lighting (10: off, 11: on, 12: flip state)
2x - Airing (20: off, 21: on, 22: flip state)
3x - Heater (30: off, 31: on, 32: flip state) - Timed 15min heater mode
50 - 76 numbers are target temperature values - Thermostat mode
Create the PCB
I designed the project to made up of modules, so it can be disassembled for further experiments and tests. For ideal use of space, several layers of PCBs are connected to each other via pin connectors. The photo gallery helps to create your own.
Create the Enclosure
I chose a simple but high-quality electricial installation box for this project, I used only basic hand tools for the design. 80 by 80 millimeters isn't so big, it demanded the compact interior layout.
Create the Temperature Sensor Unit
To keep avoid the disturbance of the circuits operational heat output I placed the temperature sensor further away, used the top of the same box type for it, covers the place of the original analogue thermostat. For the precise measurement I cut heat insulating material into it.
Wall Mounts
At the end, I mounted both of units on the wall after installing the power supply and the digital data cables.
Conclusion
I'm not kidding you. This is a tested and well-tried project, it's been controlling the heating in my apartment for five years without any malfunction. The temperature is always even, never too cold or too warm.
It's cozy to manage using a smartphone.
In addition to the Thermostat function, the One-time Timed (15min) heating function is also very useful in spring or autumn evenings before going to sleep.