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
0x0 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.


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 -
 1 2 3    5                                                      28
 | | |    |                                                      +    |   |                          |
 26001a00 1d1b 1d1a 1d1a 391a 1d1b 1d36 1d1a 391a 1d1b 1c1b 1d36 3800 0d050000000000000000000000000000
 ........|_| |_

 1a = 26 
 1d = 29
 36 = 54
 39 = 57 (roughtly  2x the others 1a, 1b, 1c, 1d)

 26   - IR
 00   - No repeats
 1a00 - 0x001a, 26 (22 pairs (44 Bytes) + 2 pairs (4 bytes) for the footer)

 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
 00.. - padding (not sure why so much)

 27 * 269 / 8192    

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