Difference between revisions of "Project:Nanode/Applications"

From London Hackspace Wiki
Jump to navigation Jump to search
Line 84: Line 84:
  
 
==Simple Applications==
 
==Simple Applications==
 +
 +
Here's some ideas to get you started with your Nanode.  Feel free to add your favourite applications to this section. Wherever possible provide a link to relevant external information, code examples or a link to a GitHub Gist which can be quickly cut and pasted into a new code sketch.
 +
 +
===Nanode Basics===
 +
 +
Nanode is very similar to the Arduino - in fact anything that you can do on an Arduino can be done, almost without modification, on the Nanode.  The Nanode provides the familiar Arduino shield connectors - so you can plug a wide range of shield and protoboards straight into the top of the Nanode.
 +
 +
With a shield in place, Nanode provides a second row of connectors on each long edge of the PCB - these connectors have been tailored to suit the needs of a variety of hardware devices.
 +
 +
Nanode can be fitted with a row of connector pins on the top edge of the pcb, so that it can be plugged into a standard breadboard. Unlike the Arduino, all of the available I/O, both analogue and digital and power can be accessed from this single in line (SIL) connector - making connection to a breadboard simple, quick and easy.
  
 
===Connecting a RGB LED===
 
===Connecting a RGB LED===

Revision as of 06:50, 11 June 2011

Upgrade to Pachube Premium Account

From Ed Borden, Pachube, New York.

"We are really excited about this project here at Pachube. We want to give our full support to anyone who has the gumption to take this thing and pull it along to the next level. I don't care if you haven't tested the first run yet! :) Full steam ahead!

For any of you guys on this list who bought a nanode from Ken and want to connect it up to Pachube, drop me a line with your username and I'll upgrade your account to Premium. And if you do something awesome that you want the world to know about, tell us about it!"

edborden at pachube dot com

Testing Nanode

The ATmega328 microcontroller supplied with the kit has a specially modified version of the Arduino bootloader pre-programmed into it.

Arduino usually has a LED wired to Digital pin 13, but in Nanode, digital 13 is in almost constant use as the SPI Clock.

So in the Nanode bootloader, the LED flashing function has been altered so that it flashes the red LED which is wired to digital pin 6.

If all is well with your Nanode board, the Red LED should start flashing about 2 seconds after the power (from USB or FTDI cable) has been applied.

If it does not flash, check for faults such as missing soldered joints or the LED incorrectly inserted.

Applications

Quick Tutorial- 4/6/11.

1. Download and Install Arduino Environment http://arduino.cc/en/Main/Software Mac users: mount the dmg and drag arduino into Applications folder. Windows users: open the arduino-0022 folder and run Arduino.exe Ubuntu users (tested on 10.10): sudo apt-get install arduino

2. Download FTDI Cable Drivers

Plug in the FTDI programming cable.

  • Windows users: When prompted to install drivers, point the installer to the arduino-0022/drivers directory
  • Mac users: mount the arduino installation dmg and double click on the FTDI install package at the bottom of the window. In Arduino application menu/Tools/Board/ select "Arduino Duemilanove or Nano w/ ATmega328" and menu/Tools/Serial Port "/dev/tty.usbserial-A400f2he"
  • Linux users: if you are using a 'modern' ubuntu or debian install (from my experience) the FTDI cable should be plug and play, type dmesg into terminal to check for the device mount point, mine is: /dev/ttyUSB0

3. Download EtherShield Libraries

Download here: https://github.com/thiseldo/EtherShield

  • Change the downloaded folder name to "EtherShield" and place in Arduino/libraries/ folder
  • Mac users: make a folder called "libraries" in Documents\Arduino\ then place the EtherShield folder into the newly created libraries folder.
  • Windows users: place the EtherShield folder into arduino-0022\libraries\
  • Linux users: place the EtherShield folder into arduino-0022\libraries\ (or /usr/share/arduino/libraries/ ?)

4. Run the EtherShield_DHCPTest

Arduino: File > Examples > EtherShield_DHCPTest

  • In the source code, change MAC address to something random :) e.g. change the last two digits "??" to the two digit number written in pen on the bottom of your Nanode:
 static uint8_t mymac[6] = {0x54,0x55,0x58,0x5F,0x01,0x??};
  • (for Nanode version 5 users) On line 57, change
 es.ES_enc28j60Init(mymac); to es.ES_enc28j60Init(mymac,8);
  • (for Nanode version 2- older prototype boards) On line 57, change
 es.ES_enc28j60Init(mymac); to es.ES_enc28j60Init(mymac,10);

EtherShield Library and Examples

First you need to download and install the EtherShield library from GitHub

https://github.com/thiseldo/EtherShield

Make sure you have Arduino 0021 or better still 0022 installed.

(Remove any previous version of Ethershield library - as this causes code compilation problems).

Note:

To get the EtherShield examples to work you will have to edit the enc28j60 init function to read.

ES_enc28j60Init(mymac,8);

In the webserver example this can be found on line 48.

EtherShield simpleClient examples for Pachube and Emoncms: github


Simple Applications

Here's some ideas to get you started with your Nanode. Feel free to add your favourite applications to this section. Wherever possible provide a link to relevant external information, code examples or a link to a GitHub Gist which can be quickly cut and pasted into a new code sketch.

Nanode Basics

Nanode is very similar to the Arduino - in fact anything that you can do on an Arduino can be done, almost without modification, on the Nanode. The Nanode provides the familiar Arduino shield connectors - so you can plug a wide range of shield and protoboards straight into the top of the Nanode.

With a shield in place, Nanode provides a second row of connectors on each long edge of the PCB - these connectors have been tailored to suit the needs of a variety of hardware devices.

Nanode can be fitted with a row of connector pins on the top edge of the pcb, so that it can be plugged into a standard breadboard. Unlike the Arduino, all of the available I/O, both analogue and digital and power can be accessed from this single in line (SIL) connector - making connection to a breadboard simple, quick and easy.

Connecting a RGB LED

An RGB LED is a cheap and effective way of signalling changing environmental measurements or "moods". By fading the individual LEDs you can create a very large range of subtle colours. Using simple ramping up and down of Blue Green and Red will produce a display that could indicate temperture or power consumption starting at blue, fading through green and then through orange into red.

Use the PWM channels on digital 3, digital 5 and digital 6 to drive the red, green and blue anodes. The common cathode connects to 0V

Remember to use a current limiting resistor of at least 100 ohms in series with each LED. A ping pong ball or other semi-opaque plastic globe forms an attractive mood light. Cheap LED lamps available from Homebase for £2.50 each in a number of novelty shapes - globe, cube, heart and star.

Connecting a Radio Control Servo

Use the servo/display connector adjacent to the 5V regulator. Plug the 3 wire servo cable directly into the end three pins of the connector - noting that the red +ve supply to the servo goes on the left.

Connecting a "Modern Device" LCD serial Display Controller

Use the servo/display connector adjacent to the 5V regulator. Plug the 3 wire display cable directly into the end three pins of the connector - noting that the red +ve supply to the servo goes on the left.

Use the software serial library on digital 4 to send serial text and commands to the display.

Using Arduino Shields

You can plug Arduino shields into the Nanode provided that you consider the following points:

Nanode uses digital 8,11,12 and 13 to control the ENC28J60 ethernet controller.

Nanode uses digitals 7,9,10 to a certain extent depending on what hardware options have been fitted.

You may need to use "stackable headers" to lengthen the pins of your shield, so that it has clearance over the Magjack connector - available from Cool Components

Connecting to 1 Wire Sensors

You can connect to a variety of 1 wire devices including temperature and humidity sensors

Use the Arduino 1 wire library for example sketches

Connecting to Thermistor Temperature Sensors

Thermistors are a low cost temperature sensor available in a wide range of shapes and sizes to suit your application. For example if you wish to monitor your heating system, you might use the clip on pipe sensors from Rapid Electronics.

Thermistors are generally built into a potential divider circuit using a resistor of similar value to that of the thermistor - eg 10K for a thermistor which has a resistance of 10K at 25 degrees C. The thermistor should be put in the upper arm of the potential divider so when the temperature rises, its resistance drops and so the voltage at the mid-point of the divider rises.

This voltage is read using one of the analogue inputs, but the input has to be linearised and scaled so that it reads correctly in degrees C. Fortunately the code to do this is available on the Arduino Playground. and a more advanced example which uses the Steinhart-Hart Linearisation Equation



Webserver Application (Dave Ingram)

Dave's code is in his Github repository

https://github.com/dingram/Nanode/


USB Bootstrap loader

The template for the USB boot loader is USBaspLoader. It needs to be built using these config files.

There are some caveats. Read the notes.

MAC address

The code for reading the unique MAC Address has not yet been fully debugged. Dave Ingram (DMI) said that he would have a look at it.

There will be an update as soon as we have this working.

If you did not have your tiny MAC chip soldered to the back of the pcb during the Nanode Weekend - this can be done at a later date at the space.

Ken has put together an early code attempt at running this device - see Github https://gist.github.com/1016689 More work needed!

RFM12 Wireless Module

Wireless connectivity can be added to the Nanode using the Jeelabs RFM12B wireless board: http://jeelabs.com/products/rfm12b-board

RFM12 example with DHCP and DNS and posting data via Ethernet to Pachube and emoncms by OpenEnergyMonitor: download from github

Bitlash

Bitlash is a interpreted command shell (language) which runs on the Arduino. It takes 14K of program memory, but allows programs to be written from a serial terminal and stored as functions in the EEprom on the ATmega328. It is reminiscent of the early 1980s home computers which executed BASIC directly from power-up.

Bitlash could be used to write simple scripts to automate sensing functions, datalogging or other applications running on Nanode. There is an opportunity to be able to reprogram a Nanode remotely, and have it perfor different tasks.

Bitlash can incorporate any of the Arduino library functions, making it simple to combine Bitlash with existing C-code.

More infomation here Bitlash Wikki