Tucsni

Embedded stuff

On this page, I'll be reporting on some of my adventures with embedded stuff like Arduino and JeeLabs stuff when I think it may be usefull for other people:


Airwick repurposing

10/02/2010

As shown here, it's possible to repurpose an Airwick Freshmatic to a wireless sensor node with a JeeNode in the space which is normally used by the spray canister. I've largely followed the instructions of Szymon, but since I've a bit different ports setup with room boards, things are just a little bit different in my situation. 

JeeNode

You can see how the connectors of the Freshmatic have been reused on the JeeNode. Note that I soldered a wire on an SHT11 pad that is connected with AIO, but I later moved it directly on the AIO pin of the port; that seemed to be more firm.

Open Freshmatic

Above it a picture of the opened Freshmatic. The arrows+text in the picture above give some notable details (click image to enlarge in order to have  more readable text).

Programming your Freshmatic

Here I program the freshmatic with a slighly modified rooms sketch (the 18-01-2010 version with the watchdog patch). You can find this modified sketch here.

Freshmatic inspection

It's almost like the housing is made for the JeeNode; it fits quite snugly in there. The JeeNode doesn't need to be fixated either. You do have to remove the canister spring in the bottom though, but that's not too hard.

Freshmatic done

So this is what the result looks like. Note how the LDR sensor sticks out just a little bit so that light can fall on it unhindered. I later routed the ground wire through the movement switch so that you can also turn the device off.  The modified sketch will ofcourse make the LED blink whenever motion is detected.

Collecting rooms data on the central JeeNode/JeeLink with modbus sketch

10/02/2010

Having  room nodes sending data is one thing, but you want to collect this data and store/view/analyze it.  There's ofcourse JeeMon, which does a great job at this and makes some very nifty graphs. When you want to connect with other (existing) central software,  it can be usefull when the central Jeenode/Jeelink makes the collected data available in some existing protocol format.

Mango is open source software for general purpose M2M which supports a variety of protocols. One these is the modbus protocol. Since there's already some modbus code available for the Arduino by jpmzometa, I made a sketch that makes the rooms node data available in modbus holding registers so you can have Mango (or another modbus master) retrieve the collected data from the Jeelink.

The sketch is available here. The JeeLink will basically become a modbus slave with ID 1 (9600 8N1).The rooms data for each node get stored in 5 holding registers (0-4: node A, 5-9: node B, etc.). See source code for more details.

Mango view

This is what a Mango view could look like. The gauge is indicating the light intensity as collected by the LDR sensor. The bulb blinks when IR presence is detected. 

Modbus RTU slave library with support for modbus function 6 

12/03/2010

I extended the modbus code from jpmzometa to support modbus function 6 (required for use with Mango) and to be able to use it as an Arduino library. You can find this Arduino modbus RTU slave library (with support for function 3, 6 and 16) here. Just put the ModbusSlave directory in the Arduino libraries folder. The header file provides info on how to use it.

update: jpmzometa has kindly included function 6 in his modubus library, so you are advised to get the modbus library from here.

EtherShield library 4.2

29/06/2010

There are some ethernet shields for the Arduino out there. One of them is the ethershield of Nuelectronics, based on the Microchip ENC28J60 SPI ehternet controller. The official Arduino ethernet shield on the other hand is based on the Wiznet W5100 chip. The most obvious difference between these 2 is the price; the ENC28J60 based one costs quite less. The primary reason for that is probably the fact that the W5100 does  more than just providing ethernet PHY/MAC. It has a IP stack as well, making it relatively easy to use with Arduino, but you have to pay some more for that.

The etherShield needs a software IP stack in the Arduino. The Arduino library made available by Nuelectronics is derived from Guido Socher's Tuxgraphics IP stack which uses the ENC28J60 driver from Pascal Stang. However, the library that can be downloaded at the time of writing is a 2.x version and is not up-to-date anymore. The Tuxgraphics IP stack is already at version 4.2 at the time of writing; quite some enhancements have been made in the meantime. I have taken this 4.2 IP stack and made the new functions available in the Arduino style library interface as introduced by Nuelectronics so that existing Arduino sketches can be reused and take advantage of new functionalities. The resulting etherShield library version 4.2 can be downloaded here. 

The following new functions (compared to the 2.x library) are available in 4.2:

  • Routing through a gateway for http client calls (really a must have feature)
  • UDP server and UDP client methods
  • DNS resolving
  • binary buffer fill method
  • generic TCP client (still with 1 TCP segment only limitation though)
There are some other changes. Check the header file for more info.

update: The 4.2 version is used as basis for the Jeelabs ethercard library, which works with the Jeelabs ethercard. The ethercard library (amongst other enhancements) adds a convenient printf-style method for writing web pages. You can also use the ethercard library with ethershields, but you have to change the the CS pin define in enc28j60.c to Arduino pin 10.



Last update: 22/09/2010