BLE Room Temperature controlled Heater
by Matthew Ford 11th May 2022 (original 25th May 2021)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.
Updated 2nd May 2022 – Rev 4 using simple long
life BLE temperature sensor
Updated 5th Jan 2022 – added ESP-01 Timer Switch
The oil filled electric convection heater shown above is used to heat the bedroom over night. However it did not do a good job of keeping the room warm and by about 3am the room became uncomfortably cold. The control on the heater was controlling the heater's temperature, not the room's temperature. This project uses a very simple long life BLE temperature sensor to measure the temperature at a central spot in the room and broadcast the temperature as part of its advertised name. The Adafruit BLE board scans for near by BLE devices, picks up the temperature and then controls a 40A Zero Crossing Solid State relay that turns the heater on and off. The heater's switch is on and it's own control is set out of the way, so it turns on and off controlled by the Solid State switch.
The whole unit is time controlled to only run at night. It automatically starts to control at 8pm and stops at 7am, using the ESP-01 Timer Switch. Initially a mechanical wall socket timer was used, but this proved too noisy at night and lost it time when switched off. The ESP-01 Timer Switch keeps accurate time (within a second or so) over years and automatically adjusts for daylight saving changes.
NOTE: See the warning below about controlling an oil filled convection heater.
Using four (4) previous projects, this project
was completed in less than half a day. Those previous projects were
3G/2G SMS Remote Control Power Switch, the Simple BLE Temp Sensor for Beginners runs 5 Years on Coin cell, the WiFi to BLE Bridge and the ESP-01 Timer Switch
The Simple BLE Temp Sensor for Beginners runs 5 Years on Coin cell provides the remote room temperature sensing. It mounted on the side of a book case and will run for 5 years on its CR2032 battery. Every 100 seconds it advertises its name together with the current temperature, eg. T_3,22.25 The nRF52832 uC on chip temperature sensor is used. It is not very accurate, but since the temperature is to be controlled at about 20 degC, only need a single point calibration to get +/-0.5 degC accuracy.
The Adafruit nRF52 Feather from the WiFi to BLE Bridge is a programmed to continually scan for BLE devices. If the device name does not start with T_3, then it is ignored. Otherwise the device name is parsed to extract the current temperature. If the room temperature is low the Adrfruit Feather drives the control input to the 40A Solid State Relay from the 3G/2G SMS Remote Control Power Switch, with the SMS board replaced with the WiFi to BLE Bridge. The Adrfruit Feather output is specially configured as a High Drive (9mA) output pin. The Solid State Relay in turn controls the AC supply to the heater. The Zero Crossing feature of the Solid State switch means there are no current spikes on the power line as the heater only turns on and off just when the AC voltage crosses zero.
To control the over all on/off times of this heater the ESP-01 Timer Switch relay is inserted between the Adafruit Feather output and the Solid State Relay input. The ESP-01 Timer Switch is controlled via its webpage.
When the ESP-01 Timer Switch is set to Auto, it will disable the Solid State Relay input outside the set On/Off times. The ESP-01 Timer Switch uses internet time (NTP server) to prevent time drift and has the local time zone set to handle daylight saving changes automatically.
The Adafruit Feather is in turn controlled via the ESP8266 WiFi via pfodApp (no Android programming required) to set the desired room temperature and display the current temperature and weather the heat should be set ON/OFF or auto controlled by the BLE temperature sensor and to display a plot of the room temperature over the last 24hrs. As mentioned above this ON/OFF/Auto control is further controlled by the ESP-01 Timer Switch settings. If the Timer Switch is set to ON, the Adafruit Feather's ON/OFF/Auto has full control. If the Timer Switch is set to OFF, the heater is always OFF. If the Timer Switch is set to AUTO, the Adafruit Feather's ON/OFF/Auto only has control between the Timer Switch's On Time and Off Time.
The control menu, sliders, plot etc, was designed using pfodDesignerV3. Here a simple black/white color scheme is used, but pfodDesignerV3 makes it easy to choose your own font and background colors. The entire menu and plot format is contained in the Arduino sketch. No Android coding is required.
Another feature of pfodApp is that the plots can be zoomed, in both axes, using two fingers. Above is the plot of the last 3 days temperatures zoomed in to 20hrs and with the temperature zoomed into 18degC to 25degC. This shows the heater controlling the temperature within in +/-0.5 degC.
For the parts list for this project see the parts lists of the four previous projects. 3G/2G SMS Remote Control Power Switch, the Simple BLE Temp Sensor for Beginners runs 5 Years on Coin cell, the WiFi to BLE Bridge and the ESP-01 Timer Switch. From the 3G/2G SMS Remote Control Power Switch you can omit the following parts:- the 3G SIM5320 module and the Mega2560 and the battery.
/ Adafruit HUZZAH ESP8266 are required to adjust the temperature
setpoint and plot the last 3 days temperatures. If you hard code your
desired temperature and don't need to view the previous temperatures,
you can omit the Adafruit HUZZAH ESP8266 from the WiFi to BLE project
and omit the pfodApp.
The ESP-01 Timer Switch can be controlled via a web page from any web browser.
Having already completed the previous four projects, this construction is easy. From the SMS Remote Control Power Switch, remove the Mega2560 board and the SMS Adafruit FONA board and antenna and battery and install instead the Adafruit Feather nRF52 Bluefruit LE from the WiFi to BLE Bridge. Wire the SolidState +ve control input to Pin A2 and the -ve input to GND on the Adafruit Feather nRF52. The USB power supply in the SMS Remote Control Power Switch will power the Feather nRF52 once it has been programmed. No changes are need to the Simple BLE Temp Sensor for Beginners runs 5 Years on Coin cell or the ESP-01 Time Switch
As you can see from the first photo above the ESP-01 Time Switch is powered from the 5V supply on the HAZZAH ESP8266 board and the ESP-01 Timer Relay opens and closes one of the low voltage leads (the GND lead for example) from the Adafruit Feather nRF52 that controls the Solid State Switch. This allows the timer to control the period during which the heater is active. The ESP-01 Timer Switch Relay will flicker on when powered up. This can be avoided by adding a large capacitor, see ESP-01 Time Switch. However for this application the very short on time, on power up, does not matter so the capacitor was omitted.
For the ESP-01 Time Switch, follow the programming instruction given in that project.
For the WiFi to BLE Bridge, follow the programming instructions given in the Simple BLE Temp Sensor for Beginners runs 5 Years on Coin cell - BLE to WiFi Bridge section, but use the following sketches to program the Adafruit Feather, BLE_TemperatureControl_BLE_R4.ino, and the Adafruit HUZZAH ESP8266, BLE_TemperatureControl_WiFi_R4.ino, boards. These sketches are in the BLE_TempControl_R4.zip file. Download BLE_TempControl_R4.zip and unzip it to your Arduino sketch directory. The sketches need a number of supporting libraries, SafeString available via the Arduino library manager and ESPAutoWiFiConfig.zip from ESP32 / ESP8266 Auto WiFi Config and pfodParser.zip library. The file libraries_RoomTempCtrl_R4.zip contains all the necessary libraries. Just download it and unzip it to your Arduino sketch directory.
The Adafruit Feather stores the Auto/On/Off and setpoint and senor setting in a file in flash memory so they are retained if the entire unit is turned off. The on/off of the ESP-01 Time Switch only controls the Solid State switch, not the power to the Adafruit Feather. The file system need initializing, so first time you program the Feather, uncomment the #define INITIAIZE_FILE_SYSTEM near the top of the BLE_TemperatureControl_BLE_R4.ino sketch and load and run the sketch to set up the file system, then comment out the define again for the final programming.
The red led on the Feather indicates the mode of operation. The led is off for heater OFF, on bright for heater control ON and on very dim for heater control AUTO. If the scan does not find the sensor, the led will flash rapidly.
Messages between the BLE Feather and the ESP8266 are in CSV format. See the comments in the sketches for the format
An oil filled convection heater has a heating element inserted in the bottom via seals to keep the oil in. Over time the seals get stiff and eventually start to leak oil. In normal operation, an oil filled convection heater limits it temperature via a on-heater thermostat and the expansion of the metal case is limited also. In the first installation of this project the heater thermostat was turned to maximum (usually the heater was only run at half setting). The result was when the heater was turned on it became much hotter then normal and the extra expansion caused the seals to leak oil and release a strong smell of burnt oil. So the suggestion is to not set the heater thermostat at maximum, but instead set it just above what would be needed to heat the room to a slightly higher temperature then the setpoint. This will help prevent premature oil leaks.
After the heater started leaking it was replaced with a very old
upright convection element in air heater, without a fan, with its
thermostat turned to maximum.
The room responds much faster to this heater turning on and off and the heater cycles on/off about every 15mins. The control is still ~+/-0.1 degsC, in this case around a set point of 21degsC
AndroidTM is a trademark of Google Inc. For use of the Arduino name see http://arduino.cc/en/Main/FAQ
The General Purpose Android/Arduino Control App.
pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.
Contact Forward Computing and Control by
©Copyright 1996-2020 Forward Computing and Control Pty. Ltd. ACN 003 669 994