Caprice ceiling fan voice control - Part 1 of 2
The Mission
To enable voice control for the fans and lights of our new Mercator Caprice ceiling fans.The Steps
Step 1. Figure out the radio frequency (RF) commands for the fansStep 2. Set up an RF sender on one of my Raspberry PIs
Step 3. Develop a script to control the fan
Step 4. Configure voice control via Alexa
Step 1 - Determine the RF commands
I purchased a DVB-T 820T2 radio tuner. Like this one on ebay.I used my Windows desktop, and installed the USB dongle and the Universal Radio Hacker (URH) software from here. (These would work on my Raspberry Pi3, but required quite a bit of memory and were a bit slow).
1. Determine fan radio frequency
I fired up the URH Spectrum Analyzer.I knew the fans were likely be around 433 MHz or 315 MHz.
Once running press a button on the remote, I could see a signal spike.
Ok so close to 433 Mhz.
2. Analyse and decode the signals
This probably took the longest amount of time, but decoding the signal was pretty fun.This time I started the URH Record Signal function.
I recorded the stop and light buttons on two of my remotes (for different fans).
This was to get enough information to compare the commands from the different remotes and determine the header and command information. I expected the signal to be structured something like:
[fan_id][command][end]
fan_id - identifies a specific fan
- command - the command to send, e.g. toggle the light
- end - Some sort of pattern to indicate the end of a command
Below shows 4 button clicks.
Helpfully URH does some useful analysis, detecting the modulation (ASK in this case) and takes a punt on the bit length - 300 ns in this case. (How long a on or off bit is in nano-seconds). It also then decodes the radio signal from an analog signal into a digital representation, i.e. a 0 or a 1.
If you zoom in on a click you'll see it basically repeats the same pattern a number of times depending on how long the button was pressed for.
Let's take a closer look.
So it's pretty straight forward:
No signal (off) = 0
A signal (on) = 1
And each individual 0 and 1 is evenly spaced (i.e. it lasts 300 ns).
So ignoring the no signal at the start this looks like:
100 101 101 101 100
This matches URH's analysis shown in the picture.
Note: In some cases URH guessed the wrong length, so I had to adjust it manually.
Great - so we now have a bunch of 0's and 1's to make sense of.
3. Determine the command signals
Ok so here is the toggle light and stop commands for fan A, and fan B.I recorded all the commands for fan A to look at the patterns.
The result was I could divide the bits into the following.
<fan_id: Fan A or B> <command: light> <end>
100101101101100101101101101100101101101101100101 101100100101101101 1011011
101101100100101101100101100100101100100100100101 101100100101101101 1011011
<fan_id: Fan A or B> <command: stop> <end>
100101101101100101101101101100101101101101100101 101101100101101101 1011011
101101100100101101100101100100101100100100100101 101101100101101101 1011011
Looking in more detail we can see the signals repeat the pattern 100 and 101.
So assuming 100 = 1 and 101 = 0 we can simply the commands a bit further.
<fan_id> <command> <end>
1000100001000010 011000 001
0011001011011110 011000 001
1000100001000010 001000 001
0011001011011110 001000 001
- Fan Identifier = 16 bits (65,536 possibilities - this aligned to the manual that sates 65,000 possible unique ids)
- Command = 6 bits
- End = 3 bits
#Commands cmd_stop='001000' cmd_light='011000' #light toggle cmd_breeze='011100' cmd_mode='110100' #reverse cmd_s1='110000' cmd_s2='100110' cmd_s3='010000' cmd_s4='010100' cmd_s5='100101' cmd_s6='100000' cmd_off='111100' #light and fan off cmd_on=cmd_s3
Note: I tested all possible command combinations and found one very useful command which turns the fan and light off.
Step 2 - Set up an RF sender on one of my Raspberry PIs
I purchased a RF wireless sender and receiver like the following.I only used the sender (the 3 pin item on the left).
I connected this and connected the data pin to GPIO pin 22 on the Raspberry Pi3.
You can find plenty of information online on how to do this.
I also made a simple antenna from some Cat 6 wire, you can see this below.
Steps 3 and 4 are continued here.
Comments
Post a Comment