Bluetooth Temperature Regulator

by Milen in Circuits > Microcontrollers

1271 Views, 8 Favorites, 0 Comments

Bluetooth Temperature Regulator

Photo0299.jpg
Bluetooth temperature regulator

The heating of the house using electric heaters during the winter can cost a lot of money. The reason for that could be not only the high energy price, but also not the efficient use of it. Sometimes the electrical heater can be forgotten working for a long period and the room temperature can become unduly high and a lot of energy can be waste. Some electric heaters have temperature sensors and controllers, but their disadvantage is that they measure the temperature locally. Their sensors in the most cases are placed inside the heaters bodies and can be affected by the warm they create. Another weak points is that in a lot of cases they are mount at the walls and measure the temperature there, but inside the room the temperature can be different, what creates another disadvantage. Proposed by me temperature regulator solves these problems. It includes two main parts :

  1. Bluetooth thermometer and controller
  2. Bluetooth power switch

The controller can be everywhere in the room where it can observe the current temperature and through Bluetooth control the power switch to turn on or off the heater. The power switch is mounted inside the heaters body and commutates its power supply. It can be put also outside the room on the power line or inside the power outlet within reach of the Controller BT.

Supplies

HC-05.png
HC-06.png
nano.png
OLED.png
image.jpg
box.jpg
swith.jpg
SSR.jpg
Photo0278.jpg

For this project I used:

Connecting the Bluetooth Modules With the Arduinos

Photo0285.jpg
Photo0287.jpg
transmitter.png
receiver.png

To the first Arduino I connected the HC-05 module. This assembling should work as thermometer & controller. I simply folded the pins of the module and soldered it as shown on the picture. Additionally a level shifter containing one 2kOhm and one 1kOhm resistors were added to the RX pin of the BT module. The OLED display was also connected to the I2C pins of Arduino nano (A4,A5). The power switch module was done is the same way, but using the HC-06 module. It can use also HC-05 one instead but set in slave mode. The SSR should be connected to it. Which control pins you will use for that purpose - your decision. I used D8. The modified power supply modules were soldered to VIN of the Arduino boards.

At the RESET pin of the Arduino of the controller assembling I soldered the tactile switch.

Power Supply Module Modification

Photo0280.jpg

The cheap modules from the shown type are available only with output voltages of 3.3 ,5 or 12 V. I wanted to have around 7.5V output voltage and to supply the Arduinos through their VIN pins. In this way their 5V microcontroller voltages are delivered by the embedded voltage regulators and their value is strong defined. To reach that I have to rework the supply modules. The R5 resistors, which were around 2.5kOhm I have replaced with a 5.1kOhm ones..

Pairing of the BT Modules

gsmarena_000.jpg

After connecting together the BT modules and the Arduinos, the modules must be configured - one as muster, other as slave. For that purpose are used the ATT commands. How to do this you can read here, here or here. The attached sketch can be used to check after that if the modules communicate between themselves .You would need two PC's with Arduino serial monitors. If you do not have two computers, you can find in Internet how to test your modules with your smartphones. Or you can try to install and use some Virtual machines (for example Virtualbox)

Downloads

Putting All Controller Parts Together

Photo0249.jpg
Photo0251.jpg
Photo0253.jpg
Photo0256.jpg
Photo0258.jpg

The controller & thermometer assembling I mounted in a plastic case. All was fixed with a hot glue. The reset switch was soldered on a small perfboard piece and a hole for it was done on the side wall of the case. The OLED display was glued on the front cover of the case. Initially the LM35 sensor was fixed also on the side wall of the case, but this did not work well - it was heated by the internal electronics and was showing 3-4 degrees C more than the real room temperature. So I took it outside soldered on a 10-15cm piece of shielded cable, After this rearrangement the Arduino thermometer started show a value very close compared with other room thermometer.

Coding

Photo0308.jpg
Photo0292.jpg
set temp.png
set hist.png

The codes used are attached to this step. Both assemblings must be programmed with different codes. the sketch "HC05_master_mod.ino" is used for the BT thermometer-controller. The "HC06_slave.ino" for the BT power switch.

The codes are not complicated. I would say that especially the master code is quite heavy. This is because it results from lot of iterations. For some reason adding only one raw containing Serial.print() was spoiling the work of the OLED display. I was not able to find the reason. May be it is in the libraries used (the sketches use the SoftwareSerial, some Adafruit graphical & display libraries and others), or may be it is in the hardware - I used Arduino boards bought in Aliexpress - they had still the old bootloader. But it does not matter - the provided code works fine for me.

At start up the thermometer&controller Arduino reads from the EEPROM the value of the target temperature. It waits around 13 secs new value to be entered through the serial monitor. If a new value is entered it is stored in the EEPROM and set as target value. During this time the target temperature is displayed on the screen. After finishing of this period the Arduino starts to measure the current temperature and if it is lower than the target one - send signal to the power switch to turn on the SSR. On the display in a frame is shown the current temperature. If a successful connection with the power switch is established a blinking label "connected" is displayed also on screen. The power switch module indicates that the SSR is working turning the Arduino LED on.

There are some specific points in the code, which I have to comment.

  • The Arduino uses its ADC to measure the output voltage of the LM35 chip. This ADC normally uses the Arduino power supply as voltage refence for the AD conversion. The Arduino power supply can vary from 4.5 to 5.2 V or more. This variation affects the temperature measurement precision. To have correct results we have to know how big exactly this voltage reference is, what is also the supply voltage of the Arduino. Of course external precise voltage reference or ADC can be used, but this makes the circuit more complex and expensive. The solution is to measure the supply voltage of the Arduino (pin 5V), when supplied by the AC/DC 7.5V module and adjust the conversion coefficient according it. In my code : temp = curr_value * 0.4921875 uses this coefficient. It is calculated as the supply voltage (in my case 5.04 V) is divided by 10 and further divided by 1024. You have to calculate this coefficient by yourself. You can find more explanation in Internet searching "Arduino+LM35"
  • To prevent the continuous switching ON/OFF (oscillation around one value), what can damage the heater I have implemented a temperature hysteresis of 1.5 degrees C. It is shown in the blue frame on the picture. You can change this value if needed.

After programming of both modules the BT temperature regulator should be ready for work. On the video above you can see how it works.