User Tools

Site Tools


project_octobus

This is an old revision of the document!


Overview

Project OctoBus evaluated the use of 6LoWPAN for home automation. It is based on the Atmel AVR Raven hardware and runs Contiki as an operating system. This page describes the prototype. The goal is to use standard technology for solving the hard problems, i.e. routing, naming and adressing.

The Setup

The prototype consists of the AVR Raven Kit running Contiki. A wireless router running OpenWRT Router runs an IPv6 stack and mangles between IPv6 and 6LoWPAN. The setup looks like this:

I can use it to switch the lamp from my notebook. What happens is this: I create an UDP packet using a small C program. The packet is sent (over IPv6) to the router, which routes it to the AVR Raven board over the 6LoWPAN link. The Contiki system on the Raven receives the UDP packet and toggles the relay driver. This causes the relay to switch, et voilá: I can see what I type again.

This solution has several advantages:

  1. I don't need to use custom communication software on my notebook, since all communitcation is done over IPv6. All major operating systems (Linux/Mac/Windows) support IPv6, Windows starting with Windows XP SP3. In fact, there is also a webserver running on the AVR Raven which I could also use to toggle the relay. In fact I can use generic tools like ping6 and tcpdump to debug communication problems.
  2. The Contiki operating system has routing built-in. This means that devices can be connected in a mesh: this way, I can reach devices that are out of the link range of the router gateway.
  3. Adressing the devices is done using IPv6 adresses. The local (64bit) adress can be set during manufacturing, while the prefix part (64bit) is provided by the router. When setting up a device, there is nothing to be configured. The IPv6 stack takes care of constructing the full adress.

Currently, the prototype uses 802.15.4 on 2.4 Ghz which is not suitable for links across several floors. A real implementation should use 868 MHz to improve in-house reliability.

All software components are on Github: http://github.com/gonium/octobus

Software on the OpenWRT Router

The router is a Buffalo WZR-HP-G300NH running OpenWRT. I followed the instructions at the OpenWRT Wiki for setting things up.

In addition, I installed several packages to get the IPv6 stack running, this is also documented in the OpenWRT wiki. I also found this page in the SIXXS Wiki helpful (but the router does not run aiccu currently.) You have to be careful while installing the radvd and the Raven USB stick:

  1. radvd advertises the available prefixes to all connected IPv6 devices. I use two network prefixes: “aaaa::/64” for the 6LoWPAN devices and “bbbb::/64” for the Ethernet/WLAN devices. The router routes between those networks and has the IPs “aaaa::1” and “bbbb::1” on both interfaces, respectively. I did not understand how to map this in the usual OpenWRT /etc/config/radvd file, so I am using /etc/radvd.conf instead.
  2. The USB stick uses an ohci-interface and shows up as usb0. You can use the /etc/config/network file.

An archive of /etc is here: octobus-router-etc.tar.gz

This is the complete package list of the router:

root@OpenWrt:~# opkg list-installed
base-files - 42-r20728
busybox - 1.15.3-2
crda - 1.1.0-2
dnsmasq - 2.52-2
dropbear - 0.52-4
firewall - 1-10
hotplug2 - 1.0-beta-1
ip - 2.6.29-1-2
ip6tables - 1.4.6-2
iptables - 1.4.6-2
iptables-mod-conntrack - 1.4.6-2
iptables-mod-nat - 1.4.6-2
iputils-ping6 - 20071127-1
iputils-traceroute6 - 20071127-1
iw - 0.9.19-1
kernel - 2.6.32.10-1
kmod-ath - 2.6.32.10+2010-03-24-5
kmod-ath9k - 2.6.32.10+2010-03-24-5
kmod-button-hotplug - 2.6.32.10-1
kmod-cfg80211 - 2.6.32.10+2010-03-24-5
kmod-crc-ccitt - 2.6.32.10-1
kmod-crypto-aes - 2.6.32.10-1
kmod-crypto-arc4 - 2.6.32.10-1
kmod-crypto-core - 2.6.32.10-1
kmod-ide-core - 2.6.32.10-1
kmod-input-core - 2.6.32.10-1
kmod-input-gpio-buttons - 2.6.32.10-1
kmod-input-polldev - 2.6.32.10-1
kmod-ip6tables - 2.6.32.10-1
kmod-ipt-conntrack - 2.6.32.10-1
kmod-ipt-core - 2.6.32.10-1
kmod-ipt-nat - 2.6.32.10-1
kmod-ipt-nathelper - 2.6.32.10-1
kmod-ipv6 - 2.6.32.10-1
kmod-leds-gpio - 2.6.32.10-1
kmod-mac80211 - 2.6.32.10+2010-03-24-5
kmod-nls-base - 2.6.32.10-1
kmod-ppp - 2.6.32.10-1
kmod-pppoe - 2.6.32.10-1
kmod-usb-acm - 2.6.32.10-1
kmod-usb-core - 2.6.32.10-1
kmod-usb-net - 2.6.32.10-1
kmod-usb-net-cdc-ether - 2.6.32.10-1
kmod-usb-net-rndis - 2.6.32.10-1
kmod-usb-ohci - 2.6.32.10-1
kmod-usb-serial - 2.6.32.10-1
kmod-usb-uhci - 2.6.32.10-1
kmod-usb2 - 2.6.32.10-1
libc - 0.9.30.1-42
libgcc - 4.3.3+cs-42
libiptc - 1.4.6-2
liblua - 5.1.4-6
libncurses - 5.7-2
libnl-tiny - 0.1-1
libpcap - 1.0.0-2
libuci - 12012009.5-1
libuci-lua - 12012009.5-1
libusb - 0.1.12-2
libxtables - 1.4.6-2
lua - 5.1.4-6
luci - 0.9.0-1
luci-admin-core - 0.9.0-1
luci-admin-full - 0.9.0-1
luci-admin-mini - 0.9.0-1
luci-app-firewall - 0.9.0-1
luci-app-initmgr - 0.9.0-1
luci-cbi - 0.9.0-1
luci-core - 0.9.0-1
luci-http - 0.9.0-1
luci-i18n-english - 0.9.0-1
luci-ipkg - 0.9.0-1
luci-lmo - 0.9.0-1
luci-nixio - 0.9.0-1
luci-sgi-cgi - 0.9.0-1
luci-sys - 0.9.0-1
luci-theme-base - 0.9.0-1
luci-theme-openwrt - 0.9.0-1
luci-uci - 0.9.0-1
luci-uvl - 0.9.0-1
luci-web - 0.9.0-1
mtd - 12
netcat - 0.7.1-2
opkg - 513-2
ppp - 2.4.4-5
ppp-mod-pppoe - 2.4.4-5
radvd - 1.6-1
screen - 4.0.3-2
swconfig - 5
tcpdump - 4.0.0-2
uci - 12012009.5-1
udevtrigger - 106-1
uhttpd - 7
usbutils - 0.86-1
wireless-tools - 29-4
wpad-mini - 20100309-1
zlib - 1.2.3-5

The AVR Raven USB stick is installed as described in the Contiki tutorial - you can flash the firmware binary provided by them without any changes.

Software on the AVR Raven

For a general tutorial, see here. I am using Mac OS for development. On my blog there are some notes on how to get the system running and how to flash the devices.

The little board you see in the picture is not really interesting: It provides a power connector with a little LED to indicate a working power supply. The screw terminal is the connector for the relay. The socket on the left is for a serial port connector (it has a little cable soldered to the Raven board). On the Raven board itself, I soldered the JTAG connectors and (on the backside) two ISP cables for programming.

The directory structure of Contiki is somewhat overwhelming. I am currently working in these directories:

  1. contiki-2.4/platform/avr-ravenlcd: This is where the code for the ATMega3290p lives. Run make here and upload. The directory also includes relay.{c|h}: This is where the physical connection to the relay driver is toggled. The two ATMega microcontrollers connect over a serial line, so I've implemented a protocol here.
  2. contiki-2.4/platform/avr-raven: The ATMega1284p code lives here, this is where most patches are. The code for the relay is in the subdirectory contiki-2.4/platform/avr-raven/apps/raven-relay-switch. Don’t run make here!
  3. contiki-2.4/examples/webserver-ipv6-raven: Run make here for the ATMega1284p code. This builds the webserver code and includes the platform/avr-raven dir.

The serial terminal for debugging output can be accessed like this:

screen -U /dev/cu.SLAB_USBtoUART 57600

Software on the Notebook

For easy testing, I wrote a small program called 6switch that sends out commands to the AVR Raven. It just uses the socket API to send out an UDP packet with a command word in it. This is a custom protocol and can probably be replaced by command words from KNX etc.

In addition, I wrote a small GUI with Shoes. It looks like this:

The Relay Box

The relay box just encapsulates all components directly connected to AC mains. It contains a relay in normaly open position, a fuse, a permanently connected socket and a switched socket (which is connected to the relay).

Preliminary Bill of Materials

I want to know what the manufacturing cost of an IPv6 plug would be. The main components will be an embedded chipset and the relay. Custom parts like a plug enclosure etc. are estimated, but all other components can be procured directly:

project_octobus.1281359703.txt.gz · Last modified: 2012/10/30 10:37 (external edit)