In part 1 of this series I blogged about receiving infrared signals using an IR led. This blog post will focus on getting the signals up in the air (and off course receiving them on the other side, in my case my home automation server with a Jeelink attached)
The Jeenode’s have a HopeRF wireless receiver/transmitter on board, which makes life easy.
Jeelabs provides a RF12 library for really easy sending over the air, the receiver in my case is a Jeelink (which is basically a Jeenode but in nice small USB stick format)
I modified my existing source code to enable wireless transmitting:
/* * mdIR - IR interface for home automation. * Version 0.1 May, 2010 * Copyright 2010 Maarten Damen * http://www.maartendamen.com */ #include <RF12.h> #include <Ports.h> #include <IRremote.h> int RECV_PIN = 4; IRrecv irrecv(RECV_PIN); MilliTimer sendTimer; byte needToSend; decode_results results; long unsigned int sendbuf; struct { byte decode; // IR decode } payload; void setup () { Serial.begin(57600); Serial.println(57600); Serial.println("mdIR started..."); rf12_config(); irrecv.enableIRIn(); // Start the IR receiver } void loop () { if (irrecv.decode(&results)) { needToSend = 1; sendbuf = results.value; Serial.println(results.value); Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value } /* TODO: rf12_canSend doesn't work if I remove this... (needs to check incoming packets?) */ if (rf12_recvDone() && rf12_crc == 0) { } if (needToSend && rf12_canSend()) { needToSend = 0; Serial.println("need to send"); rf12_sendStart(0, &sendbuf, sizeof sendbuf); } }
Here’s a screenshot of my Jeelink receiving the packets send by the Jeenode receiving the infrared signals:
Image 1: Jeelink receiving IR signals send by another Jeenode. Notice the different buttons pressed.