Temperature Control and Monitoring using

Raspberry Pi and TpLink HS110 Smart Plugs and two 3kW Fan Heaters

 

IMPORTANT:  In my view running 3kW heaters long term connected to UK 13amp sockets is not wise.  I have decided that until I find an alternative I will run the 3kW heaters I have at half power. (Spring has come so that's enough heat to warm the workshop if I set the ramp up to start early enough - in the early hours of the morning)

The sockets and connections get very warm and can even burn out depending on the type of socket.

Recently TPLink replaced a TPLink HS110 where the internal switch had failed to open circuit after about 2 years use. (The Plugs have a three year Guarantee).  I have another HS110 where he prong of the socket burnt out.

Having said that I hav used the plugs over two winters on the 3kW heaters with just those two failures.

 

If you have any queries or comments, please email rpi@torrens.xyz

The code (version 035 May 22nd 2019) can be downloaded as a Zip File with this link.   This set of files should be extracted from the Zip file so that you end up with it all in a folder \home\pi\code.

This zip file is all the files in use by me on May22nd with just the ftp_cred file edited to overwrite the password.

Recent changes resulting in version 035 include dividing up the code into more modules with separate modules for each class and introducing scaling as newer TPlink HS110 seem to have different power scaling. (1000x!)

Then edit the ftp cred file if you want to use FTP and edit rc.local in \etc to make the code start automatically or jus go to \home\pi\code and type .\tmux_start.sh.

The various options can also be edited in the config035.cfg file.    You will find aadditional items need to be installed including the very useful tmux, w1thermsensor.

This is easiest to sort by just trying to run the software and installing missing items based on error reports.

The "import" statements at the start of each python script can also help with this..

To edit the schedule.csv file load it into excel and change the format of the date and time columns so that they display the dates and times.  Be sure to change back the format to plain numbers before saving to csv file again.

The schedule file now just has a list of start timeas and session durations instead of a list of times and temperatures. This now means all sessions for a whole year can be in a quite small file. The schedule also specifies the ramp up speed, minimum and maximum temperatures.  Tao facilitate testing the script outputs files to check the calculations and list temperatures.

A complete set of files in use March 1st 2019 code version 27 now in use can be downloaded from this link..   In this version have added debug rotating log file to try to detect where the code freezes. Freezing is happening after 3 to 10 days running.  The file generated can be viewed by clicking on debug.html link in above window. 

(The next stage will be to generate the schedule for multiple rooms from a web site booking system. This would allow rooms to be booked and then the heating to be automatically brought on at the right time.  Also it is intended to put the profiles for rooms in a separate file from the list of session times and lengths.).

The Raspberry Pi Python 3 code used in this project has the following features:

Every Cycle five "three wire" temperature sensors are scanned, and data logged from them, if new sensors were connected then they would automatically be included.  (Currently five sensors are connected in parallel, but it is possible to use far more).
A CSV file is generated with sensor codes, names, locations etc which can be edited for the next program run so that sensor names can be added.

       (CSV files also generated for testing the new temperature scheduling and profile).

A CSV file, config.csv is used to set up program parameters.

FTP is used to send files to this website.

Every Cycle the following files are generated:

An HTML File To display status on web site (See Below)
An HTML File showing Recent Program Status (Status.html) linked to from page below.
An HTML File showing all recent Logged data, (log.html) linked to from page below

Every few cycles a CSV file is updated with logged data also linked to from the page below.  This shows all data logged since program started.
This CSV file can be opened by Excel so that data can be analysed.

Each cycle two TPLink type HS110 Smartplugs are commanded on or off based on current target temperature and their status and power use logged.

After a power failure the software is setup to restart automatically by editing "rc.local" in "/etc" and using a command that uses "tmux"

This system is controlling the heating in the Whitchurch Shed. ( www.whitchurchmeninsheds.uk ).

Fan Heaters are controlled by TPLink Smart Plugs which in turn are controlled over Wi Fi by the R Pi (Raspberry Pi)

A combination of www.dataplicity.com and "tmux" (  github.com/tmux/tmux/wiki ) and "cloudcmd" ( is used to allow the Python 3 to be monitored stopped, started and edited from anywhere. (docs.dataplicity.com/docs/share-files-with-wormhole ) [ see also My Cheat Sheet ]

(The same software is used to provide more accurate control of a Sauna Heater.  This mode is one of the start-up options. This application has not yet been tested with this version of the software)

 

If you have any queries or comments, please email rpi@torrens.xyz .