Close
0%
0%

Smart IOT thermostat

I live in a rented flat and didn't want to shell out ~£200 for a Nest thermostat, so I decided to build my own.

Similar projects worth following
A smart thermostat that can be retrofitted to an existing boiler setup, using off the shelf components and lightweight networking protocols.

This project is designed to be a fully featured smart thermostat that will control the heating within my flat. I live in a rental, so there were a few constraints that otherwise would not apply to a heating control system.

Firstly it had to be able to be integrated into the current heating system, as I am not buying a new heating loop for a rental property. Secondly it had to be easily reversible, so that when I move out the flat I am able to remove all traces of the system and get my damage deposit back.

With respect to the actual features of the thermostat I wanted it to be able to give full daily granularity over different heating schedules and the ability to change settings (such as desired temp) without going into the actual code. This project is in active development, so I aim to add features as I am able to. 

Until the project is complete, all further information will be included in the project logs. Once it is "completed" (as if any maker project is ever really completed) I will condense all the project logs into a main report that I will put in this section. I will also write full step-by-step instructions, including all code and software elements, so that anyone can emulate it.

Update 31/03/2022:

I never managed to finish this - life got in the way. 


  • 1 × Raspberry Pi 3B Single board computer running Linux
  • 2 × NodeMCU Micro-controller with integrated Wi-Fi
  • 1 × DS3231 RTC Real time clock module for the Raspberry Pi

  • Setting up the MQTT broker on the Raspberry Pi

    Jamie02/15/2019 at 13:08 2 comments

    An Ode to Security

    Let's be honest, not everyone gives the appropriate thought to IoT security, a quick browse of the news shows that. Given that my favourite hat is of the tinfoil variety, I shall be going against the tide for this project.

    My main concern was with development boards being connected to my home network permanently (even if I did write the firmware myself). This is mostly due to their intrinsic lack of RAM and flash memory. A consequence of this lack of any real computing power is that implementing encrypted wireless communication becomes a real faff. I know of people that have (semi-successfully) implemented it, however I decided that it would be easier to isolate the devices to their own network. 


    Raspberry Pi Access Point

    As we want to create an isolated network for our nodes, it makes sense to use the hub itself as the wireless access point (AP). If you have a WiFi enabled Pi this will be trivial. 

    In order to set up the Pi I first flashed the SD card with a clean version of Raspbian Lite (no GUI required). Once this was completed I booted it up and connected it to my home network (you will have to connect the Pi to internet for the initial setup and any updates). 

    With this done I followed the linked tutorial:

    https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

    Once the Pi was set up as an AP, I realised one crucial issue with the Pi being on a stand-alone network with no internet access: it will not keep time if it reboots. This is due to the Pi having no Real Time Clock (RTC). Thankfully there are various cheap RTC modules that are designed for the Pi and an equal number of tutorials to get these set up. 

    I used the the DS3231 RTC module and set it up using the following tutorial:

    https://thepihut.com/blogs/raspberry-pi-tutorials/17209332-adding-a-real-time-clock-to-your-raspberry-pi

    FINALLY we are ready to actually set up MQTT on the Pi to allow it to become the hub.


    The Fun Part (well, the actual point of this post)

    To set up the MQTT broker, we want to install 'Mosquitto' onto the Pi using the below command:

    sudo apt install mosquitto

    Once this has installed (it may take ages) the MQTT daemon will begin immediately on port 1883 (as long as you didn't change any default settings). As it stands, you now have a working MQTT broker on the Pi that will be accessible from any device attached to the Pi's access point.

    The Mosquitto installation can be tested from the command line of any connected device using 'Mosquitto-clients' (see below for installation).

    sudo apt install mosquitto-clients

    Once the installation was working, I needed to secure it using a username and password. This can be set using the 'mosquitto-passwd' command from the terminal. 

    Voila, you now have a Raspberry Pi running as an access point with a working (and password protected, but un-encrypted) MQTT broker.  

    Tune in next time for more ramblings of how I created the logic code that will run on the Pi.

  • System Architecture

    Jamie02/15/2019 at 13:07 0 comments

    Network Topology

    For this project I decided to go for a star network topology to build my smart thermostat, this is a system where there are a number of nodes, all connected to a central hub (see below). 

    Star network topology

    This model brings various benefits and can be described as the status quo for  IoT project architectures (I am super original). It's benefits include the fact that it is modular and can be easily extended via adding in new nodes and functionality as required. Finally this network topology lends itself perfectly to the use of the Message Queue Telemetry Transport (MQTT) protocol for intra-device communication. This is an extremely lightweight protocol that works on a publish/subscribe model and is already implemented in many home automation scenarios. 


    Turning a Model Into Reality

    Now I had the desired topology, I had to find components that would work well with MQTT and the node/hub architecture. 

    Some people decide to use a full home server as their hub, but that would almost certainly defeat the point of building this system to save myself money, not to mention it would be ridiculously under-utilised. Instead I decided to use a spare Raspberry Pi 3B that I have. Not only does this run 'full' versions of Linux, but it also uses very little power. 

    For the node elements of the network I will be utilising the NodeMCU development board. This is a board based on the ESP8266 WiFi module, however it has components attached that allow programming directly from the Arduino IDE (in fact any IDE that has Arduino plug-ins available; I use VSCode). 

    To summarise, I plan to use a Raspberry Pi as a hub and the nodes will communicate via the hub using the MQTT protocol. Currently I am planning to utilise two nodes, one that will sense the temperature and another to control the heating system. There will be logic running on the Pi to parse the temperatures that are sent to it and the same program will decide whether to turn the heating on or off as a consequence of the inputs. This signal will be sent via MQTT to the node that controls the boiler. 

    In my next project log I will be (hopefully) detailing setting up the Raspberry Pi to run as a hub, allowing all the devices to communicate via MQTT.


  • Intro/Preamble

    Jamie02/15/2019 at 13:01 0 comments

    Current Situation

    In my flat the heating is controlled by an analogue dial that controls the temperature that the boiler turns on and off at. The only means of controlling the time is vial a dial on the boiler itself. This is very inaccurate and also inefficient as there is no scope for changing the heating times on a per-day basis. This all combines together to mean that the central heating costs a lot more than it should and has a larger impact on the environment that is necessary. 

    See below for the dial thermostat that currently controls my flat heating.

     What to do About it

    I decided that a fun (and valuable) project would be to overhaul the heating control system within my flat, the barrier to making it worthwhile was very low, after all. 

    I could, of course, have shelled out £200 for a full Nest-style system, however as an engineer that's no fun. Home grown it was. 

    Nest thermostat... total waste of money ;)

    Project Aims

    Once this project is complete I hope to have a fully functional control system for my flat's heating. It won't just be a prototype, I plan to actually put it to use. Due to this, there were a few goals that the project had to reach:

    - Control the heating more accurately and efficiently than the current system

    - Be retrofittable to the current setup, so I am able to get my damage deposit back when I move out. 

    - Cost less than an off the shelf model (hopefully a lot less!)

    With these in mind, I set about looking at possible solutions and ideas that I could incorporate into my design.... TO GOOGLE!.....

View all 3 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates