-
Notifications
You must be signed in to change notification settings - Fork 664
Add New Remote Part 1
Before you start adding support for your device to the library there are some checks to make: Run the Example receiver programs (Receive Demo Simple and Receive Demo Advanced) that come with the RCSwitch library examples. If you get no output it is worth checking a few common concerns.
- I've had a wireless doorbell not recognised by the sample receiver program. The 433mHz receiver I had did not have a timer crystal. I reran the "receive demo simple" example with a crystal-based receiver the WL101-341/331 and the sample receiver would now detect the transmission correctly. The problem was that the timer on my receiver was not precise enough to receive & decode the signal.
- Upgrade antenna on the receiver and transmitter boards. You can purchase the antenna. You must get the ones for 433mHz or 315mHz they are different! You can make one in a few minutes using a bit of wire! See this PDF or this [Post] (http://www.instructables.com/id/433-MHz-Coil-loaded-antenna/)Many boards come without an antenna and their range can be very limited just a few cms or less. If you have problems receiving a signal using an antenna. For transmission, an antenna can extend the range from within a single room to entire floors of a house the difference is significant
- Check the Power you are supplying to the receiver board and the transmitter some are 3.3V others 5V so check this! The current requirements for receiver and transmitter are very low so that is not likely to be a problem.
- I tend to use the really cheap units for my project - I buy 10 transmitter/receiver pairs for $2.50 on AliExpress / eBay. I have some of the more expensive 3.3v boards and some crystal based boards like the WL101-341/331 useful for edge cases.
- As with all electronic / computer work check that the receiver/transmitter boards are working. It's not unknown to get a duff board or damage a good one by wiring it wrong! So buying a batch of the cheap ones makes sense!
- Try ALL the RF remotes you have in your house, even ones that you do not want to automate. This will let you validate you have working hardware and software, even if its just the example simple receiver.
- Open up the remote for your device and look for parts labelled 433mHz (crystals, stickers, chips, PCBs) or 315mHz. Most units are 433mHz and can be decoded using the standard library. If you have a 315mHz unit change the hardware the software is the same. Check the packing/instructions and look online for your model to see what the specification of the transmitter is.
If you have a remote that is not recognised by RCSwitch and you have checked through each of the concerns above, it may be your remote uses a protocol that is not supported by RCSwitch. This section will explain how to add support for your device to the library its a 2 stage process
- Part1: Grab the codes, decode
- Part2: Updating the library to add your new protocol & check it works correctly with your new remote
- Capture your codes with this: https://github.com/sui77/SimpleRcScanner
- The program counts down grabs a sample, output the sample over serial, then resamples.
- Watch the countdown on the serial output.
- When it gets to 2 press and HOLD the button you are sampling.
- Keep the button depressed until the sample timings appear on the serial output.
- Repeat this process a few times, at least 3 times for each button.
- After this, you will have 3 samples from the Serial Output for each button on your remote.
- In a spreadsheet Enter the Button name and past the serial samples. Label this sheet as RAW DATA.
- Goto http://test.sui.li/oszi/ and past in the 3 samples you have for the first button. You can copy the data from your "RAW DATA" Spreadsheet. As you do this 3 graphs will appear on the web page.
- I had one scan where the waveform that the web page generated using the numbers looked odd, I discarded the data and rescanned this scan looked like the previous scans, perhaps it was some interference. If this happens to you remove the suspect dataset from your "Raw Data" spreadsheet and replace it with a new sample. My samples looked like this...
Serial Capture #1
5... 4... 3... 2... 1...
1200,544,832,384,1380,428,756,472,1324,476,740,476,1312,492,1320,508,692,524,704,516,1272,528,700,524,1268,536,1268,588,584,628,596,624,1176,620,604,620,1176,620,608,612,1184,612,612,612,1188,604,16964,648,584,624,592,620,592,620,596,616,1208,612,600,648,1144,668,552,620,1244,576,632,580,1232,588,624,592,1232,588,624,592,1228,592,620,608,620,580,1220,580,640,588,1196,604,620,604,1196,604,620,600,1192,604,1196,656,556,648,1176,636,584,624,600,620,1180,616,608,616,1188,608,616,608,1184,612,612,608,1188,612,1208,608,604,612,612,608,1188,612,616,604,1192,604,1224,596,612,604,616,604,1196,600,620,604,1192,604,624,600,1196,604,624,596,1196,604,16952,672,544,660,560,652,564,644,568,648,1172,644,572,640,1180,640,576,636,1184,636,580,632,1188,628,588,624,1196,624,592,624,1192,624,592,624,600,620,1176,620,608,612,1184,616,608,612,1184,612,612,612,1188,608,1212,608,604,612,1208,608,608,604,620,604,1192,604,620,600,1204,592,628,596,1208,584,644,592,1184,612,1208,612,608,604,620,604,1196,600,624,596,1200,600,1220,600,612,600,1220,600,616,604,616,600,1200,596,1224,596,616,600,624,596,1204,592,16956,668,552,660,556,652,564,648,572,640,1176,644,572,640,1180,636,580,632,1188,632,584,628,1192,628,588,620,1196,628,588,624,1200,616,596,616,608,616,1180,616,604,620,1180,616,608,612,1188,612,616,604,1188,612,1208,612,604,608,1212,608,608,604,616,608,1188,608,620,600,1196,604,620,600,1196,604,624,596,1200,600,1220,600,612,600,624,600,1196,600,624,600,1200,596,1220,600,616,600,1220,600,612,600,624,596,1200,600,1220,600,616,596,628,592,1200,600,16952,680,540,664,548,660,560,648,572,640,1180,636,576,640,1184,636,576,636,1188,628,588,620,1196,624,596,616,1204,616,604,600,1224,596,620,580,660,564,1228,572,652,568,1228,572,648,580,1212,592,624,596,1188,616,1212,600,628,596,1208,620,584,628,596,624,1176,620,604,616,1180,616,612,612,1184,612,612,608,1192,608,1212,608,608,604,620,600,1196,604,620,600,1196,604,1216,604,612,596,1220,604,612,600,624,600,1196,600,1220,600,612,600,624,600,1200,596,16956,672,544,664,556,652,564,644,572,644,1176,640,576,636,1184,636,580,632,1188,628,588,628,1192,624,592,620,1200,620,592,620,
Reset your Arduino to scan again...
Serial Capture #2
5... 4... 3... 2... 1...
1216,604,604,608,1212,608,604,608,616,608,1192,604,616,604,1196,604,620,600,1196,604,620,600,1200,596,1220,600,616,596,624,600,1196,604,620,600,1200,596,1220,604,612,600,1220,600,612,600,624,596,1200,600,1220,600,612,600,624,600,1196,600,16944,684,544,660,556,652,564,648,568,644,1176,644,572,640,1180,636,580,632,1188,632,584,628,1192,624,588,624,1196,624,592,620,1200,620,596,616,604,616,1184,612,612,612,1184,612,608,612,1188,612,612,608,1188,608,1208,612,608,604,1216,604,608,604,624,600,1192,604,620,604,1192,604,620,600,1196,604,616,604,1196,604,1216,600,612,604,616,604,1196,600,628,596,1196,600,1220,600,612,600,1220,600,616,596,624,600,1200,596,1224,596,616,596,628,596,1196,600,16944,688,540,660,556,652,564,648,572,640,1180,640,572,636,1184,636,580,632,1188,632,584,628,1192,628,584,624,1196,624,592,620,1200,620,596,616,608,616,1180,616,608,612,1184,612,612,608,1188,612,612,608,1188,612,1208,608,604,608,1212,608,608,604,620,604,1192,604,620,604,1196,600,616,604,1196,604,620,600,1196,604,1216,600,612,604,620,600,1196,604,624,596,1200,596,1224,596,612,604,1216,604,612,604,616,600,1200,596,1224,600,612,600,624,596,1200,596,16948,684,540,660,560,652,564,644,572,644,1176,640,572,640,1180,640,576,636,1188,628,584,628,1196,624,588,624,1196,624,588,624,1196,624,592,620,604,616,1180,616,612,612,1180,616,608,612,1192,604,616,608,1188,608,1208,612,604,608,1212,608,608,604,616,608,1192,604,620,600,1192,608,620,600,1192,604,624,600,1196,600,1216,604,612,600,620,604,1196,600,624,596,1196,604,1216,604,612,600,1220,600,612,600,620,600,1196,600,1224,596,616,600,624,596,1200,596,16940,684,544,660,556,656,560,648,572,644,1172,644,572,636,1184,636,580,632,1188,632,584,628,1192,624,588,624,1196,624,592,620,1204,616,596,616,608,612,1180,616,608,616,1184,612,608,612,1188,608,616,608,1188,608,1212,608,608,604,1212,608,604,608,616,604,1196,604,616,604,1196,600,620,604,1196,600,620,604,1196,600,1220,600,612,600,624,600,1192,604,620,604,1196,600,1220,600,612,600,1224,596,616,596,624,600,1200,596,1220,600,620,592,624,600,1200,596,16948,680,540,668,548,656,560,648,572,644,1176,640,576,636,1184,636,580,628,1192,628,
Reset your Arduino to scan again...
Serial Capture #3
5... 4... 3... 2... 1...
576,636,1184,636,580,632,1188,628,588,624,1196,624,592,620,1196,624,592,620,1200,620,596,612,608,616,1180,616,608,612,1188,608,612,612,1188,608,616,608,1188,608,1212,608,608,604,1212,608,604,608,616,604,1196,604,620,600,1192,604,620,604,1192,604,620,600,1200,596,1228,592,616,596,624,600,1200,596,628,596,1196,600,1220,600,616,596,1224,596,620,592,628,596,1200,596,1224,596,616,596,632,592,1204,592,16956,672,544,664,552,652,564,648,568,644,1180,636,576,636,1188,636,576,632,1188,632,584,624,1196,624,592,620,1196,624,592,620,1204,616,596,616,604,616,1184,612,612,612,1180,616,608,612,1188,608,616,608,1188,608,1212,608,608,604,1216,604,608,604,620,600,1196,604,616,604,1196,604,620,600,1196,600,624,600,1196,600,1220,600,612,600,624,600,1200,596,624,596,1200,600,1220,600,616,596,1224,596,616,596,624,596,1204,596,1220,600,616,596,628,592,1200,596,16960,672,540,664,556,648,564,648,572,640,1180,640,572,640,1184,632,580,632,1192,628,584,628,1192,624,592,620,1196,624,592,620,1204,616,596,616,604,616,1184,616,608,616,1180,612,612,612,1188,608,612,608,1188,612,1208,608,608,604,1220,600,608,604,620,604,1192,604,620,604,1192,604,624,600,1196,596,628,596,1196,600,1220,600,612,600,624,600,1196,600,624,600,1196,600,1220,604,612,596,1220,600,616,596,628,596,1200,596,1220,600,616,596,628,596,1200,596,16952,676,540,664,556,648,564,648,572,640,1180,636,580,636,1184,632,580,632,1188,628,588,624,1196,624,588,624,1196,624,592,620,1200,620,592,620,604,616,1184,612,608,616,1180,612,616,608,1184,612,612,608,1192,604,1216,604,608,604,1216,604,608,604,616,608,1192,604,620,600,1196,604,620,600,1196,600,624,600,1196,600,1216,604,612,600,624,596,1200,596,624,600,1200,596,1220,600,616,596,1224,596,616,596,632,592,1200,596,1224,596,616,596,628,596,1200,596,16952,676,540,664,556,648,568,644,572,640,1180,640,576,636,1184,632,580,632,1192,628,580,632,1192,624,588,624,1196,624,592,620,1200,616,600,616,604,616,1184,612,608,612,1184,612,616,608,1184,612,612,608,1188,612,1208,608,608,604,1220,600,608,604,620,604,1196,600,616,604,1196,600,624,600,1196,600,620,600,1200,600,1216,604,612,600,624,596,1200,596,632,592,1196,600,1220,
Reset your Arduino to scan again...
Serial Capture #4
5... 4... 3... 2... 1...
1260,560,660,552,676,544,1256,540,692,528,1264,536,688,536,1256,544,684,540,1252,544,1272,552,664,548,1268,556,656,556,668,556,1236,568,656,560,1236,564,664,560,1232,568,656,564,1224,576,1244,576,644,572,648,572,1224,576,644,580,1220,580,1240,580,632,580,1244,576,632,584,1236,584,632,584,1232,588,632,580,1236,584,632,580,16756,672,544,660,556,652,564,644,576,636,1184,636,580,632,1188,632,584,628,1192,628,588,624,1196,624,592,620,1200,620,592,620,1204,616,596,616,608,612,1188,612,608,612,1188,612,612,608,1188,608,616,608,1192,608,1212,604,608,608,1208,612,604,608,624,596,1196,604,620,600,1196,604,620,600,1200,600,624,600,1196,600,1216,604,616,596,624,600,1196,600,624,600,1196,600,1220,600,612,600,1224,600,612,600,1224,596,616,596,1224,596,620,596,1220,600,616,596,16748,672,540,664,556,652,564,644,576,640,1180,636,576,636,1188,632,580,632,1188,632,584,628,1196,624,588,624,1196,624,588,624,1200,620,592,620,608,612,1184,616,604,616,1180,616,608,616,1184,612,612,612,1184,612,1208,612,604,608,1212,608,608,604,616,608,1192,604,616,608,1192,604,620,604,1192,604,620,600,1196,604,1220,600,612,600,624,600,1192,604,624,600,1196,600,1220,600,612,600,1224,596,616,600,1220,600,616,596,1220,600,612,600,1220,600,612,600,16744,676,540,668,552,656,560,648,568,644,1176,644,572,640,1184,632,584,628,1192,628,584,628,1192,628,588,624,1196,624,592,620,1200,620,596,616,608,616,1180,616,608,612,1184,616,608,612,1188,612,612,608,1192,604,1212,608,608,608,1212,608,608,604,616,604,1196,604,616,604,1196,604,616,604,1192,608,620,600,1196,604,1216,604,608,604,620,604,1196,600,628,596,1200,600,1216,604,612,600,1216,604,612,600,1220,600,616,600,1220,600,612,600,1224,596,620,592,16744,676,540,664,556,652,564,644,572,644,1180,640,572,636,1184,636,580,632,1188,632,584,628,1196,624,588,624,1196,624,588,624,1200,620,592,620,604,616,1184,612,612,612,1184,612,612,612,1188,608,612,612,1184,612,1208,612,604,608,1216,604,608,604,620,604,1192,604,616,608,1192,604,624,600,1196,600,620,604,1196,600,1216,604,612,600,624,600,1196,604,620,600,1200,600,1220,600,612,600,1220,600,612,600,1220,600,612,600,1220,604,612,600,1220,600,612,600,
Reset your Arduino to scan again...
Serial Capture #5
5... 4... 3... 2... 1...
612,600,1220,600,612,600,1224,600,612,600,1220,600,612,600,1220,600,612,604,16740,680,536,668,548,656,564,648,568,644,1176,644,576,636,1180,640,576,636,1184,636,584,628,1188,632,584,628,1196,620,592,624,1196,624,592,620,600,620,1180,616,604,620,1184,612,608,612,1184,616,608,612,1188,612,1204,616,600,612,1208,612,604,608,616,608,1188,608,616,604,1192,608,616,608,1188,608,616,604,1192,608,1212,608,608,604,620,600,1200,600,620,600,1200,600,1216,604,608,604,1220,600,612,600,1220,600,616,600,1216,604,612,600,1220,600,612,600,16740,676,544,664,548,660,556,652,568,644,1180,640,572,640,1180,640,576,632,1188,632,584,628,1192,628,588,624,1192,628,592,620,1196,624,592,620,604,620,1176,624,600,616,1184,616,608,612,1184,612,612,612,1184,612,1208,612,604,608,1212,608,608,608,612,608,1188,608,616,608,1188,608,620,604,1188,608,620,604,1188,608,1216,604,608,604,620,604,1192,604,624,600,1192,604,1220,600,612,600,1220,604,608,604,1216,604,612,600,1220,600,612,600,1220,600,616,596,16740,680,540,664,552,656,560,648,568,648,1176,640,572,640,1184,636,576,636,1184,636,580,632,1192,628,584,628,1192,628,588,624,1196,620,596,620,604,616,1176,620,608,616,1180,616,608,612,1184,616,608,612,1188,612,1204,616,604,608,1208,612,604,608,616,608,1188,608,616,608,1192,604,620,604,1192,604,620,604,1196,600,1216,604,612,604,616,604,1196,604,616,604,1196,600,1220,604,612,600,1216,604,612,600,1220,600,612,600,1220,600,616,600,1216,604,612,600,16740,680,536,668,548,656,564,648,568,648,1176,640,572,640,1180,640,580,632,1184,636,580,632,1188,632,584,628,1192,628,584,628,1196,620,596,620,600,620,1180,616,608,616,1180,616,608,616,1184,612,612,612,1184,612,1208,612,600,612,1212,608,604,608,616,608,1192,604,616,608,1192,604,616,608,1192,604,620,604,1188,608,1216,604,608,604,620,604,1196,600,624,600,1192,604,1216,604,612,600,1220,604,608,604,1216,604,612,600,1220,600,612,600,1220,600,616,596,16744,676,540,664,552,656,560,652,564,648,1176,644,572,636,1184,636,576,636,1184,636,580,632,1192,628,584,628,1192,628,592,620,1196,624,588,624,604,616,1180,620,604,616,1180,616,608,616,1184,612,608,616,1180,616,1204,616,600,612,1208,612,604,
Reset your Arduino to scan again...
Serial Capture #6
5... 4... 3... 2... 1...
1192,608,616,604,1192,608,616,604,1192,604,1216,608,608,604,620,604,1192,604,616,604,1196,604,1216,604,608,604,1216,604,612,600,1216,608,608,600,1220,604,608,604,1216,604,608,604,16740,676,544,664,548,656,564,648,568,648,1172,644,568,644,1180,636,576,636,1188,632,584,628,1188,632,584,628,1192,628,584,628,1196,624,588,624,600,620,1176,620,604,616,1184,616,604,616,1180,616,608,616,1184,612,1204,616,600,612,1208,612,600,612,612,608,1192,608,612,608,1192,604,616,608,1188,608,620,604,1188,608,1216,604,608,604,620,604,1192,604,616,604,1192,608,1216,604,608,604,1216,604,612,600,1220,600,612,600,1216,604,612,600,1224,600,608,604,16736,680,532,676,540,664,556,652,564,648,1176,644,572,640,1180,636,576,636,1188,632,580,632,1188,632,584,628,1192,628,584,624,1196,624,592,620,604,620,1176,620,604,616,1180,620,608,612,1184,612,612,612,1180,616,1208,612,604,608,1212,608,604,608,616,608,1188,612,612,608,1188,608,620,604,1188,608,616,604,1192,608,1212,608,608,604,616,604,1196,604,620,600,1196,604,1216,604,612,600,1216,604,608,604,1220,600,612,600,1220,600,612,604,1216,604,608,604,16736,684,532,672,548,656,560,652,564,648,1172,648,568,640,1180,640,576,636,1184,636,580,632,1188,632,580,632,1192,628,588,620,1196,624,592,620,604,620,1176,620,604,620,1176,620,608,612,1184,616,604,616,1184,612,1212,608,604,608,1208,616,600,612,612,608,1188,612,612,608,1188,608,616,608,1192,604,616,608,1192,604,1216,604,608,604,620,604,1192,604,620,604,1196,600,1220,600,612,600,1216,608,608,604,1216,608,604,604,1216,604,612,600,1220,600,612,604,16736,680,536,668,548,660,556,652,568,644,1176,644,572,640,1180,640,576,636,1184,632,584,632,1188,628,584,628,1196,624,588,624,1196,624,592,620,604,616,1180,620,608,612,1180,620,604,616,1184,616,608,612,1184,612,1208,612,604,608,1208,612,604,608,616,608,1188,612,612,608,1192,604,616,608,1188,608,616,608,1192,604,1212,608,608,604,616,608,1192,604,620,600,1196,604,1216,604,612,600,1216,604,608,604,1216,604,612,604,1216,604,608,604,1216,604,612,600,16740,676,536,668,548,660,560,648,568,648,1172,644,572,640,1180,640,576,636,1184,636,584,628,1188,632,584,628,1192,624,588,628,1192,624,592,620,
Reset your Arduino to scan again...
The generated graphs from the data above are shown here. I've used the horizonal scroll bars to align the start of the data portion of the signal.
In the graph below I have the plot of the ON and OFF command for device 1 on my remote. Notice how they are the **same **for the first part where the only variation is at the end, highlighed in yellow. This is because the format is
<Synch bit> <Manufacturer Code> <Button Code> <Action Code>
As <Synch bit> <Manufacturer Code> <Button Code>
are the same for button 1 the only part that is different is the action: ON Vs OFF
As you can see these numbers from the scanning program provide an insight into the coding in place in the signal. In the next step, we will formalise this understanding.
- For my signal, the encoding is ASK, in particular, OOK, with RZ line coding. So I need one up+down for each bit. From the RAW DATA, spreadsheet copy a single sample and paste it into a new spreadsheet.
- In the new spreadsheet convert the comma-separated list of numbers into a range of cells. (E.g. in Excel Data convert Text to Colum, Delimited, Comma Separated).
- Copy the range of cells and then paste them into a new column transposed (E.g. in Excel Past Special, transpose)
- Finally, sort the numbers from the sample. You will see a few big numbers much larger than the others. In my samples, these values were all just over >16000.
- Working down the sorted numbers you will see larger groups of numbers of roughly the same size. In my case they are all whole number multiples in the data were 1,2 and 28. E.g. the large numbers just over 16,000 were 28 times the size of the smallest number. So what do these 3 type of number mean? We are looking for three types of data
- "Synch" Signal
- "1" Signal
- "0" Signal
Each represented by whole number multiple of the pulse length of 605 µs. 16. So we have identified the encoding
"Synch" represented as 1 high of 605µs and a Low of 28* 605µs = 16,940µs. In the graphs above, most of the "Synch" signal is "silence" (no RF transmission) seen as long gaps on the trace this is the LOW part of the synch bit. The high part of the Synch bit is the last high before the long silence. This is why you must discard the last bit of data before the long silence. That single high followed by 28 lows is what bounds each "cluster" of numbers. If you are wondering this silence plays an important role. It is used by the receiver to detect any noise: Transmissions during this quiet phase must be from another device will interrupt the sync signal. The receiver will wait for the retransmission. It is used to synchronise between data transmissions. I looked for the first long silence, or more correctly the second part of the synch bit and did not consider data in the sample before this as it was the tail end of the previous transmission plus the first part of the synch data. "1" represented by a Low to High of 605 µs to Low = 1 * 605µs transmission "0" represented by a Low to High of 605 µs to Low = 2* 605µs = 1210µs transmission
From this analysis of the sampled date my remote's protocol should look like this:
{ 605, { 1, 28 }, { 1, 2 }, { 1, 1 }, false }
Where
- 605 represents the pulse length in microseconds (µs)
- { 1, 28 } represents the high and low multiple of the pulses that represent a synch bit
- { 1, 2 } the high and low multiple of the pulses that represent a zero
- { 1, 1 } the high and low multiple of the pulses that represent a one
That's the Analysis complete we now have enough to update the library to support this remote. If you want to understand more you can do the further analysis: I pasted the 4 data sample for the Switch 1 ON into a new spreadsheet and decoded the signal being transmitted by the original remote in binary:
1111010101010101101010100101101010100110100101100110 1111010101010101101010100101101010100110100101100110 1111010101010101101010100101101010100110100101100110 1111010101010101101010100101101010100110100101100110
Doing the same for Switch 1 OFF command:
1111010101010101101010100101101010100110100101010101 1111010101010101101010100101101010100110100101010101 1111010101010101101010100101101010100110100101010101 1111010101010101101010100101101010100110100101100110 (Look's like I pressed ON!)
1111010101010101101010100101101010100110100101010101 is 4315972465486165 in decimal
That is how I decoded Switch One and Off. But how did I get from the sampled data to a string of 1s and 0s?
Summary of Spreadsheet Approach used
- Paste capture serial data into Sheet
- Text to Column, comma delimited
- Copy paste generated row of timing data (Transposed to column) -Column D in the example below
- Mask out items before first and last >16000 values
- Label Timings as high and low (Column E) in the example below
- Used threshold logic which evaluates to "0","1" or "" and only rendered 1 or 1 on the Low transition as this is a zero crossing encoding =IF(AND(E51="L",D51>1000),"0",IF(AND(E51="L",D51<700),"1",""))
- Copy the generated bits including spaces
- Paste Values, Transpose, Skip blanks
- Copy resulting row of 1's and 0's into Notepad++
- Strip tabs to get the binary number