Jeenode infrared project part 1: getting started

Today I received new Jeenodes, so it’s time for more electronics fun 🙂
One thing that I head in my head for a while was an infrared receiver and sender.
I want it to be like an advanced Logitech Harmony, the main downside on the Logitech Harmony is that there is no status tracking.
What happens if the TV is already on, and your Harmony tries to turn it “on”? (right.. *poof* your TV just got powered off)

So, in my opinion an ideal remote has integration with my home automation system, and keeps tracking of device statuses (I can use Plugwise for example to determine if my TV is powered on or off)
And what to think about turning on the TV on at your preferred time on your preferred channel? (imagine waking up, stepping inside the living room and have the morning news ready for you.. )
Enough introduction, let’s dive into the hardware…

Hardware used

1 x Jeenode
1 x Vishay TSOP 1838 IR receiver (datasheet:
1 x Breadboard
Some jumper cables, to connect stuff around…

Here’s a picture of my initial setup:

Image 1: Jeenode connected to IR receiver module.


I quickly wanted to get started, so I google’ed around a bit.. until I found this nice IR library: (nice work Ken!)
This library provides a few basic IR protocols (NEC, Sony and RC5+6)
There is a test sketch included with the IR library called IRrecvDump which is nice for debugging.
I tested out several remotes I had laying around here (logitech, xtreamer, samsung tv, dreambox sat receiver) unfortunately only the xtreamer remote uses the standard IR protocol.

My main goal is to control my TV so I started ‘hacking’ on that IR protocol first…

Samsung IR protocol

My TV remote is a Samsung BN59-00609A, I had some luck that this remote is included within LIRC ( which has an excellent library of remotes.
“All” I had to do is modify some of the existing IRlibrary code. This took me well over 2 hours 🙁

This is the modified routine to receive the Samsung IR protocol (it looks like an extended NEC protcol):

long IRrecv::decodeSamsung(decode_results *results) {
 long data = 0;
 int offset = 1; // Skip first space
 // Initial mark
 if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) {
 return ERR;

 // Check bits
 if (irparams.rawlen < 2 * SAMSUNG_BITS + 4) {
 return ERR;

 // Initial space
 if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) {
 return ERR;

 for (int i = 0; i < SAMSUNG_BITS; i++) {
 if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) {
 return ERR;
 if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) {
 data = (data << 1) | 1;
 else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) {
 data <<= 1;
 else {
 return ERR;
 // Success
 results->bits = SAMSUNG_BITS;
 results->value = data;
 results->decode_type = SAMSUNG;
 return DECODED;

And here are the used variables:

#define SAMSUNG_HDR_MARK 4500
#define SAMSUNG_BITS 32
#define SAMSUNG_HDR_SPACE 4500
#define SAMSUNG_BIT_MARK 560
#define SAMSUNG_ONE_SPACE 1600

Here is an example decoded button press (on/off button):

Image 2: Example key press in Arduino serial monitor.

According to the LIRC file 40BF maps to:

POWER            0x40BF

Voila! We got a match.
Next up is actually sending out the actual commands for my remote, to completely replace it. To be continued!


Hi, I am Maarten and I am the owner of this weblog. I post on various IT subjects that matter in my life as an IT professional.

Recent Posts