US Home

(Last updated: Thu Aug 24 2017)

Blackbean/Broadlink IR Controller

I picked up a Broadlink RM3 IR Controller. After setting it up with my phone (grrr) I switched over to using Davorf's BlackBeanControl python code. Seems to work up to a point but that's fine as it got me playing. I was able to learn IR codes and send them with no issues. But I soon wanted more, I wanted to be able to receive IR and compare it to the existing library. That's where I begain to run into problems.

First I figured out that the Blackbean Control code couldn't do this. It could send and it could learn but it couldn't really listen. So I wrote my own: Broadlink-RM3-MQTTBridge (a work in progress). I decided to put it into a loop and asked it to learn over and over again. That worked pretty well. But then the next issue appeared. I soon found out that the Blackbean was getting different IR codes for the same key. Hmm, but they did look similar but differe enough that you can't just compare them. A quick look at the python-broadlink Issues page. There it explains a bit about what gets sent to the board. Since it appears that the sent is the same as what is sent we can derive some meanings from their work (thanks folks).

From what I can see, the Blackbean sends raw IR timings. So the code needs further filtering to be translated into equivalent IR key definitions. Something that can be uniquely matched each time. I'm hoping to read up on the various IR encodings to be able to translate this into the proper ones and zeros.


Data for sending an IR/RF command (payload for the send command)

Offset Meaning
0x00 0x26 = IR, 0xb2 for RF 433Mhz
0x01 repeat count, (0 = no repeat, 1 send twice, .....)
0x02, 0x03 Length of the following data in little endian
0x04 .... Pulse lengths in 32,84ms units (pulse_length * 269 / 8192 works very well)
.... ....
.... 0x0d 0x05 at the end for IR only


offset values description
0x00 0x26 - IR as described above, 0x26 for IR, 0xb2 for RF 433, 0xd7 for 315Mhz etc (no RF on the RM3)
0x01 repeats as above
0x02-0x03 pulse lengths as above, Little endian (so 0x30 0x00 = 48 (0x0030) bytes)
0x04+ duration until next change each single byte (zero indicates that the next value is 2 bytes long)

Each of these duration values, represents the duration until the next "change" in IR brightness.

Note: 38khz = 1/38khz sec = 26.3 us (26.9474 us)


Endianess is the byte order of the number in the computer's memory. The number can have any size of bits, but the most common numbers used are 32 bits (4 bytes) and 16 bits (2 bytes).

There are 2 main types of endianess:

Endian Description
Little endian LSB first, little end first, used mostly in Intel machines.
0x30 0x00 0x0030 (48 decimal)
Big endian MSB first, big end first, used mostly in Motorola machines.
0x30 0x00 0x3000 (12288 decimal)


Please note, these notes are a work in progress. They are probably wrong. I tend to scribble things down while trying to figure things out. So if something makes not sense, that probably true.

Work In Progress

 Tivo - NEC - 4 bytes / 32 bits
 Blackbean received:
 Key 2 -
           1st byte                                                       26 (bytes)
 1 2  3    5                                                      28      +
 | |  |    |                                                      +    |  |                           |
 2600 1a00 1d1b 1d1a 1d1a 391a 1d1b 1d36 1d1a 391a 1d1b 1c1b 1d36 3800 0d050000000000000000000000000000
      \LN/ \-------------------------- MSG -------------------------------/
 ........|_| |_

 1a = 26 (bytes follow, includes freq(?) and EOM)
 26   - IR
 00   - No repeats
 1a00 - 0x001a, 26 (22 pairs (44 Bytes) + 2 pairs (4 bytes) for the footer + 2 pairs for EOM)

 1d 1b 1d 1a 1d 1a 39 1a 1d 1b 1d 36 1d 1a 39 1a 1d 1b 1c 1b 1d 36
  s  s  s  s  s  s  l  s  s  s  s  l  s  s  l  s  s  s  s  s  s  x
     0     0     0     1     0     1     0     1     0     0     stop
 3800 - Frequency? (stop bit? just a guess, may be part of the IR signal)
 0d05 - End of Message (EOM)
 00.. - padding (not sure why so much)

 27 * 269 / 8192    

 1d = 0001 1101

Each of these duration values, represents the duration until the next "change" in IR brightness.

   ____   __   _   __   __   _   _   __   _   _   _   _   _
 _|    |_|  |_| |_|  |_|  |_| |_| |_|  |_| |_| |_| |_| |_| |__ ... __
    2.4  1.2  .6  1.2  1.2  .6  .6  1.2  .6  .6  .6  .6  .6  >1.2 (27.0)
  Off period always equals 0.6ms