2009 June

June 2009


For the next version of the widget,  I’m planning to have an on board boost regulator.  This design will allows the widget to run from just about any voltage source as low as 0.7v (so NiMh will be fine) and up to 5.5v, this boost regulator in conjunction with a standard LDO regulator will give me a nice input voltage range of 0.7v – 12V.  Before I finalise the design I wanted to test things to see how well it’ll work. 

I ordered in a couple of battery holders from Polou with an integrated boost regulator, since the widgets are designed for 3.3v operation I ordered this model http://www.pololu.com/catalog/product/796,  that provides a 3.3v 100mA supply from a single AA battery, I’m not too sure what the minimum voltage is, but is running fine on a single NiMh cell.

Well today they arrived and I now have one hooked up to my solar powered widget.  Installation was simple as the small pcb on the rear of the battery holder allows me to direct access to the cell contacts, so I soldered the solar cell +ve and –ve on the respective contacts.

Solar Widget Single AA Battery

From some previous tests with my solar powered widget, I was finding that the batteries would start charging when the solar cell output reached around 2.8 –2.9v, this is fine for during the day with the solar cell in direct sunlight, now with the single cell I’m finding that inside under artificial light I’m charging at around 1.5v, with plenty of overhead left.

You can see below the voltage output of the boost regulator is ~3.3v (3.322 to be exact) and the voltage from my solar cell is ~1.52v, this is inside under some standard down lights while writing this post at the kitchen table (actually one of the down lights is dead so I could expect a little more output from the cell)

image

Just to try something different I removed the battery, seeing if the regulator could run direct from the solar cell, unfortunately it doesn’t, I doubt the cell in the current light conditions can provide enough start up current for the regulator,  I will however try it in the natural sunlight tomorrow.

With the addition of the boost regulator, and the widget in max power savings between sensor reading (when asleep widget is drawing 1.5uA, which is most of the time) then the widget should run indefinitely from the single cell….or maybe I could just get away with a solar cell and a super cap now there’s a future project….

Just thought I’d post an update on what’s happening in the widget development world.

Limited Production Run

I have a very limited number of widget kits available for purchase.  This limited batch of widget kits also include a bare prototype personality at no cost with each widget to get you started in your wireless applications.

Introductory price of $US25ea (or $20ea for 5+)  include headers, bare prototype boards, 10Mhz low profile crystal, switch, all smd components are pre-assembled and tested, latest bootloader and RFM12 test program loaded.

Options:

SMA Pigtail: $2.50 for externally mounting SMA antenna.

SMA Edge: $2.50 for mounting SMA antenna onto PCB

SMA R/A antenna 900Mhz only: $4.50 to suit SMA connectors above

CR123 Battery Holder: $2.50

I’ve yet to get full details and pictures available or a means to order online yet, so contact me in the mean time if you’re interested, please let me know the band of the RF module required when ordering, e.g 915Mhz, 868Mhz or 433Mhz.

New Bootloaders

The v1.1 of the widget bootloader for 8Mhz and 10Mhz boards are now available in the download area.  These have been updated to incorporate the onboard LEDS and provide visual indication when entering the bootloader.

Source now in SVN

All the arduino source that I’ve changed for the widgets is now in SVN on the project page.  This includes:

  • Bootloader source.
  • modified boards.txt that include the 8 and 10Mhz versions of the RFM12Widget. 
  • Modified wiring_analog.c to read Widget battery voltage.

This can be checked out/copied directly to your arduino install directory by overwriting the existing files.  The arduino environment will need to be restarted for the boards.txt file to take effect.

V1.1 PCBs

I’ve started incorporating the user feedback into the next revision of PCBs.  Still a bit of work to be done on the PCB layouts.

Widget Mesh

Started preliminary design for a simple mesh network. 

Ultimately I would like to have the ability for the widgets to provide Zigbee type functionality (not compatibility)  along with frequency hopping as standard,  that is transparent to the application.  Only very early days so far.

The other day while playing around with the ADC on the widget I had some problems with noise causing the reading to bounce around, It needed some form filtering to remove the noise.   Normally almost everyone seems to take a number of readings and then average the result, unfortunately this takes time.

I came across this simple low pass filter on EDN.  A Low pass filter works by blocking the higher frequency (in this case noise) and allowing the low frequency signal (in this case the underlying signal) to pass. hence the name.  Perfect in cases where measuring slow moving signals, like temperature etc.  The algorithm is fast, simple to implement and works a treats.  It can be made to filter faster for a more response to change or slower to give more filtering.

#define FILTER_SHIFT 3
int32_t filter_reg;
int16_t filter_input;
int16_t filter_output;
 
filter_input = analogRead(0);                 // read ADC
 
// low pass filter to get rid of noise
filter_reg = filter_reg - (filter_reg >> FILTER_SHIFT) + filter_input; 
filter_output = filter_reg >> FILTER_SHIFT;   

 

The algorithm is a classified as a leaky integrator, where the latest reading have more weight than the older reading.  So you take a single reading each cycle of the sensor loop and feed that into the filter, the output is used you would normally use the raw value.

The response of the filer can be adjusted by the FILTER_SHIFT, to make it more responsive, then lower this value, to give better filtering and hence a slower response then increase this value.  For my application I found that a value of 3 to 4 worked well, but will depend on the underlying application.

I suggest you read the full article for an in depth description.

I want to deploy widgets around the home, both inside and out,  so I needed to find something that would allow some protection from the environment to the electronics, cheaply and easily.

On the weekend while doing some shopping I found the solution in the kitchen area of the local discount store, at $1.50 a piece it was the right fit for the job.  They probably won’t like U/V in the long run, but will see how they go, at that price I can replace cheaply.

(click picture for more details)

Waterproof/Dustproof housing with easy access to the internals.

This will be the standard sensor node housing.  The widget Boards and battery pack are fixed via velcro so I can easily remove for reprogramming etc. 

I still need to look at airflow of sorts for temperature, humidity and pressure sensors, will probably look at putting a couple of small vents in, this will compromise the waterproofing.  

To mount these I can put some velcro on the back and mount it on any horizontal or vertical surface.

Widget waterproof Housing

 

Open and showing details of SMA pigtail connection, batteries (x2 AA side mounted) and widget board velcroed to the container (personality board removed)

Widget Waterproof Housing Detail

 

Same as above, but this is for my outside sensor nodes where I’ve mounted a Solar Cell sealed on the outside, I did some initial testing and there was a filtering effect of the plastic lid and the cell, so I  decided to put the cell on the outside to get maximum efficiency, it was a pretty messy job after I used silastic to seal everything, the cell now has a smear of silicone haze across it that is appearing very difficult to remove.  So in future I think I’ll live with the slight degraded Cell performance and mount it inside, where it fits perfectly, that way I can use a couple of blobs of hot glue to fix the cell to the lid.

Solar Powered Widget

In my previous blog entry I described adding a solar cell to the widget and how I could measure the voltage produced by the Solar Cell, however I still need to monitor actual battery voltage easily, and preferably with not a lot of additional hardware.

Problems reading ones own voltage.

Measuring ones own voltage has a couple of problems:

  1. You can’t just measure VCC directly, i.e. you can’t connect an analog pin to VCC.  The reason is the battery voltage varies, and since the default AREF is tied to VCC you will always read VCC unless you use some form of a reference not tied to VCC.

  2. I can also use a reference diode and a resistor between VCC and GND, to form an external reference voltage, the diode has a known voltage drop across it so this can be measured using the default AREF.  We can calculate the battery voltage by measuring the volt drop across the diode.  While this will work, the circuit will always consume a small amount of power, even when not being used, remember I want to get as much life out of my batteries as possible.  So it rules this out as a solution.

  3. For the same reasons as 1) I can’t use a simple voltage divider and the default AREF.  As the voltage varies so too will my readings.

  4. I can use a simple voltage divider and the internal 1.1v bandgap reference for my AREF, the same as I used for my solar cell voltage monitor in the previous blog entry.  Again this will work, but also as in 2) this will always consume  some power even when not being used, so is ruled out as a solution in this case.

No Extra components?

We can however measure VCC voltage with no external components by simply reading the value of the internal bandgap reference voltage (1.1v) which is always fixed regardless of the battery voltage,  and by using the default AREF which is tied to VCC, so will vary as the battery voltage changes.  We now have a way of measuring the voltage change against a fixed reference.

V_BAT =  (VREF * 1024) / analogRead(14);

Where:

V_BAT :

battery voltage

VREF:

fixed reference voltage in this case 1.1v, but could be referenced to an external reference.

analogRead(14):

raw ADC reading from MUX channel 14

 

You might see in the above formula, that analogRead() function is reading channel 14.  But analogRead() only supports channels 0-7 right? 

Correct, but what we are doing is to read the internal ADC channels after we make a small change to the Arduino source code.

Changes to “wiring_analog.c”

To take an ADC measurement of  the internal bandgap we need to switch to ADC MUX channel 14 (23.8.1 in reference manual).   However to do this with the arduino wiring library we need to make changes to “wiring_analog.c” as per http://code.google.com/p/arduino/issues/detail?id=10.  This change allows us to read from all ADC MUX channels, internal and external.

Example

Once you’ve made the change to “wiring_analog.c” then use the following example sketch to read your VCC/Battery Voltage.

uint16_t raw_bandgap = 0;      // Internal bandgap reference
float volt_battery = 0.0;
 
void setup(){
  Serial.begin(57600);
}
 
void loop(){
  // Read Battery voltage
  analogReference(DEFAULT);                          // use VCC as AREF
  raw_bandgap = analogRead(14);                      // read and discard first result after changing reference (see 23.5.2 of manual)
  raw_bandgap = analogRead(14);                      // measure internal bandgap voltage
  volt_battery = (1.1 * 1024) / raw_bandgap;         // calculate voltage
  Serial.print(volt_battery);
  Serial.println(" v_bat");
  delay(1000);                    
  
}

When this method won’t work.

If you have a voltage regulator or a protection diode inline between your battery and VCC, then this will only show the voltage at VCC, not the true battery voltage. 

If you have a voltage regulator then you will always read what it puts out, and not give a true indication of battery voltage.  I guess you could still use the method as a form of low battery measurement.  i.e. when the battery falls below regulation values I guess the regulator will fail to regulate and you should get a lower than normal reading.  however I haven’t tested this theory.

If you only have a protection Diode then measure the volt drop across it and compensate in your calculations, it will still give you a good indication of battery voltage.

Update:

Some other uses for this method is for auto-calibration of sensors as described by ladyada(you need to go to the bottom of the page)

 

Solar Powered Widget board

One of the tasks I want to use the widget boards for is a Wireless Sensor Network around the house for measuring environmental values.  The sensors that I want to live outdoors will need to be self sufficient in terms of power, so I wanted to see if I could charge the batteries via solar, of course this can be done, but again I want to do it as cheaply and as simply as possible, I also want the widget board to monitor the solar voltage and report it back.

I already had a 3.6v 0.2w cell that I picked up some time ago from Sure Electronics for about $10 for 5.  The spec for this cell is max voltage (under load) is 3.6v and max current is 60mA, more than enough to trickle charge x2 AA NIMH batteries. 

The Batteries should not require much of a top up as the node will be sleeping most of the time, from the power saving discussion @ JEELabs, by adding the solar, I should be able to just leave the node without having to change batteries (replacing failed batteries aside).

To measure the voltage produced by the solar cell I need a voltage divider that would produce 1.1v max @ 3.6v.

Why 1.1v I hear you ask?  The reason for the A/D full scale input voltage of 1.1V is that I’ll be using the ATMega168 internal bandgap reference as the AREF source for the onboard A/D and not the default AREF. 

There are a couple for reasons for this.  The internal bandap reference itself is a 1.1v voltage reference, because the battery voltage may change over time (remember I’m not using any onboard voltage regulators) so as the VCC / battery voltage changes, so would my A/D voltage readings unless I use a reference voltage.   Now as the reference is 1.1v this means that my input must not go above 1.1v else I will go over scale and get an incorrect reading.

I’m not going to bore you with the math so a quick calculation using an online voltage divider calculator (http://www.daycounter.com/Calculators/Voltage-Divider-Calculator.phtml)

Input Voltage = 3.6v

Output Voltage = 1.0v  (remember I don’t want to go over 1.1V so I’ve given myself some headroom)

Gave the values for R1 = 26K and R2 = 10K

Luckily I had both these values, however for the 26K I only had  one in 5% tolerance, the 10K I had as 1% (I like to use low tolerance resistors for voltage dividers so my error is minimised),upon testing the 26K resistor actually read 26.4K on my meter, so after plugging these real values in my actual FS Vout is 0.989v, pretty close to 1.0V.

A blocking diode is also required to prevent any damage to the Solar cell by the batteries, see the circuit and photo below.

(Click for larger image)

image

(Click for larger image and notes)

Solar Powered Widget Board

Arduino Sketch to read the voltage produced by the solar cell, next step is to find a waterproof housing and add some environmental sensors. 

Another benefit of taking voltage readings of the solar cell is I now have a light sensor.

int raw_solar = 0;        // Raw Solar FS ~ 1.0v
int raw_bandgap = 0;      // Intenal bandgap reference
float volt_solar = 0.0;
 
void setup(){
  Serial.begin(57600);
  analogReference(INTERNAL);  // select internal reference for AREF
}
 
 
void loop(){
  
  raw_solar = analogRead(0);                         // read solar voltage raw values
  volt_solar = (raw_solar * 1.1 * 3.617) / 1024;     // Scale ADC input.  (voltage divider r1= 26.4k  r2 = 10k  vi=vo/(r2/(r1+r2)) = vo/.2777 =  vo * 3.617
  Serial.print(volt_solar);                          // display raw solar voltage reading
  Serial.println("v");  
  delay(1000);                    
  
}

Switch to our mobile site