Skip to content

Add_New_Remote_Part_1

Martin-Laclaustra edited this page Aug 17, 2018 · 16 revisions

Adding a new Remote...

Before you start adding support for your device to the library there are some checks to make:

  1. Check that your receiver receives signals (it is wired to the correct pin, etc.). Use the script at https://github.com/sui77/SimpleRcScanner/tree/master/htdocs for your hardware. Check the wiring if you see only 0s. At least there should be some noise in the band. (This program may be useful later)
  2. Run the Example receiver programs (Receive Demo Simple and Receive Demo Advanced) that come with the RCSwitch library examples. This will output results only if the protocol of your device matches one of the default list in the library. If you get no output it is worth checking a few common concerns.

Checklist (Before Starting)

  1. The band (frequency) of your receiver must match your remote. Open up the remote for your device and look for parts labelled 433mHz (crystals, stickers, chips, PCBs) or 315mHz. Most units are 433mHz. If you have a 315mHz unit make sure that your receiver (and transmitter if you aim to mimic the signal) use the same frequency. Change the hardware if necessary. Both can be decoded using the standard library. The software is the same. Check the packing/instructions and look online for your model to see the transmitter specification.
  2. 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.
  3. Install / 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 use 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. Antenna also improve reliability in marginal situations.
  4. I tend to use the really cheap units for my project - I buy 10 transmitter/receiver pairs for .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.
  5. 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!
  6. 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.
  7. 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.

A word about the cheap transmitter-receivers: They work really well and are very reliable. For most modern remote control RF sockets and lights they work fine. I have 30+ plugs and many lights in my house brands include Status, Funry, Sonoff slampher, ProElec. They all work perfectly with the cheap transmitters and receivers. I only have one device that needed the crystal based timer - a doorbell. I suspect the higher tolerance might be to prevent false positives on the doorbell.

Overview of Approach

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: If the number of data bits of your protocol is less or equal to 24 bits, you can use the library without modification. See below. If not, you will need to modify it (see part 2). You can also update the library to add your new protocol to the list of protocols. In any case, the last step is always to check if it works correctly with your new remote.

To use you new protocol without modifying the library, include these in the setup() function:

static const RCSwitch::Protocol customprotocol = { 360, {  1, 23 }, {  1,  2 }, { 2,  1 }, false };
mySwitch.setProtocol(customprotocol);

Adding a new Remote

  1. Capture your codes with this: https://github.com/sui77/SimpleRcScanner
  2. The program grabs a sample during count down and output the sample over serial, then you can repeat the process.
  3. Watch the countdown on the serial output.
  4. When it gets to 2 press and HOLD the button you are sampling (or keep it pressed the whole time).
  5. Keep the button depressed until the sample timings appear on the serial output.
  6. Repeat this process a few times, at least 3 times for each button.
  7. After this, you will have 3 samples from the Serial Output for each button on your remote.
  8. In a spreadsheet Enter the Button name and paste the serial samples. Label this sheet as RAW DATA.
  9. Goto http://test.sui.li/oszi/ and paste 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.
  10. I had one scan where the waveform that the web page generated using the numbers looked odd, I discarded the data and rescanned... this new scan looked like the previous (good) 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. image

These plots do not show it, but ideally you should inspect also including the beginning of the next signal repeat. The gap, and characteristics of the pulses around the gap are also important!

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.

image

  1. For my signal (And the signals rcswith can deal with), 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.
  2. 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).
  3. Copy the range of cells and then paste them into a new column transposed (E.g. in Excel Paste Special, transpose)
  4. 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.
  5. 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 (there might be 4 groups instead of 3). E.g. the large numbers just over 16000 were 28 times the size of the smallest number. So what do these 3 types of number mean? They are lengths during which the transmitted signal must stay high or low. We are looking for three types of bits, each composed by 2 of these lengths:
  • "Synch" bit
  • "1" bit
  • "0" bit

Each represented by a pair of whole numbers, as the duration of their two levels is multiple of the basic one, called pulse length in this library, and that in my case was 605 µs. 16. So we have identified the encoding.

Pulse length (in this library) is a concept that allows simplifying the "formula" for the encoding: It is roughly the greatest common divisor of the different durations identified previously. That way, those durations can be described with simple integer small numbers, multiples of the pulse length. In practice: in excel: a) sort the durations; b) identify the groups; c) use the function "average" to average the durations within each group; d) approximate the greatest common divisor; e) check that the pulse length multiplied by the simple numbers roughly reproduce the initial timings.

"Synch" represented as 1 high of 605µs and a Low of 28* 605µs = 16940µ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 "high" in the train before the long silence when you manually "decode" each of the signal that it sent when pressing each button of your remote. That single high followed by 28 lows is what bounds each "cluster" (or train) 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 and 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. WARNING: Modern remotes use more complex inter-data sync signals. Rcswitch can not deal with those kind of signals (e.g. 2 syncs bits, that may be equal or different, or a gap, followed by a train of short up-downs, followed by a second gap). If that is your case, your only chance is to use a modified rcswitch version that allows re-playing fixed sequences. "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

image

From this analysis of the sampled date my remote's protocol should look like this: { 605, { 1, 28 }, { 1, 2 }, { 1, 1 }, false }

Where

  1. 605 represents the pulse length in microseconds (µs)
  2. { 1, 28 } represents the high and low multiple of the pulses that represent a synch bit
  3. { 1, 2 } the high and low multiple of the pulses that represent a zero
  4. { 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. The library (receive demos) will the tell us what are the codes that each button sends. But you can also get those codes manually: 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

(Note that these codes are far longer that most common codes, which are 24 bits. These long codes do not work with the library out-of-the-box and we need some more tweaking of the library in order for them to work, see later)

That is how I decoded Switch 1 On and Off. But how did I get from the sampled data to a string of 1s and 0s? This is a Summary of Spreadsheet Approach I used:

  1. Paste captured serial data into Sheet
  2. Text to Column, comma delimited
  3. Copy paste generated row of timing data (Transposed to column) -Column D in the example below
  4. Mask out items before first and last >16000 values
  5. Label Timings as high and low in alternating rows (Column E) in the example below (as this is a return to zero (RZ) encoding)
  6. Used threshold logic which evaluates to "0","1" or "" and only rendered 1 or 1 on the Low transition (you can see above that in my case only the low length differs between "0" and "1") =IF(AND(E51="L",D51>1000),"0",IF(AND(E51="L",D51<700),"1",""))
  7. Copy the generated bits including spaces
  8. Paste Values, Transpose, Skip blanks
  9. Copy resulting row of 1's and 0's into Notepad++
  10. Strip tabs to get the binary number
  11. Use an on-line binary to decimal converter to get decimal values as needed