MyThermostat
A home wifi thermostat with a Raspberry PI-3 with TFT screen and an ESP32 measuring the room temperature and sending it to Raspberry via wifi.
Overview
The wifi thermostat software runs on a Raspberry with TFT 3.5" Touchscreen.
The room temperature is measured by a sensor connnected to an ESP32.
Every 30 seconds the ESP32 sends the room temperature to the Raspberry via wifi.
The thermostat SW running on the Raspberry PI compare the received temperature and consequently turn on or off the relay.
The thermostat has the following states:
- Off. The relay is always off
- Manual. The relay is on if the room temperature is below the set temperature
- Thermostat. The relay is on if the room temperature is below the set temperature at that time range.
See the logic diagram below also.
Prepare your Raspberry
- I used a Raspberry PI 3 Model B Scheda madre CPU 1.2 GHz Quad Core, 1 GB RAM bought at Amazon
- Start from a clean sd: I tested 8M and 32M SD Samsung cards.
- Install "Raspian Jessie with Desktop" or "Raspbian Stretch with Desktop", I tested:
- Stretch "2017-11-29-raspbian-stretch.img" downloaded and with "installation guide" at Download Raspbian Stretch
- Jessie "2017-04-10-raspbian-jessie.img"
- Jessie "2016-11-25-raspbian-jessie.img"
- (Optional, if you don't have screen, keyboard and mouse) Prepare the SD you just created for headless operations following these instructions.
Raspbian Stretch Headless Setup Procedure
- Install the python PIL module with the command. In newest Raspberry PI OS it should be there already.
pip3 install pillow
Autostart the Python3 program on Raspbian
- Place thermostat folder into /home/pi
- Add this line to ~/.config/lxsession/LXDE-pi/autostart file
...
@sh /home/pi/thermostat/start.sh
Install a TFT 3.5" Touchscreen
- I used a Elegoo 3.5 Inch 480x320 TFT LCD Display Touch Screen Monitor
- Install the software inputting these commands one by one:
sudo apt-mark hold raspberrypi-bootloader
sudo apt-get update
sudo apt-get upgrade
git clone https://github.com/goodtft/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/
sudo ./LCD35-show
- Calibrate the screen
Optional, but useful. Follow instructions at 3.1 here ELEGOO 3.5" TFT Touchscreen
Highlights
Screenshots
These are the pages shown by the MyThermostat python3 programs:
Logic Diagram
220V relay connection to Raspberry PI Schematic
See these lines of code inside MultiPage.py
# set pin 40 as output to command the 220V relay
RELAY_PIN = 40
...
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(RELAY_PIN,GPIO.OUT)
GPIO.output(RELAY_PIN,GPIO.HIGH)