Using Home App to control your ventilation system

Itho daalderop CVE ECO RFT fanMy home is equiped with an Itho Daalderop CVE ECO RFT, and a single RF remote comes with it. I have only one RF remote and that is a problem. It is never near me if I need to control the ventilation system.

Picture of a RF Remote

 

 

screenshot of Home App fan control

Ever since I added some TRÅDFRI bulbs to the Home App I began thinking of controlling my ventilation system with Home App.

Inspired by the blog post of Adrian Philipp I decided to build a RF Remote controlled by Home App myself. He appears to have every needed electric component and some code to programm the IOT hardware. And the best part, he seems to have a proper working solution. Great!! Let’s build this!

Buy the hardware

Adrian documented every hardware component precisely with URL of where to buy them. All of it comes from AliExpress, they are cheap for sure but it takes a little while before the items arrive in your postbox. I am sure you can order them at any IOT oriented reseller too. This could be for instance TMEConrad, SOS solutions or iPrototype. To provide you complete information I will provide the URL’s that I used to order my setup.

The CC1101

picture of a CC1101

Actually, the CC1101 is a component from Texas Instruments. That product alone would be useless in combination with the ESP8266. Just because our SPE8266 board and almost every IOT board can only communicate with other hardware by an SPI. SPI explained. So be warned if you wander around on the Wild West of the Interwebs and stumble upon a CC1101 component. To not buy just a CC1101 component!
This is why we order a CC1101 on a board with a full SPI. It contains other parts to complete the Serial Peripheral Interface. And to be even more precise, we need the 868MHz version of the CC1101.
While some other similar projects use a variation to this board, without the capability to also receive RF signals, make sure to pick a board with the CC1101. This will enable us to expand our features with the ones that need the receiving capability. For instance to update the current fanspeed setting if the normal remote is used.

Optimisation of the project:

picture of CC1101 on pinsI ordered the exact same CC1101 as Adrian, but while building the hardware, I have realised you would be much better off with this version (picture on the right). I haven’t tested this particular version and the table of connections isn’t correct for this version of the solution but I am sure you could get this to work.
The big advantage: it has pins that can be used to plug it into a breadboard and connect to your ESP board by wires. So without soldering at the very tiny copperplates that are separated by 1mm of space! That would speed up this project a lot! As a bonus the documentation of this board is perfect! So if you decide to order this module, make sure you update the table of connections. The correct order can easily be figured out with that documentation.

The ESP8266

the ESP8266

This is the main component that will actually control the CC1101 to send and receive the RF signals. We send commands and receive status updates to and from this board via WiFi.
WiFi is one of the standard features on this board.
Another feature is the USB-to-UART bridge. This feature enables us to program the ESP like any other Arduino device. To use the  USB-to-UART bridge we need to install the Silicon Labs’ CP2102 driver. And the last thing, the Arduino IDE needs configuration to retrieve the ESP8266 Core Libraries for Arduino.

This Wiki page contains more detailed information of the ESP8266 board.

A simple breadboard

Breadboard

You can order any, I have found that mine is a bit big. The function of this board is that we just can plugin boards and sensors. We can connect the pins of the sensors and boards using little wires with pins on them. This helps speed up the building process of prototypes.

A Micro USB cable

The ESP8266 board comes without any cable, you need to connect it to your computer to program it. But I figure everyone has these.

The hardware build process

Our first step is:

Verify programming setup

In this step we will test if we can connect to the ESP8266 board and send a little program to turn on and off the builtin LED.

Plugin the ESP into the breadboard in the way the stripped-out gutter is in it’s heart.
Don’t connect anything else just yet.

  1. Install the Silicon Labs’ CP2102 driver
  2. Install the Arduino IDE.
  3. Configure the IDE with an additional board manager URL.
  4. Connect the ESP board to your computer using the USB cable.
  5. In Arduino IDE go to Tools/Board and under “ESP8266 Modules” select “NodeMCU 1.0 (ESP-12E Module)”.
  6. Again under “Tools” but now into “Port”there should be an item: “SLAB_USBtoUART”, select it.
  7. Now you can open an example file and run the code on your ESP board,
    “File/Examples/ESP8266/Blink” this will open an example code that will turn the LED on and of every one second.
  8. “Sketch/Upload” This will compile the code into a binary code and writes is to the flash memory on the ESP board.

If there are no errors occured and the LED blinks, this test is finished and we can conclude our programming setup is ready for the next step.

Connecting the wires

The wires should be connected to the correct pins and the wires between the pins and CC1101 should be as short as possible. To prevent signal loss solder the wires to the connections on the CC1101.

CC1101 Pin Wire Color CC1101 Pin function ESP8266 Pin Description
1 Red VCC 3V3 Power supply
CC1101 1.8V ~3.6V
ESP8266 3.3V
2 GDO0
3 Green CSN D8 SPI Chip select
4 White SCK D5 SPI clock
5 Yellow MOSI D7 SPI data input
6 Brown MISO/GDO1 D6 SPI data output
7 Blue GDO2 D2 Information output
8 Black GND GND Ground
9 ANT Antenna
10 Black GND GND Ground

Verify correct wiring

Once everything is connected, try to alter the blink code in a way you can confirm that your change is committed to the ESP, chnage it to something like this:

void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is active low on the ESP-01)
delay(500); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(500); // Wait for two seconds (to demonstrate the active low LED)
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
delay(500); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}

view raw
gistfile1.txt
hosted with ❤ by GitHub

Upload the new code and verify everything still works as expected.

If you can’t connect to the port or something doesn’t work as expected, you should check your wires.

Configuring and uploading the final code to the ESP

  1. Download my code using Git or a web-browser from: Github
  2. Once you have downloaded the code you need to open the sketch.ino file in the sketch directory.
  3. Open the Serial Monitor (Tools/Serial Monitor)
  4. Switch back to the editor and edit the values of ssid and password, optionally you can provide your preferred hostname for the ESP.
  5. Upload the code and once it has started, switch back to the Serial Monitor.
  6. Read the text that is printed to the serial monitor.
###### begin setup ######

Connected to IP address: xxx.xxx.xxx.xxx
MDNS responder started
Web socket server started on port 81
###### setup done ######

This means your ESP is now connected to your WiFi network and ready for a WebSocket connection.

You can see the Led flashing. This means RF packets are received from RF Transmitters.
You can press the button on your own transmitter and you will see it flash.

The ESP can print information about all the packets that are received. Set the variable showEveryPacket to true to enable this. This is necessary to find your RFTid.

Find RFTid

  1. Set showEveryPacket to true in the code.
  2. Look at the Serial Monitor and press a button on the RF Remote.
  3. You will see 3 the same messages, with something like “Last ID: 67:a9:6a:a5:a9:a9:9a:56”
  4. This is the RFTid in Hex.
  5. Set the RFTid to this value in the code.
    Example: “const uint8_t RFTid[] = {0x66, 0xa9, 0x6a, 0xa5, 0xa9, 0xa9, 0x9a, 0x56};”

Once you have set this correctly with the ID of your RF Remote the ESP will store the last send command as the current status. This enables the ability to show the correct fan speed in the Home App even if you used the RF Remote.

Pairing / Joining

For the Itho CVE to respond to the new CC1101. The new CC1101 should be paired to your Itho CVE. The procedure to do this is as following:

  1. Pull the plug of your Itho CVE and wait for at least 15 seconds.
  2. Plug the Itho CVE back in the walloutlet.
  3. Within 2 minutes: Reset the ESP, either by pressing the reset button or removing the power from it and plug it back in.
  4. Listen for the CVE to spin up for 2 seconds and down at the time the ESP is starting. If you haven’t heard anything reset the ESP and listen again.

Repeater function

Adjust the value for the repeater variable in code and upload it again.
This function lets the ESP repeat every command it receives from the RF Remote.
This can help expanding the range of the RF Remote.

Until this step everything is the pretty much the same to Adrian Philip his project. The thing I improved is the implementation of the connectivity to Homebridge. His solution isn’t completely documented and finished. Stumbled upon this neat plugin. It implemented WebSockets. I just started using the plugin and made some code changes  to provide the WebSockets workflow. The integration into Homebridge and finally into the Home App becomes much easier and smooth.

Test the Websockets Server

There is a chrome extension called Simple WebSocket Client.
Using this client you can test the WebSockets Server.

Simply type the ipadress that shows up in the serial monitor in the “URL” field plus the port number. example: ws://192.168.1.112:81

Once you press “open” the ESP send the current status:

{"speed":0,"power":false}

In the field “Request” you can type a message in the following same format for example:

{"speed":100}

When you press “Send” the request message is send to the ESP and it will process your command, in this case: is will send a RF command for high fan speed. And it will return it’s new current status. You can try a speed of 50 and/or power off. If everything went well you hear the fan speed up, slow down to medium and finally to low.

Screen Shot Simple Web Socket Client

Configure HomeBridge

In the HomeBridge webinterface open the plugins page.

  1. Search for: homebridge-esp8266-fan
  2. Install it
  3. This plugin comes with a settings page, open the settings page of the plugin on the plugin page, provide a name, the ip-address of the ESP and port (81)
  4. Restart Homebridge

Done!! Homebridge will connect to your ESP8266 and send commands. If you connect the Serial Monitor it will show a line that says “[0] Connected”

Use it!

This is the best part. If you already have added HomeBridge into your Home App the new accessory will show up automatically.

screenshot of the Home App that displays the fan control on the Home page

Press some buttons on your RF Remote and the status will almost directly change to the new state within Home App.

Ofcourse the solution works both ways. In Home App you can press the fan on and off. This will send the high and low signals to the CVE.
To send medium press and hold the fan button and a slider will be displayed. Slide to in between 33 and 66 percent of the slider. The ESP will send the signal Medium speed to the CVE.