Thursday, 21 March 2013

RF breakout boards

In my ongoing compulsion to connect things to other things, I did not want to be locked in with a design to one RF solution.
There are a few minimalist options available now. The Hope-RF RFM12 is a favorite, the newer Hope-RF RFM70 or 73 and not forgetting Sparkfun with the Nordic nRF24L01 solutions

I wanted to use the sparkfun SIL footprint as my 'fit-all' footprint.  and make small breakout boards so that I could use any of the 3 options as a plug-in.
The breakouts need space for an on-board regulator to enable use with 3.3V or 5V. Dont fit the reg for 3,3V, cut a track and fit the reg for 5V. The RFM12 also needs spaces for some resistors if used with 5V. Its inputs are not 5V tolerant.

This is the first version I came up with. Its before I decided to use the Sparkfun footprint as the model.
New version will use the Sparkfun footprint.

I dont need to solder the RF board on to the 'main' board, its just a plug-in, fit if required. One footprint does all.
The Sparkfun versions are available pretty much everywhere and now I have options to use RFM12's in the same socket or the RFM70.

RFM70 and RFM12



 The Sparkfun version.

This is what the new versions will adhere to.

RFM12 water meter

The latest use I have for the RFM12 mini-node is to monitor the water I'm using on keeping my garden alive.

Where I live, there is no public water supply, ALL of my water comes (directly) from rain. This is collected on my house and shed roof areas and stored in several tanks.
At long last I fitted an irrigation system that waters the garden around my house, but then I wondered, how much water am I actually using?

I purchased a 3/4" flow meter from littlebird electronics (and available from several other suppliers).

It is spec'ed at 5V but runs fine at 3.3V with clean edge transitions and 0-3.2V switching on the sensor o/p (using the internal pin pullup)

Without the sensor connected, the node board (in active mode) consumes about 0.5~0.6 mA. This is at 1Mhz.
With the meter connected this jumps up to a whopping 3.2mA if the sensor is giving a 'zero' or 2.6mA if its a 'one'.
Its a bit high for comfort.
When paired with the solar charger this should actually be fine.
The solar panels are supposed to give 170mA (I measured just over 150mA).
If we round up the consumption to 4mA and then have 18hrs of no charging per day, (18 x 4), that's only 72mA/hrs. This takes less than 30-min of good charging to replace the used energy.
I have a stack of 1000mA/hr single-cell Lipos as that is what is used in the garden lights so one of then should let it run for (theoretically) about 250 hrs in the dark, just over 10 days.

The 1st attempt software is done. The board keeps a running total of water through since powered up and also the water through in the last minute.
From the data-sheet, if I got my sums right, it gives a pulse for each 3ml of water through the meter. This will only be so within the specified flow-rates (see here) but I'm not needing a precision device, just an approximation. If its within 5~8 % it will be good enough for my purposes

Another possibility I have not tried yet is to tie the 4 free port pins together and see if I can power it from them directly.
The trouble with that is I would then have to find another way to detect the water staring to flow.
If I managed to use three pins, that leaves an analog i/p free.
Perhaps a piezo sensor on the pipe. Or a micro hydro generator that gives power from the water flow so no batteries required.
Or fit a micro-switch over the anti siphon vacuum breaker that is already installed on the pipework. Its a simple little valve that when the pipe is pressured, it pop's up, pushed by the internal water pressure, and closes a seal. When the pump is off and the pressure drains out of the system it releases and lets air into the pipework so my water tank does not siphon out and empty itself.

I think I'll make one for the shower next. Its probably the largest water consumption item I have. If you have ever had teenagers in the house then you know what I mean....

Solar charger for RF nodes

In my remote nodes, they currently use alkaline batteries. These will run a node for perhaps 12~18-months. It depends on how much they send and how often and what type of heat cycling they are exposed to.

Typically on a temperature node, I send the info every minute. This comprises of temp and battery voltage.
The duration that the RFM12 is actually powered-up and transmitting is a large proportion of the power drain so if the string that is sent is longer, ie it goes from 15ms to 30ms, thats a doubling of power consumption. If you send more, batteries last for less. Not really a surprise.

I wanted a solar option as one of my nodes in on the roof monitoring the solar hot water system. It has a Dallas 1-wire sensor globbed on the on the end of the tank, under the cover, with heat-sink paste.
I dont measure the tank internal water temp, but its close enough so I can see whats happening. The manufacturer has the electric thermostat mounted in a similar location. I reckon where I measure its about 3~4 Deg cooler than the internal temp.
This is a Thingspeak live graph of the solar hot-water system. Its logging most of the time but off now and again if I'm messing with it.
I figure if I put a solar one up there, I can just forget about it.

The board is pretty small, about 23 x 33 mm with a couple of mounting holes. It uses the same single cell Lipo charger IC as the garden lights, the CN3083.  I got them from Ebay

This is the circuit. Nothing fancy, pretty much off the data sheet with the monitoring dividers added.

I use it wired-in and as a plug-in.

The PCB on the left is my first 'real' version, a general purpose board that I use for assorted purposes.
The software files are on AVRfreaks but quite old now, Its evolved slightly but essentially the same. The core RFM12 software is almost unchanged.

RFM12 mini-nodes (Tiny861)

The latest evolution of the RFM12 module is a mini version using an AVR TINY861
Design files are on AVRfreaks.

This is it, top and bottom
White connector on the left (3-pin) gets used as a one-wire port, its +V, GND and a port-pin

The other white connector is +V, GND and 4 analog i/p port pins
Also sporting a 6-pin programming header + LED.
After-all, its not really electronics if it cant have a flashing LED.

Schematic as shown, or a PDF version here
Boards are fairly compact, 35mm square.

The PCB's were produced in Kicad and manufactured by Seed Studio's PCB service.

These work well when paired with a solar charger + L-ion cell. The charger was an offshoot from the solar garden lights , also on the blog.

The small board on the right of the picture is a single-cell Lipo charger.
Its used here with one of the Tiny861 RF nodes (above). The charger board, as well as supplying the battery voltage to power the node, also gives out monitoring voltages (resistively divided) for the panel and battery voltages.
Charger is here

Wiznet in AVR assembler

I've been exploring the use of the Wiznet W5100.
I have a logging/serving system at home using a Freetronics Ethermega. It runs as a combined web-server and logging client.
The Ethermega has on board the W5100 ethernet chip and a mini SD card socket. Ideal for serving web pages.
Assorted RFM12 nodes send back sensor data which is collected and then available on the web pages. Much of this data is also logged to Thingspeak and Nimbits.
The web related stuff is all done in the Arduino environment and that has become my problem.
So far, it just is not reliable. There seems to be a lot of stuff out there about the problems with the Arduino Ethernet implementation.
In my case, it is just as likely to be my software as I write C at kindergarten level. I just aint very good at it!
I lack the knowledge to dig into the libraries to add/modify/diagnose.
So I started on an AVR assembly language version for the W5100.
Once the W5100 version is done, I have a W5200 module just waiting for its turn. Its TINY and has a power-down mode.

Masochist? perhaps...

The easy way to start was to use a WIZ811MJ module, commonly available and reasonably priced.

The client side is done, I can post data to Nimbits and Thingspeak. A couple of days back I signed up for a free PROWL account and pushed data to my Ipod touch. It was quite straightforward so that was a pleasant surprise.
Server side is done in the sense that it can serve pages from flash but not yet from any other medium.

Just getting to grips with DNS as I dont like to hard-code IP addresses.
Its a working skeleton and I get responses back now and can (at last) understand them. Next bit is to make a parsing module to find and extract the data, shouldn't be too difficult.
Then its on to NTP requests.

So far, with client/server/DNS/serial/timebase and other support routines,code size it at 4.5K, another 1,4k used for data so not too bad yet. Its by no means optimised.
I mostly use Mega328's so space will not be a problem for a while.

The client and server are done as state machines so the software (as part of the operating main loop) checks in to see if anything needs doing. It is designed to be non blocking for the 'main' application so the micro can continue with other tasks and as the web system needs attention, it gets it.
At this point it is not interrupt driven and so far during the learning process I'm only using one socket from the 4 available.

The starting point for my code was mainly from a contest entry, the WIZnet iEthernet Design Contest 2007 by Chuck Baird.
This enabled a good start to getting things going.

Saturday, 9 March 2013

RFM12 nodes(Mega328.168), the story...

Some time back I started experimenting with RFM12 modules from Hope-RF.
These neat little modules are available in different frequency bands, I use the 433Mhz version.

The idea was to produce a network of sensors that could measure different things in the physical world, such as...
Pressure (water tank height, )
Temperature (Dallas 1-wire  DS18B20)
Light (LDR or light>frequency converter)
Count the revs on my electricity meter (count pulses/reflections)
Read how much water was flowing through my garden irrigation system (count pulses)
and turn things on/off

The node boards started off as home made. The first one used an Arduino pro-mini and the plug-in version of the RFM12.

This one was home etched. I had been playing with the small Arduino boards and had a couple handy so figured I may as well use one to get going.

This got me started.
To begin with, it was quite tricky. The data sheet for the RFM12 was pretty bad so lots of Google searching went on and looking at other peoples code and notes.

This made life difficult for me because almost everyone wrote in C. I was learning a bit about C by using Arduino but I had a long way to go.
My programming choice is assembly language.

I managed to send data between two boards (eventually) so things progressed.

PCB Version-2 was next

 This one used the surface-mount RFM12 and a Mega328
The 8-pin socket is for an RS485 chip

This particular board is in use, it sits in my workshop and every minute, it wakes up and transmits the temperature. Sensor is a DS18B12.
The batteries last over a year.

Underside with the RFM12 (green patch)

From here on, I used the surface-mount RFM12. The plug in version was too awkward.

Overkill garden solar lights

If you have purchased some solar garden lights from the hardware store, the chances are you discovered that...
Not really that bright
Lifespan is poor
They don't shine all night

The lack of charge/discharge protection for the battery (typically a single-cell nicad) has a large impact on the lifespan. But they are cheap.....

Time to build some seriously overkill garden lights! So this is what I came up with.

ATtiny45, Single-cell Lipo,1000mAh,  real charge control (CN3083), over-discharge protection, 2  superbright white LED's, serial o/p.
The AVR spends most of its time asleep, waking up now and again to monitor the solar panel and battery voltages. Every 2 min, this info is available from a serial pin (9600bd) which sends out a string like....
giving a human readable value of the voltages from the solar panel and battery. Handy during development to graph the charge/discharge curves.
Tracking the voltage from the solar panel allows for better detection of when it is actually dark. The AVR looks for a set of consecutive values below a threshold to decide if its time to turn on.

It does not turn on at dusk, but waits for near-dark (all tweakable in software of course).I did consider fitting a small 2.4Ghz radio module but held-off for this one, perhaps next version. I got some RFM70's to try off ebay (tiny!).

Overkill solar garden light

This is the circuit, or a better quality PDF from here

Its built on a small double-sided PCB about 40mm square. The PCB's were produced in Kicad and manufactured by Seed Studio's PCB service.

The LED string connects into the large screw-terminals.

In this application 2 LED's gives a good balance between available light and power consumption. The LED driver (ZXSC310) will run 6 leds but with a corresponding reduction of batter life.

The solar panels come from Seed Studio and are very well priced so I opted for the 1W version. You could probably get away with the 0.5W panel if you have loads of sunlight and the lights are positioned well or you dont need them to run all night.