August 11, 2011

Family reunion: JeeNode and JeeLink get to talk

So as I said before leaving for vacation, I did receive the jeeLink and JeeNode from ModernDervice. It took a good half hour to solder the jeeNode together.

First Impressions
  The jeeNode PCB has lots of really good little things showing that jcw has an unusual attention to detail. The shape profile of the components is actually printed on the PCB to help position those that are polarized in the correct way. I also dreaded soldering the RF12 and it all went very smoothly, so don't get to worked up like I did, it's a piece of cake. The instructions on the jeelabs site to assemble the jeenode are good but I didn't like the order in which it tells you to solder the components. It should be from lowest to highest profile so can push the components down as much as you can against the PCB. The instructions do say that but then one of the capacitors from modern device actually had a higher profile than the port connectors which made it a little tricky to solder the ports correctly so be warned: the cap should go last.

  Being Arduino, I went straight to download the Arduino IDE. As much as I hate eclipse, I must say that they sure made it simple and straightforward for Arduino first time users! Once you have the IDE running, simply select the COM port your hardware is on and its model and you're in business! Sweet!
OK, not quite, you still need to get the libraries. So, for the JeeNode, you will need 2 core libraries, the rf12 and the ports libraries. You can get them there:

Do check them both out in the arduino "libraries" folder. That is IT!
Having never ever dealt with anything Arduino, I did not know anything about it and certainly did not know what to expect but I somewhat had an expectation of greater complexity.

Making it work: Hello World?
Though I sometimes like the obligatory hello world tutorial, it usually doesn't actually DO anything, which makes it kind of moot unless the environment itself is what you need to get used to. In this case, I think something a little meatier was in order so, since I had a DS18B20 on hand, I decided the better example would actually be to have the jeeNode send the temperature readings from that sensor to the jeeLink attached to my laptop. Maybe later I can make something useful with those wireless readings but at the moment, the intent is mostly to check that a) I did all the soldering right and b) I can wrap my head around the jeeLabs and Arduino goodness.

  I did need help from Google to figure it out but basically, you can find libraries to make your life easier for a lot of common components. That indeed include the Dallas 18B20 I was planning to use. It's a 1-wire component and guess what, there's a OneWire library. And lo and behold, there is even a DallasTemperature library that thinly wraps around the one wire to provide convenience functions around the temperature sensor.

Setting it all up:
 First I had to set the jeeLink up, that means I simply had to give it a node number. You do that by opening a terminal to your jeeLink COM port and simply type '1n'. This set my jeeLink as node 1.
Pretty simple eh? That's because the jeeLink comes loaded with a sketch called rf12demo and it allows for this dynamic configuration.

First test:
 ok so now the jeelink is listening, I will try to load a sketch on to the jeenode and have the jeenode send the temperature readings. The DS18B20 is plugged on to port 4 on the jeeNode but there is a little trick: Port on the jeeNode is like port 3 on the arduino, consequently, when we code to the jeenode, since we do it from an arduino software perspective, our port 4 will really be port 7 in the arduino lingo. Unless you know this, it actually is weird, once you do, well, whatever. So, here's a sketch that sends the temperature:


// Data wire is plugged into port 4 on the JeeNode, since port
// 1 of the jeeNode is really port 3 on the arduino, port 4 on
// jeeNode is port 7 in arduino lingo
#define ONE_WIRE_BUS 7

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire ds18b20 (7);
OneWire oneWire(ds18b20);
char payload[10];
float temperature;

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

void setup(void)
  // start serial port
  Serial.println("Remote Temperature Sensor v0.1a Starting...");

  // Start up the library

void loop(void)
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  sensors.requestTemperatures(); // Send the command to get temperatures
  temperature = sensors.getTempCByIndex(0);
  Serial.print("Temperature: ");
  Serial.println(" C");
  sprintf(payload,"%d", int(temperature));
  Serial.print("Sending temperature: ");
  if ( trySending(payload)){
    Serial.println("Succesfully sent.");
  } else {
    Serial.println("Sending failed 3 times in a row");

boolean trySending(char message[]){
  boolean result = false;
  if (rf12_canSend()){
    rf12_sendStart(1,message,sizeof message);
  return result;

And guess what, we do get the temperature on the jeeLink: yeeehaaaw

Oh no!
 the problem with this sketch is that if rf12_canSend() returns false (which it does every now and then) then nothing gets sent until the next loop, meaning we can lose readings

Second Try
 the solution I found, at least for now, is to implement a retry mechanism like so:

boolean trySendingHarder(char message[], int retries){
  boolean result = false;
  int i = 0;
  while ((i++
  if ( i < retries ){
  return result;

All I have to change now is the call to trySending(payload) to trySendingHarder(payload,3) and it will do the retry 3 times. It has now been running 24 hours and hasn't missed a beat!

I hope this will help someone out there getting started with jeestuff.


  1. hi, i'm new to jeenodes and find this post very usefull. i tried to experiment with it, using the DS18B20 sensor. i used your code above and uploaded it to one of my jeenode. i then uploaded another jeenode with the default rf12demo sketch and left it connected to the pc to receive the readings from the other jeenode. but when i opened the serial monitor i got this readings:

    OK 2 51 48
    OK 2 51 48

    why is it like that? am i doing something wrongly? please please get back to me, really want to get it to display temperature. thanks !

    just in case- my email is

  2. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. get into pc

  3. Take advantage of free trial periods. If possible, always try before you buy. Don't commit to any sort of subscription before you know it's right for you. Many of the larger online music services offer free trial periods. Make sure the program you choose is easy to use and convenient.
    watch here

  4. Free to watch and download all Korean dramas, shows and movies releases in English Subtitles at DramaFast and DramaBus.this website