At Jokamajo we're currently alpha testing a social metering application called Flukso. Flukso lets you compare your total electricity consumption to that of other households. These can be family, friends, colleagues, you name it. With Flukso, we're trying to turn those abstract watts and kWh's into something more tangible. You can display time-series charts covering the most recent hour, day, month or year. You can also dynamically add or remove other Fluksonians' (yeah, by signing up to the trial you're also getting a new passport) data onto the chart. If you're interested, you can check it out here. Note: Due to privacy reasons, we're only showing my personal chart.
fonduinoIn order to get this working, we needed to be able to transfer the pulses sent out by the energy meter to our Flukso server. We spent quite some time searching for a set of suitable off-the-shelf building blocks. We tackled this problem from two angles. Solving the networking problem first led us fairly quickly to a wireless residential router running a Linux kernel. OpenWRT is a good candidate as it lets us add all the software packages we need for our metering, like NTP support for timekeeping. As a fair amount of people are now using wifi to connect to the Internet from any room in their home, using a wifi capable router makes sense. Trying to detect the pulses sent out by the energy meter meant that we then had to look for at least one free GPIO on the router board and getting the linux kernel to pass these triggers to our software residing on the board. We solved this by using the hotplugging deamon. The major drawback of this solution is that we haven't got a long-term solution to store the meter value on the router. Since storage is all flash-based, you can only write to it about 100.000 times. Households having an average electricity consumption of 70kWh per week and the energy meter sending out a pulse for every Wh you've consumed, means that you're burning through the flash in less than two weeks time. That's a bit short, even for an alpha trial...
We then looked at it from the other side. Detecting the pulses is now the easy part. Just use a microcontroller. We really like the AVR ATmega168-based Arduino project. Such a controller gives us the opportunity to play with all kinds of IO. We solved the storage problem by using the analog comparator on the AVR to compare the supply voltage to the chip to an internal reference voltage. Now we can keep the meter value in RAM. When the comparator detects a power drop, it triggers an interrupt routine which can still write the value to the AVR's EEPROM before brown-out. Our major stumbling block in this case consisted in the networking part. How could we get this Arduino to communicate with a web server? There are a couple of Arduino shields out there that try to solve the networking problem. You can see examples here and here. But they only give us an ethernet connection, no wifi. DHCP is barely supported and we can forget about some more 'exotic' protocols like NTP.
Come to think of it, the fact that we ran into these problems actually makes sense. 8-bit microcontrollers are great for connecting to the physical world. You can measure almost anything you like, as long as it can be converted to volts and amps. Driving leds and motors is a breeze. Wireless routers on the other hand are perfect for networking and fairly demanding computational tasks. They're running, or can be converted into running, Linux. So basically all the power of a UNIX operating system is at your fingertips. Pursuing a hybrid solution, in true Prius style, therefore makes sense. And that's exactly what we've done for our Flukso prototypes. When googling for this type of solution we bumped into an experiment marrying an Arduino to a Fonera in this post. Since our trial means installing the solution in people's homes, we were in need of a more polished solution.
Sparkfun released a minimalistic Arduino-compatible board called the Wee that contains just the bare essentials for getting the AVR up and running. Comparing this board to a Diecimila makes the latter look rather bloated. And we got lucky. The Wee is so-to-speak pin compatible with the Fonera 2200. If you align both boards correctly, you can solder GND to GND, Rx to Tx, Tx to Rx and 3.3V to ... 3.3V! This means that we could let the Fonera and Wee have a two-way UART conversation. Additionally, you can power the Wee directly from 3.3V out pin on the Fonera's serial header. We later switched to a different way of powering the Wee through the Fonera, but that's another story.
Now we needed to have some sort of connector to terminate the wires coming from the energy meter. We noticed that the spacing of the perforations in the Fonera's grey plastic shell are actually 0.1" apart. So we could just insert and glue an 8-pin female header into the Fonera's perforations. We could also slide the pins of the header into a small prototyping board. So there you have it. A fully functional and configurable Fonera-Arduino hybrid, a Fonduino. Or should we call it an Ardonera instead?
Comments
Very nice work! I'm extremely glad that the work I did over at EchoDitto Labs made its way into a larger project. For those looking to do similar work, let me shamelessly link to the slides and audio of a presentation I made at our local Dorkbot on this subject:
Dorkbot DC: Arduino and Fonera
Jokamajo, very happy to know La Fonera was useful for you guys on this project! Let us know if you need further help from our side, we try helping all innovative projects based on our Foneras. The new Fonera 2.0 has also USB interface so it may help you get some more fun out of it, check it out at fon.com.
Cheers,
Jordi - FON
Do you send info from the arduino to the fonera? I've been trying doing so and I only can get 1 way comunication: (fonera -> arduino) and I would like to do it in both ways... Any tips?
Hi binnary,
If you're running a stock OpenWrt release, then an 'ash' shell console is attached to the ttySO serial port by default. Just check the contents of your /etc/inittab:
root@OpenWrt:/etc# cat inittab::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
tts/0::askfirst:/bin/ash --login
ttyS0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
So the messages you send on the Arduino's Tx should be proper shell commands. You could write a shell script called 'notify', make it executable and copy it to one of the directories listed in your $PATH (/usr/local/bin will do). If you now print the string 'notify light_detected' to Arduino's Tx, this will be interpreted by OpenWrt's shell as the command 'notify' with the argument 'light_detected'. Now, all that's left is to add some code to the 'notify' script to catch the argument and off you go!
A second approach is to detach the shell console from the serial port by deleting the last three lines from the /etc/inittab file. You can now open /dev/ttyS0 as a file, and read it out line-by-line with your scipting language of choice. Note however, that you can't rely anymore on the serial port console to access OpenWrt in an emergency situation, e.g. not having telnet/ssh access via ethernet/wifi. The serial will still be available when the bootloader is active, so the device will not be bricked. You will just have to reflash it once more.
Hope this helps.
Thanks a lot! I was trying the second metod, but I think that the problem was on the arduino, I have loaded the code again and now it works! ;)
Thanks for your help!
Icarus,
Nice work. We met at HomeCamp 2 weeks ago.
As a general thought there has to be a low cost easy way to get a small 8 bit micro to talk to a wireless router gateway - this is key to all that we are doing.
I have worked with 433MHz short range wireless links - as a way of getting gas meter pulse data out to a hub (which in 1999 was a low data rate PSTN modem). If you only need 1 way communications, a 433MHz link is very low cost and can be made fairly robust. The power consumption can be minimal, I ran the link with 15 second updates on pulse count total, on just 25uA of power @3.6V taken from a single AA lithium thionyl chloride cell. Expected battery life was 10 years.
If you want 2 way communications or transfer more data, then you might wish to consider a Zigbee link and then a Zigbee gateway plugged into your router. Lady Ada did something similar to this with her Tweetawatt using low cost Xbee modules.
Zigbee is fine - provided that you have a power source available - otherwise changing batteries every 2 weeks could become a nuisance.
If through the efforts of HomeCamp we can find a standard, low cost way of getting data from micro to web it would be a great step forwards.
Ken
Hello Ken,
considering the fact that we typically would hook up multiple wireless sensors to the gateway, some kind of multiplexing would be required on the PHY layer at the receiver side. This, to me, would make Zigbee a more apt candidate than some proprietary and mostly point-to-point 433MHz link.
Zigbee has also been specifically designed to be very power efficient. A decent low-power sensor setup should thus last quite a lot longer that the two weeks you mentioned.
Since an Xbee comes with a UART itf, it's quite straightforward to connect it to a wifi gateway, as already demonstrated by Ladyada. Which would leave us only with the design of a battery-powered sensor + Zigbee Tx board.
wanted to drop a link to lady ada's tweet-a-watt kits: http://www.ladyada.net/make/tweetawatt/
Hi Drewish,
Thanks for the link. There are some substantial differences between a Tweet-a-watt and a Fluksometer. The Fluksometer measures your total household consumption, a tweet-a-watt measures an individual appliance. And while twittering your electrical consumption is a cool thing to do, it doesn't allow you to analyze your consumption pattern over days, weeks or months, nor directly compare it to other users. That's where the real value of this type of application resides. Being able to reduce your consumption based on interpretation and benchmarking with peers. This is what we want to achieve with Flukso. To help people in reducing their energy consumption by visualizing the data from the Fluksometer.
Cheers,
Bart.
I came across a link to your project, great work!
I've been working on a low cost, low powered wireless Arduino solution, specifically for wireless sensor type applications, as the xbee + xbee shield + arduino just get too expensive if you want to roll out a number of sensors.
Enter the Wireless Widget Open Hardware Project. http://code.google.com/p/strobit
For the 'server' / data collector I came across these from poland http://www.propox.com/products/t_231.html that are running linux, reasonably priced and more compact than the router (but doesn't have wifi)
Regards,
Stephen...
Hi Stephen,
Nice work on the Strobotics sensor nodes. You could hook up a sensor node to a wifi station. The latter would then function as gateway, collecting all sensor measurements and transmitting them to a web platform.
Cheers,
Bart.
Post new comment