Wednesday, March 30, 2011

Applications for the Nanode

Having now built up the first pair of Nanode boards it's time to test them out and then start to develop applications.

The first thing on the list is to test the basic ethernet connection, and ensure that the boards can communcate with Pachube, which I am using as a brokerage service to broker messages and data between Nanodes.
As described in a prevous post, one Nanode will publish data up to a Pachube feed, and the other Nanode will subscribe to that feed at regular intervals, and print out the data to the serial port.
Here are the two boards each connected to a network port. The orange and brown wires between the boards is so that they can share the 5V power from the FTDI cable.

The upper board is the Publisher (Putter) and the lower board is the Subscriber (Getter). Every few seconds the Putter sends a new packet of data up to Pachube feed 8729, and at regular intervals the Getter subscribes to this feed to retrieve the data. In this case the data is a simple comma separated list of 6 arguments, which could be six readings from the ADCs on the Putter device, or a numerical command to which the Getter will respond.

Tuesday, March 29, 2011

Nanode 5 - Just Make It!

Nanode is a very low cost internet connected microcontroller board - compatible with the Arduino programming environment. It allows applications for internet remote monitoring and control to be developed on a familiar low cost platform, such as web servers and clients or for data exchange and control using services such as Pachube.

You can keep updated on the Nanode Project at the official website and also on the Hackerspaces Wiki.

The EagleCAD schematic and board file have been uploaded to my Thingiverse account. Here's how to build a Nanode - takes about 90 minutes.

Follow the Pictorial Guide on the London Hackspace Wiki for full instruction of the Build Sequence.

Nanode - It's a Bit Small Isn't It?

Here's the first of the prototype Nanodes built up, tested and working. The Nanode can be used with a variety of Arduino shields, but you may have to use extended stackable headers like these from Cool Components to give extra clearance between the shield and the Magjack. Using the local serial bus, it is possible to connect Nanodes together using 4 way telephone cable in a Master/Slave Network. It is likely that the Master device will be the one with the internet connection, and the slaves are used for specialist tasks such as pulse counting, electricity monitoring, controlling relays, measuring temperatures etc. In this case, you might wish to create a simple user interface on the Master device, possibly by fitting a display, such as the NuElectronics Nokia 3310 shield as shown below.

Nanode - Just Make It!

Pachube Internet of Things Hackathon

Just 9 days to go until Pachube hosts the first global Internet of Things Hackathon - a 24 hour event commencing in London and with sister events happening in several different countries.

In preparation for the event, to provide suitable web connected microcontroller hardware - I am putting together a small batch of Nanodes - a low cost target board designed for Internet of Things sensor applications and built to be compatible with Arduino technology.

For under £20, the Nanode offers a platform to develop intelligent sensor network node applications, capable of communicating via the Internet and Pachube or locally with other nodes on a low cost wired serial network. It can act as a web server, a web client or communicate with other web connected Nanodes using a publisher/subscriber messaging protocol.

Nanodes can also be connected together using a simple "multidrop" serial bus - made from low cost telephone extension cable. This carries power and data and allows Nanodes to be distributed around the home for tasks such as home heating control, home automation and energy (electricity and gas) monitoring.

Slave Nanodes can be cheaper still, by not fitting the ethernet components, yet still communicate with a master device connected to the internet.

Last summer, a pair of early prototype Nanodes successfully communicated with each other using Pachube as a publisher/subscriber service for short messages. A message left on the Pachube feed by one Nanode, would be picked up by a second Nanode which subscribed to that feed, decoded and used to perform some local action - such as switching a relay or changing colour on a RGB LED lamp.

For the example of the RGB LED, the publisher would send a short message consisting of comma separated arguments to Pachube b,1,255,255,255 This would be interpreted by the subscribing Nanode as a command to set the brightness (b) of the red, green and blue PWM channels of the LED (number 1) to full brightness (255) resulting in a white colour.

The publishing Nanode might have a temperature sensor connected to one of its analogue inputs, and change the arguments of the brightness command according to the temperature. Any Nanode subscribing to this feed, and equipped with the RGB LED would change the colour space accordingly in response to temperature.

This is a trivial example of how two Nanodes can communicate via Pachube. The publisher pushes the message, with no regard to whether it is received or acted upon. It might be possible to use a second Pachube feed as a "back-channel" to allow the publisher to be informed if the message has been received and acted upon.

At the Hackathon it is hoped that we have 5 pairs of Nanodes distributed around the country at various sister events - Nottingham Hackspace,, North Wales, London Hackspace, Thatcham and at Pachube's own event.

Anyone with an Arduino and NuElectronics Ethernet Shield, could participate with nearly the same firmware. Following that, the intention is to make a batch of 100 boards and offer them at discount to interested parties. Bare boards will be offered at £5, and complete kits for under £20.

Saturday, March 26, 2011

Pubbers & Subbers, Putters & Getters, Movers & Shakers - and Purple Hearts!

Sometimes the best made plans fall apart - due to circumstances beyond one's control. As a result of missing the postman at 8:13 this morning, my component order has gone back to the Royal Mail depot - and not retrievable until 7am on Monday morning - doh. Time to get a louder doorbell!

That rather put a kybosh on any new hardware developments this weekend. Instead, I thought I'd dust down some of the hardware I developed for the prototype ethernet node back in August last year and get re-aquainted with firmware which allows it to communicate via Pachube.

The first Arduino/Ethernet node was built on breadboard from 3 ICs (Atmega328, ENC28J60 and 74HC125) and about 35 other components. With a little care, the design will fit on a single standard, 63 strip breadboard, and cost about £12 in components to make. The Nanode is just a compact PCB version of the original prototype, designed with through hole components to make it easy to build at home.

Firstly, I thought I'd look back over the simple Publisher/Subscriber code I wrote for the prototype Nanodes about 8 months ago and have a go at getting the breadboard ethernet hardware running again - see above.

The strategy is based on the simple model that one ethernet connected device publishes a string of data to a Pachube feed, and that multiple nodes can subscribe to that feed and make use of the data.

The simplest Pachube feed is a comma separated array of values (CSV), so the publishing device - the "Putter" has to put out a CSV string of arguments, and the subscribing device, the "Getter" has to be able to subscribe to the given Pachube feed and get the CSV data into a form where it can do something with it.

I have dusted down the "Etherduino" breadboarded ethernet connected Arduino ( see August 2010 posts for details) - and this is acting as my "Getter". A standard Arduino and ethernet shield is acting as the "Putter".

The first test is to ensure that a simple message of say 6 comma separated arguments can be passed seemlessly from putter to getter. So far, so good - my getter is printing out the serial CSV string to my monitoring serial port every few seconds. Now to come up with an interesting demonstration application which involves some moving and shaking.

Back at Homecamp in April 2009, I showed a very simple use of a radio control servo with a coffee-stirrer glued to the servo arm, which was used as a large scale analogue meter. The Arduino can drive the arm to any angle from 0-180 degrees, and use the coffee-stirrer pointer to point to any chosen value on an A4 sized graphic. The great thing about servos is that they buzz when they move, and this attracts one's attention to the fact that something is changing.

Another easy hack is the use of low cost LED lamps to make colour changing "ambient orbs" to visualise a physical parameter - such as temperature or electricty consumption. A recent sale at Homebase and I bought 4 lamps for £10, including Heart, Orb, Cube and Star. From chilly blue to toasty red orange, and optimum green when the room temeperature is at its best.

A combination of the servo and RGB LED "ambient orbs" might be a good set of visual demos for the forthcoming Pachube Hackathon.

Saturday, March 19, 2011

Nanode - A Net Applications Node

Nanode - a £20 Network Applications Node for remote sensing projects.

Having worked with Arduinos for a couple of years, I was keen to extend the functionality and scope of the basic Arduino to include the ability to be networked with other Arduinos or devices via the internet or a local serial network - as the communication to the Arduino is fundamentally serial.
The opportunity came with the low cost NuElectronics Ethernet Shield, which provided an ENC28J60 ethernet controller and a Magjack for about £12, however by the time you had added an Arduino (and 20% VAT), the cost was approaching £40. The simplicity of the hardware was such that I reckonned that there must be a much cheaper way of getting internet connectivity - and thus the Nanode was conceived.

Combining an Arduino microcontroller and ethernet controller onto a single small board for developing networked sensor applications at minimal cost seemed an attractive proposition reducing the cost of net connectivity for microcontrollers by a factor of 2 - to an affordable £20!
The Nanode takes the standard ATmega328 microcontroller - as used in all the standard Arduinos, and combines it on a single board with an ENC28J60 ethernet controller and Magjack.

This was not the first time this had been done, Tuxgraphics produced the first one about 5 years ago as detailed in this article, and there was a very capable design on Instructables a couple of years ago. Indeed, almost all of the firmware for the ENC28J60/ATmega combination is derived from the original Tuxgraphics code.

So Nanode is not new, it owes its heritage to at least two previous designs, but it does introduce some new features which I hope will bring it more into the Arduino playground. Unlike previous designs it presents its I/O in a form which is compatible with Arduino shields, but also enhances the I/O capability with additional connectors - making the I/O more accessible when a shield is fitted and allows the device to be plugged directly into a breadboard and still access all of the power and I/O.

So after the initial idea was hatched, I had to make a prototype. I'd had a bit of prior experience breadboarding ethernet, so last August I combined the Microchip ENC28J60 ethernet controller and the ATmega328 and 74HC125 tristate buffer on a breadboard to prove the design. The combination of the 3 ICs and the Magjack on its breadboard friendly breakout board (from Cool Components) was a neat fit on the standard size breadboard. Cool Components source most of the key components, allowing the design to be built on a breadboard for about £12. A later post will describe the breadboard construction in detail - for those brave enough to follow this route.

So the Nanode, provides ethernet connectivity to what is essentially a standard Arduino and allows access to most of the original I/O lines for the control and sensor applications. To summarise you have 6 analogue inputs, 8 digital I/O lines and a serial port remaining after driving the ethernet controller. With this you can sense analogue variables such as temperature, pressure or energy consumption such as electricity or gas, and have the ability to control relays, displays or actuators using the digital I/O. The Nanode takes the serial interconnection one stage further and using some of the spare 74HC125 buffers implements a "multidrop" serial network - allowing Nanodes to be connected together on a local serial network, which provides communications and power.

Having built the first one up on breadboard, as a minimalist proof of concept, I got it working to the point where I could send messages or control packets to another network connected Arduino and NuElectronics Ethernet shield, using Pachube to transfer data between the nodes. Then I got distracted by other things and the "Etherduino" - the early construct name for the Nanode, got put to one side for 6 months.
It was on hearing that Pachube are hosting an Internet of Things Hackathon in London on April 8th/9th which encouraged me to revisit the design with the aim of having it ready for the Hackathon. The breadboard ethernet Arduino is now Nanode - a Network Applications Node. (Or Networked Arduino Node - for those in the Arduino camp).

Timing of the Hackathon was perfect, allowing me 2 weeks to finish my design and get some boards made. I also had wanted for some months, a general purpose DIY Arduino compatible board, which could be made more cheaply than commercial units. With the features of more friendlier I/O connections and had the means to be networked to other nodes on a serial bus, the Nanode seemed the ideal entry point into Net Connectivity for under £20.

Above: First Prototype Nanode Runs Pachube Client Code. Blue LED shows Ethernet data activty.

This new board was the opportunity to address some of the points on my wish list. There were several design points which I wanted to take into consideration and resolve:

1. Must be easy to build by anyone who can solder - so 2 layer PCB design (EagleCAD) using conventional and readily available through hole components. Board is 72.4mm 58.4mm (2.85" x 2.3") - marginally bigger than Arduino, to account for additional I/O connectors.

2. Low Cost - hence the use of the Microchip ENC28J60 ethernet controller.

3. Compatible with standard Arduino shields - matching connector pitch - warts and all!

4. More flexible I/O arrangement. I have fitted additional connectors on 0.1" pitch which allow compatibility with breadboards and stripboard. All of the standard I/O pins and power from the ATmega328 are available along one edge of the pcb, which simplifies plugging this board into breadboard or 0.1" stripboard. They also allow the I/O headers to be accessed even with a shield fitted. An extra connector in the top left corner brings up the analogue inputs and 5V power - so all of the ATmega I/O and power can be accessed from a single edge of the board with a SIL header pins - handy for one sided connection of everything to a breadboard.

5. Spare tristate buffers in the 74HCT125 allows several Nanodes to be interconnected on a serial bus, controlled by a master unit which is connected to the internet. This feature was developed last August and found that we could get 9600baud serial data down 300m of cable. Simple 4 way telephone cable can be used to string these nodes together.

6. With the ENC28J60 and Magjack omitted, the device becomes a simple serial node - at £5 lower cost.

7. Extra I/O connector allows direct plug-in of R/C servo or Moderndevices LCD display on 3 wire bus.

8. Serial accessed via FTDI cable or similar USB to Serial adaptor.

9. Tall headers will be used to increase the clearance between the shield and the Magjack connector - which is 3mm taller than the USB socket usually found on the Arduino.

10. Programmed through the Arduino IDE (or AVTdude) with access to the standard AVRISP 6 pin header.

BOM (Most specialist items from Cool Components in South London)

  • ATMega328P-PU - DIP version Cool Components £2.81

  • Microchip ENC28J60-I/SP - DIP version Cool Components £1.99

  • 74AHC125D tristate quad buffer

  • 3mm LED

  • 1N4004 Diode

  • 7805 Regulator

  • 78L33 Regulator

  • 16 MHz HC49-4H Crystal

  • 25 MHz HC49-4H Crystal

  • 51R 0.25W 1% resistor x 4

  • 270R 0.25W 5% resistor x 5

  • 2K 0.25W 1% resistor x 1

  • 330R 0.25W 1% resistor x 1

  • 10K 0.25W 5% resistor x 3

  • Ferrite inductor

  • 18pF ceramic cap x 4

  • 100nF ceramic cap x 4

  • 10uF 16V electrolytic cap x 3

  • 28 pin 0.3" DIL socket x 2

  • RJ45 MagJack £1.99 CoolComponents recommended

  • 36 pin 0.1" SIL header x2

  • Small Tact switch Cool Components £0.28

  • ATmega Nanode PCB - that's me!
I have sent off to have batch of 10 boards made up in time for the Hackathon. If anyone would like the EagleCAD files, or purchase a pcb - please drop me a comment.