Computing stuff tied to the physical world

The JeeNode, as seen from 15.24 km

In AVR, Hardware on Dec 19, 2011 at 00:01

(that’s 50,000 feet, or 9.47 miles – if those units mean more to you)

This post was prompted by a message on the forum, about what this whole “JeeNode” thing is, really.

Here are a JeeNode v6 and an Arduino Duemilanove, side by side:

DSC 2826

Let me start by saying, tongue-in-cheek: it’s all Arduino’s fault!

Because – let’s face it – the core of each Arduino and each JeeNode is really 95% the same: an Atmel AVR ATmega328P chip, surrounded by a teeny little bit of support circuitry and placed on a printed circuit board. So part of the confusion comes from the fact that the Arduino introduced its own conventions, moving it further away from the underlying common ATmega technology.

The differences between an Arduino Duemilanove and a JeeNode v6 – which resemble each other most – are:

  • the JeeNode has a “skinnier” shape, incompatible with Arduino “shields”
  • the Arduino runs at 5V, whereas the JeeNode runs at 3.3V (this carries through to all I/O pins)
  • the JeeNode includes a wireless radio module, called the RFM12B by HopeRF
  • the Arduino includes an FTDI <-> USB interface, while the JeeNode relies on an external one

There are many other differences, of course – so let’s continue this list a bit:

  • the Arduino’s “eco-system” is far, far bigger than the JeeNode’s (translation: everyone who finds out about JeeNodes probably already knows about the Arduino platform, and usually already has one or more of ’em)
  • this carries through to articles, websites, books, and discussion forums – Arduino is everywhere
  • you can do lots of stuff with an Arduino without ever touching a soldering iron, whereas the JeeNode is really not usable without some soldering (even if just to solder on a few pin headers)
  • different pinouts… it’s one big conspiracy to confuse everyone, of course! (just kidding: see below)

My reasons for coming up with the JeeNode have been documented in the past on this weblog, and can be summarized as: 1) running at 3.3V for lower power consumption and to better match modern sensors and chips, and 2) supporting a simpler form of expandability through the use of “plugs” – little boards which can be mixed and matched in many different combinations.

On the software side, JeeNodes remain fully compatible with the Arduino IDE, a convenient software environment for Windows, Mac, and Linux to develop “sketches” and upload them to the board(s).

The biggest stumbling block seems to be the way pins are identified. There are 4 conventions, all different:

  • Atmel’s hardware documentation talks about pins on its internal hardware ports, in a logical manner: so for example, there is a port “D” with 8 I/O pins numbered 0..7 – the sixth one would be called PD5.
  • Then there is the pin on the chip, this depends on which chip and which package is being referred to. On the 28-pin DIP package used for an ATmega328P, that same PD5 pin would be identified as pin 11. That’s the 11th pin, counting from the left side of the chip with pin 1 at the top.
  • The Arduino run-time library has software to control these pins. For a digital output pin, you can set it to “1” for example, by writing digitalWrite(5,1). This resembles PD5, but it fails for other pins (PB0 is “8” in Arduino-land, and PC1 is “1” if used as an analog input, or “15” if used otherwise – go figure…).
  • The JeeNode organizes several pins as part of 6-pin “Ports” (no relation to Atmels terminology!), each of them having 1 digital and 1 analog-or-digital pin.

The thing about JeeNode Ports is that there are 4 of them, and they can all be used for plugs in the same way. To support this, there’s a Ports library which lets you define port objects. This is an abstraction layer on top of the Arduino runtime. The reason is that it lets you associate a port object with a header on the JeeNode:

    Port myport (2);

Then you can connect your hardware / sensor / plug / whatever to the header marked “P2” on the JeeNode, and access it as follows:


This happens to be the same pin as in the examples above, i.e. PD5 of an ATmega, pin 11 of the 28-pin DIP chip, and digitalWrite(5,1) on an Arduino. This also means that there are numerous ways to perform the same action of setting pin 11 of the chip to a logical “1” (i.e. 3.3V or 5V):

  • the “raw” C-level access, using Atmel’s register conventions and definitions (fastest, by far):

        PORTD |= 1 << 5;  // or ...
        PORTD |= _BV(5);  // same thing
        bitSet(PORTD, 5); // same thing, using an Arduino macro
  • the Arduino way of doing things:

        digitalWrite(5, 1);
  • the JeeNode Ports library way of doing things, as shown above:

        Port myport (2);
  • … let’s throw in an extra bullet item, since every other list in this post appears to come in fours ;)

The one (minor) benefit you get from using the Ports approach on a JeeNode, is that if you attach your hardware to a different port, say port 3, then you only need to change a single line of code (to “Port myport (3);” in this case). The rest of the code, i.e. everywhere where its pins are being read or written, can then remain the same.

For an overview of all pinout differences, see also this weblog post. For full details, see the JeeNode PDF docs.

  1. I feel this was written just for me – Thank you jcw!

  2. This is THE example of ‘If only I learnt this in my first meeting with JeeNode’. I think you should push this posting to the top of the list introducing the JeeNodes.

  3. Excellent overview, much needed! I’ve been struggling with all the different ways to access the analog / digital ports!

    One question: is there a difference in efficiency / performance between the various ways to address a port?

  4. I’m curious as to which part was most useful to you folks…

    If it’s the code to access pins: Use The Source, Luke… maybe a follow-up post on where to find such details in the code (both Arduino run-time and JeeLabs libraries) would be useful?

    • Excellent post, thanks. Many of the differences Arduino v. Jee do not affect me. I understand the off-board FTDI (like a Nano), and I’ve assembled many push through kits and a few SMD ones.

      I am not coming at this from a Home Automation angle, as I do not own a house currently, but I know folks who have 10 years worth of Home Automation parts (Crestron, etc) and it sounds appealing.

      For me I’m mostly after the general purpose aspect: wanting a barebones board but with the built-in radio, and I’m a little earlier on the learning curve so I am still following Arduino tutorials which are completely step-by-step (so enlightenment could happen midway or after the lesson is completed ).

      I know what to look for now, so I’ll revisit some tutorial’s I’ve completed, and run through them again (and probably understand them better once I’ve adapted it to the Jee). Thanks again!

    • Yes, for me it’s mostly port access. It’s quite confusing – AVR pins, names, Arduino numbers, Jee ports – all different. One particular example: pins that can be accessed in Digital or Analog fashion – why does the same physical pin have different Arduino names? aargh ;-)

      I can see how C access is fastest for digital IO – probably not so easy for Analog IO…

      I’d love more high-level posts like this, as well as a ‘walkthrough’ of the major bits of source code…

      Thanks for your efforts, it’s a fun learning experience ;-)

  5. I’ve found most of the chips and sensors I need to use are 5v, not 3v, but if I need 3v logic, there is a chip to convert. Also, I set my pin definitions at the top of my sketch on a Arduino, so I only have to change one line to change pins, so the “minor” Jeenode advantage really isn’t any different.

    • You can use 5v stuff on JeeNodes pretty easily. The normal trick is to put a pair of resistors on the outputs from the 5v device to drop the output level down to 3.3v. The links that go the other way, the outputs from the JeeNode go direct to the device. The 3.3v level logic is usually fine (most 2v devices will happily see anything over 2.5v as a logic high).

      You’ll still need to supply 5v to the device for its logic though.

  6. For those looking for more info on direct manipulation of AVR ports, see also (I’m assuming another blog mention is OK w/ JCW).

  7. I’m assuming another blog mention is OK

    Of course!!! Good one, btw – thx.

Comments are closed.