User Tools

Site Tools



Project OctoBus (“The Kraken of Home Automation”) evaluates 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.

Trade fair setup

The description of our trade fair setup is here: HexaBusDemoSetup

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. The rationale for 868 MHz is described in a good way at the OSIAN Wiki.

All software components are on Github:

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. I also use a simple shellscript for easy tftping:

sudo ifconfig eth0 netmask
sudo arp -s 00:24:a5:b0:07:d3
tftpfoo=`(cat <<-EOF
rexmt 1\n
timeout 60\n
put openwrt-ar71xx-wzr-hp-g300nh-squashfs-tftp.bin\n
) `
echo $tftpfoo

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 -
kmod-ath -
kmod-ath9k -
kmod-button-hotplug -
kmod-cfg80211 -
kmod-crc-ccitt -
kmod-crypto-aes -
kmod-crypto-arc4 -
kmod-crypto-core -
kmod-ide-core -
kmod-input-core -
kmod-input-gpio-buttons -
kmod-input-polldev -
kmod-ip6tables -
kmod-ipt-conntrack -
kmod-ipt-core -
kmod-ipt-nat -
kmod-ipt-nathelper -
kmod-ipv6 -
kmod-leds-gpio -
kmod-mac80211 -
kmod-nls-base -
kmod-ppp -
kmod-pppoe -
kmod-usb-acm -
kmod-usb-core -
kmod-usb-net -
kmod-usb-net-cdc-ether -
kmod-usb-net-rndis -
kmod-usb-ohci -
kmod-usb-serial -
kmod-usb-uhci -
kmod-usb2 -
libc -
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 has also been a helpful resource.

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. I assume 100 devices for the prices.

Part Distributor Quantity Price
AT86RF212 Farnell 1 EUR 4.11
ATMEGA1284P-AU Farnell 1 EUR 4.95
FINDER Farnell 1 EUR 0.56
PCB with Antenna 5x5cm 2-sided Olimex 1 EUR 1,50
Socket Enclosure n/a 1 EUR 2,00
Power Supply n/a 1 EUR 3,00
Random Parts n/a n/a EUR 3,00
SUM EUR 19,12


  1. For the PCB calculation I assumed a 50 sqdm order which can hold 200 boards.
  2. I did not find a suitable wall socket enclosure or similar - this is just an estimate. The cost of this part heavily depends on the number of devices to be manufactured. I hope to find an already available enclosure and tailor the PCB to it.
  3. The power supply is still an open issue. The power consumption of the circuit is pretty low, around 20mA. The driver for the relay needs more power. Is it possible to generate 3.3V directly from mains?

Hint: Perhaps you will find a solution here: To trigger the line-relay you can use a solid-state-relay: Or you use a SSR directly as line-switch, but then you have no line-seperation. btw. the finder relay is obsolete. mfg Udo

project_octobus.txt · Last modified: 2012/10/30 10:27 (external edit)