Chimera Computing Ltd

ESP8266 - HRV WIRELESS
Electronic Projects

BACK


The following outlines how to build an ESP8266 that connects to an HRV (heating recovery ventilation) system and sends roof and house temperatures, control panel temperature and fan speed via MQTT messages to OpenHAB. This is designed to work with an ESP8266-01 board (although should work with any ESP8266 3.3V version)


OpenHAB and Mosquitto

The ESP8266 code has been written specifically to work with OpenHAB (open source home automation software) and an MQTT broker such as Mosquitto (a messaging subscribe/publish type protocol that is lightweight and great for communication between devices) Don't let the names or acronyms scare you, they are really quite simple to use once you get to know how they work. I utilise OpenHAB on a NTC C.H.I.P (US$9 computer) however many people use a Raspberry Pi or similar. This tutorial assumes you have implemented OpenHAB (if you need help setting up OpenHAB, follow this excellent article from the makeuseof web site) You also need to download and install Mosquitto (MQTT broker) and related OpenHAB binding. You can install this elsewhere on your network, however most people just install this on the same machine as OpenHAB to keep it simple.

To install Mosquitto, following this link then select the type of device you are using and follow the instructions. Because C.H.I.P runs Debian (Jessie), you can follow the Raspberry Pi instructions if you are using C.H.I.P. for your Home Automation device (also note, its best to reconfigure CHIP to boot from the CLI. There are instructions for this here)

Once you have OpenHAB and Mosquitto running, you need to prepare the ESP8266 for the code below. First, you need to add the PubSubClient library. In the Arduino IDE, from the menu's go to Sketch, Include Library, Manage Libraries In the filter search box, type PubSubClient then highlight the search result and click to Install (at time of writing, the latest version is 2.6.0) You will also need the ESP8266 board which can be done by following instructions here


What does this give me?


As stated earlier, this project will allow you to view your HRV control panel roof, house, control panel temperatures and fan speed in the OpenHAB GUI.
To show what this view looks like, here is an image from my iPhone:



I have also installed RRD4J and the related binding to have graphing configured. This will allow you to click on either 'House' or 'Roof' and get a history of HRV temperatures for each over the past hour, day or week.



Additionally, I created an OpenHAB view that shows a comparison between Outside temperature (provided by the Weather binding add-on, in my case using Wunderground) versus the roof and house temperatures by clicking on the 'Control' option. I plan on using this data in rules to turn on heating appliances as required. Simply add the Weather item to your Image URL in the sitemap file and include this on the same graph (eg: ...items=houseTemp, roofTemp, weatherTemp... - see below for more information)






Parts Needed / Assembly


You will need the following parts:

  • An RJ11 splitter (this splits the single from the controller in the roof, to the control panel and the ESP8266)
  • ESP8266-01 (other 3.3V versions should work)
  • TTL logic level converter (change data from 5V -> 3.3V)
  • AMS1117 3.3V voltage regulator (or similar, between HRV VCC and ESP VCC to change voltage from 5V -> 3.3V)
  • 1N5817 schottky diode (helps stop HRV control panel resetting on ESP power on)
  • 10K ohm resistor (pullup resistor between 3.3 Voltage Regulator and ESP CH_PD)
  • 10V 100uF capacitor (or similar, to smooth out inbound power from HRV)
  • 10V 10uF capacitor (or similar, to smooth out outbound power to ESP)
  • Optional push button to reset the ESP



    Here is a schematic showing how the parts should be assembled:
    (Note that there are 6 pins that come down the ribbon cable from the HRV controller unit in the ceiling. Pins 1 and 6 are 5V, pins 2 and 5 are GND and pins 3 and 4 are Data. You only need to use pins 1,2,3 and 6)




    Here is the breadboard with the parts together



    The splitter you need will just be an RJ11 splitter like this, just make sure its a splitter where the pins are straight through (eg: pin 1 goes to pin 1, pin 2 to pin 2 and so on)



    The completed unit soldered on a PCB shown here. Note that the extra jumper ports are for connecting an FTDI for reprogramming the ESP later (as shown in the 2nd image), and the switch shown puts it in "programming" mode. These are optional, but recommended if you need to reprogram it later (eg: you change your WiFi password as the WiFi AP and password are hard programmed into the code, which you will need to upload once your ESP8266 is built. See below)





    Click the link to download the ESP8266 HRV code:

    hrv-esp8266.ino

    Open in the Arduino IDE, ensure the ESP board is installed as well as the PubSubClient. Edit the code and change the WiFi AP name and password and the IP address of your MQTT broker (these are the only things you should need to change) Click the 'Verify' button to ensure it compiles ok then upload the code to your ESP8266

    // Wifi
    const char* ssid = "your_wifi_ssid_here";
    const char* password = "your_wifi_password_here";
    
    // MQTT Broker
    IPAddress MQTT_SERVER(192, 168, 222, 254);
    



    Testing


    For testing you can leave your FTDI adapter connected and open the Serial Monitor in the Arduino IDE, you should see messages printing the temperature information in the console. If you need to troubleshoot incoming MQTT messages from the ESP8266, then on the OpenHAB/Mosquitto server, and run one of the following commands:

    mosquitto_sub -d -t "openhab/hrv/rooftemp"
    mosquitto_sub -d -t "openhab/hrv/housetemp"
    mosquitto_sub -d -t "openhab/hrv/controltemp"
    mosquitto_sub -d -t "openhab/hrv/fanspeed"


    You should see inbound PUBLISH messages coming in from the ESP8266. Note that the code only sends the temperature data IF any data has changed. It keeps track of the last temperature, fan speed etc data that was sent.



    A 3cm x 7cm PCB fits nicely in the flush box behind the HRV Control Panel. I would recommend only doing this if it is a plastic flush box as a metal box may interfere with Wifi signals or possibly short out connections on the PCB board. Alternately, you could print out a plastic 3D case to mount the board.




    OpenHAB Configuration


    OpenHAB changes required are as follows

    'items' file:


    'sitemap' file:


    Download the extra icons for the OpenHAB view here (right click and save images)



    Save these files to the ..\OpenHAB Home\webapps\images foler on OpenHAB