Computing stuff tied to the physical world

Flashback – Ports and I2C in JeeLib

In AVR, Software on Oct 2, 2013 at 00:01

One of the small innovations in the JeeNode is the use of “Ports”:

ports

Most ┬ÁC boards, including the Arduino, brought out all the I/O pins on one or more large headers, meaning that you had to pick and route individual pins for each case where some component or sensor was being connected. While flexible, it prevented adding stuff in a plug-an-play manner: hook up some sensors, use matching bits of C/C++ code, and done.

I also always kept running out of VCC and GND connection pins while experimenting. So instead of bundling all I/O pins, a decision was made in 2009 to bring out a couple of (nearly) identical “ports”, to any of which the same sensor could be attached. That meant you could connect up to at least four sensors independent of each other.

As it turns out, there are enough spare I/O pins on an ATmega to provide one digital and one analog pin to each port. Add GND, VCC (+3.3V) and PWR (the input voltage, could be up to about 13V), and you end up with a fairly general-purpose setup. One extra spare pin was provided as “IRQ” to allow connected sensors to draw attention to themselves via an interrupt, although this feature has admittedly so far not been used much on JeeNodes.

But the real improvement is the fact that the two I/O pins can be used as I2C bus. All of a sudden, each port is no longer limited to a single sensor. The I2C bus is so useful because many types of low-cost chips include an I2C interface in hardware, and it lets multiple chips operate on a single bus.

One of the first extensions added was the Expander Plug, an 8-bit general-purpose digital I/O interface. So now, with just two pins consumed on the ATmega, you could have up to 32 input/output pins (by daisy chaining 4 of these plugs and setting them each to a different I2C address). The Dimmer Plug takes this even further: up to 8 of them on one bus, each driving up to 16 LED’s – for a total of 128 dimmable LEDs on 2 I/O pins!

Officially, the I2C bus requires dedicated hardware with “slew control” to increase the accuracy of signals on the bus. And while the ATmega has such an interface, there is just one per ATmega. Fortunately, you can also “bit-bang” I2C in plain software, i.e. simulate the relatively slow pin changes with nothing but software on any 2 I/O pins. The speed is not quite as high, and the supported bus length is also limited to a few dozen centimeters, but for direct connection of a few plugs that still works out quite well.

And so the JeeNode has ended up having 4 “ports”, each of them individually capable of supporting either I2C, or one analog (AIO) and one digital (DIO) pin – or alternately 2 digital I/O’s, since each analog pin on the ATmega can also be used in digital mode.

Since then, lots of different types of “JeePlugs” have been created, some I2C, some not. Most of the plugs have a corresponding class and a demo sketch in the JeeLib library, making it very easy to hook them up and interface to them in software. With most plugs, you just have to define which port they are connected to – and in the case of I2C plugs, which bus address they have been set to.

The placement of these ports and the choice of very low-cost standard 6-pin headers took some experimentation, but I think it all turned out ok. Lots of expandability and flexibility.

  1. I think the fact that other websites offer products with jeenode compatible headers is testimony to success?

  2. Perhaps you’ve already mentioned this point, but your decision to go with open source hardware and software licenses was huge, in my opinion. Thank you!

  3. OK. I’ve been reading your postings daily. I wish to try out JeeNodes. Should I buy two SMD JeeNodes? I am on the west coast of the US. Where should I buy? Thank you.

  4. @Margaret,

    The choice depends on if you want to start with a full kit (you have or wish to learn soldering skills) or a pre-assembled node that just needs headers soldering on in the configuration you need.

    For the latter – the JeeNode USB (or the JeeNode SMD if you already have a USB/FDTI device for loading in the sketches) is a good starting point.

    You will get faster delivery and no hassles with Customs/Import taxes if you order from the JeeLabs Shop sister organisation on the East Coast – Modern Device. They currently offer free shipping over the weekend.

  5. Hello and thank you for your response. Couple of things: = the Modern Device link gives a 404. I assume this is a link to the JeeNode products? = the Modern Device web site notes “from $4″ what does this mean? Why does it say from a low $ point and then the price is something like $22. I am interested in the intent here because it doesn’t make any sense. = thinking about the options (great to have so many!) I’d like to solder my own. Would this be the right product? http://moderndevice.com/product/jeelabs-rfm12b-board-kit/ = i apologize if i should know this- what are the advantages / disadvantages of 433 versus 915? (if you have a link that details please let me know)

    again – thank you very much.

  6. @Margaret,

    Fixed the link, thanks. The RFM12B board kit is just the radio module for plugging into an existing processor board that lacks radio capability. You need to look at the JeeNodes or JeeLinks that are both processor and radio.
    Please contact order_assistance @ jee labs.org if you are unsure about the configuration to use.

    The higher ISM band (915MHz in your case) has better results passing through walls for room to room connections and is often less crowded with other traffic than the 433MHz band. Many vendors though use 433MHz (e.g. common weather stations) so perhaps think about other devices you may wish to connect with in the future.

  7. Margaret,

    The RFM12B board is a great way to connect to other Jee modules if you already have a large collection of Arduinos. It would even be possible, if a bit more fuss, to use all the plugs with traditional Arduinos. That said, the JeeNode is the through-hole, solder it together kit.

    You’ll also need some kind of FTDI cable to connect with this – a lot of different open source shops have their versions, the one at Modern Device is the USB BUB 2.

    The rest of JeeLabs pantheon is listed here.

    JeeLink – JeeNode module that plugs into usb, no ports

    JeeNode USB – like the JeeLink but with four ports, no BUB required

    JeeNode SMD – An “assembled” surface mount module, you just have to solder antenna and headers.

    I’ll second Martyn’s comments about less interference on 915Mhz than 433Mhz, but as he said, give some thought to the direction you’re heading.

    Paul Badger, Modern Device

Comments are closed.