BLE Room Temperature controlled Heater
by Matthew Ford 6th June 2021 (original 25th May 2021)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.
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 BLE
temperature/humidity module to measure the temperature at a central
spot in the room and send the reading to a BLE receiver that then
controls a 40A Zero Crossing SolidState 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
NOTE: See the warning below about controlling an oil filled convection heater.
Using three (3) previous projects, this project
was completed in less than half a day. Those previous projects were
Very Low Power BLE Temperature/Humidity Monitor (or Very Low Power BLE Nano V2 Replacement), the WiFi to BLE Bridge and the 3G/2G SMS Remote Control Power Switch
(Alternative Temperature/Humidity Sensor Very Low Power BLE Nano V2 Replacement)
The BLE Temperature/Humidity project provides the remote room temperature sensing. It is battery and solar powered and always on ready to accept a BLE Nordic UART connection. Once it connects it automatically sends the current temperature and humidity once every minute in CSV format terminated by a newline, millisSec,temperature,humidity,1m The Adafruit nRF52 Feather from the WiFi to BLE Bridge is a BLE central device and a small modification to its code connects the the Temperature/Humidity Sensor peripheral every 2mins to pick up the CSV line, parse it for the temperature and compare it to the required setpoint (20degC). If the room temperature is low the Adrfruit Feather drives the control input to the 40A Solid State Relay via a specially configured 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 no current spikes on the power line as the heater only turns on and off just when the AC voltage crosses zero.
For the parts list for this project see the parts lists of the three previous projects. Very Low Power BLE Temperature/Humidity Monitor (or Very Low Power BLE Nano V2 Replacement), the WiFi to BLE Bridge and the 3G/2G SMS Remote Control Power Switch Of the three the BLE Temperature/Humidity Sensor requires the most work to construct. 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.
Having already completed the previous three 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 Very Low Power BLE Temperature/Humidity Monitor
To program the Feather nRF52, follow the instructions on downloading and installing the Arduino Board support for the Feather nRF52. The sketch here is using V0.22.0 of the Adafruit nRF52 board support, which differs from earlier versions.
Before programming the temperature control sketch, you need to identify the BLE address of the BLE Temperature/Humidity Sensor. If you don't already know this from its construction and testing, you can find it by using the Nordic nRF UART V2.0 app.
In this case the BLE address is C1:76:1C:1D:F1:F7 Connecting shows that the 1m CSV line is received as well as other data the sensor sends at longer intervals.
Open the BLE_TemperatureControl.ino sketch in the Arduino IDE and edit the these two lines
const float SET_POINT = 20.0; // the setpoint in deg C cSF(BLE_Client_Address, 20, "C1:76:1C:1D:F1:F7");
to set your desired setpoint the the address of your BLE sensor. cSF is shorthand for createSafeString( ) see the SafeString tutorial.
The first line in the setup() is
Bluefruit.autoConnLed(false); // default is Bluefruit.autoConnLed(true);
which disables the Blue connection LED. Otherwise it will be flashing all night. When testing you can comment out this line to see when the BLE Feather has connected to the temperature/humidity sensor.
The BLE_TemperatureControl.ino sketch is based the central_bleuart.ino example sketch that comes with the Adafruit nRF board package. The main changes are:-
BLE devices other then the BLE_Client_Address are ignored when found when scanning.
When the BLE_Client_Address is found, the connection is skipped if the temperature was read in the last 90sec. This results in a 2min interval between temperature readings.
A special void setAsOutputHighDrive( uint32_t ulPin) method has been added which is used to set the A2 pin as an output with a high current drive for the HIGH level. This is needed to drive the Solid State switch input.
The Red Led indicates that there has been a temperature reading from the BLE temperature sensor in the last 4 mins. If the Red led goes out check if the BLE Temperature Sensor is too far away or if its battery is flat.
Finally in the bleuart_rx_callback method the CSV lines are collected in the rawData SafeString using the readUntil('\n') method. Then the rawData is parsed using the nextToken(token, ',') to pick out each comma separated field. The final (4th) field is checked it is 1m before converting the temperature and comparing it to the setpoint.
The Very Low Power BLE Temperature/Humidity Monitor accumulates the temperature readings and these can be downloaded and plotted by the pfodApp. Here is the plot for one night from about midnight to 7:30am
As you can see the temperature s controlled to ~20.1 degC +/-0.1 and the heater turns on for about 10mins, at maximum heat (see below) each hour.
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 resulting control is shown below.
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
The next stage of the project added the Adafruit HUZZAH ESP8266 Breakout back in (wired up as shown here) and programmed it to server a pfod menu that let the heater be turned on/off, change the setpoint and display the current room temperature. The pfodApp is need to display this menu. The free pfodDesgner was used to generate the basic menu. The Off/Auto/On was hand code following the example in Text Slider Button section of the pfodSpecification.pdf
The measurements are sent to from the Feather nRF52 to the ESP8266 as CSV <temperature>,<setpoint>,<state><newLine> where the <state> is 0 for always OFF, 5 for Auto Off, 10 for Auto ON and 15 for always ON and <newLine> is the '\n' character, e.g. the above display is set by the message 35.2,21,5
The two sketches for this version are in the BLE_Wifi_TempControl.zip file. Rev 2 adds Red Led indications. Flashing if no BLE sensor found (change the sensor battery or move it closer), Off if heater mode is OFF, On (bright) if heater mode is ON, if the heater mode is AUTO then the Red Led is dimly on.
This project could be further enhanced by using the ESP8266 to store the temperature measurements and the heater switching times and serve them as a plot on to pfodApp or on a web page.
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