We have moved at community.getvera.com

Author Topic: Battery powered Arduino sensors  (Read 23965 times)

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Battery powered Arduino sensors
« on: December 26, 2013, 02:07:24 am »
I've set up a temperature sensor running off a couple of AA batteries. Looks like the battery lifetime will be a year or more. However, I would like to monitor the battery Voltage as well as the temperature, just to keep an eye on it. So I have set up one of the ADC inputs to sense the battery Voltage as part of the temperature sketch and that works OK.

I would like the battery Voltage to show up as a battery device in Vera, so I can feed it to dataMine as a Voltage level. Question is - what's the best practice to do this?

I've looked through the typedef enum for "variableType" but there's no battery or Voltage mentioned. The typdef enum for "internalMessageType" mentions I_BATTERY_LEVEL and I_BATTERY_DATE. But I don't know what the internalMessageType does or how it is meant to be used.

I can't find any doco on the general procotol, so how should this be all handled? Does the typedef need to be expanded? Any guidance would be useful.

Thanks.
« Last Edit: December 26, 2013, 02:59:24 am by a-lurker »

Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Battery powered Arduino sensors
« Reply #1 on: December 26, 2013, 03:11:01 am »
Hi, could u share your scheme? I'm interesting in arduino u use, power supply how it was connected?
Thx!

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Battery powered Arduino sensors
« Reply #2 on: December 26, 2013, 03:42:50 am »
Use the "sendBatteryLevel"-method from your sensor. Also make sure to use the latest L_Arduino.lua plugin file as there were a bug that was fixed a couple of weeks ago.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Battery powered Arduino sensors
« Reply #3 on: December 26, 2013, 07:03:16 pm »
Software: Hek has already set up the software for battery operation. You can report the battery condition as a percentage (see above) and the low power sleep time can be set as well.

Hardware: I had one of these available, which is basically just a processor, a 3V3 regulator and a power indicator LED:

http://www.ebay.com/itm/Redesign-Pro-Mini-atmega328-3-3V-8M-Replace-ATmega128-Arduino-Compatible-Nano-/200914924969?pt=LH_DefaultDomain_0&hash=item2ec77675a9

It was modified for low power operation - see attached image - PCB layout varies depending on manufacturer:
1) disconnect the power indicator LED by cutting the track between the LED and the resistor in series. Saves about 1.5 mA
2) disconnect the 3V3 regulator as it's not used. Cut the Vout pin with a sharp fine wire cutter. Saves about 220  uA.
3) install the FTDI header excluding the Vcc pin connection. We don't want the PCB powered by the USB cable while programming it - a 3V3 FTDI was used - be careful you plug it in, the right way up:

https://www.sparkfun.com/products/9873

4) the device is powered by two AAs in series and connected to the PCB using one of these ultra low power step up convertor/power regulators:

https://www.sparkfun.com/products/10967

When powered down, the CPU, DS18B20 temp sensor and radio consume (very roughly) 120 uA - which is stuff all and similar to the self discharge rate of the batteries.

The battery lifetime can be calculated by determining the average current of the set up using the general equation:

I avg = (t0*I0 + t1*I1 ... + tx*Ix) / (t0 + t1 ... + tx)

Note these figures are indicative only - your results may certainly vary. Currents are measured at the battery with a battery Voltage of 3.0 V

idling:  I0 = 28 mA, t0 = 0.65 sec (using the delays I set up in the sketch)
transmitting:  I1 = 31 mA, t1 = say 50 mSec (time is just a guess)
sleeping:  I2 = 120 uA (very roughly), t2 = 15 minutes (the temperature sampling rate)

Using the above figures the effective current = 0.142 mA  The sleep current is difficult to measure accurately, so this figure may vary and that would effect the lifetime calculation.

Assume the  batteries are good for 2000 mAhr, then that gives a lifetime of 14,101 hours, which equals 19.6 months. The lifetime is pretty much dominated by the sleep current and sensor sample rate. Assuming the figures & calculations are correct (let us know if they aren't), it's likely the batteries would die partly of old age rather than through actual usage.

I used a 1 M and 470 K resistor in series, connected to the battery plus and ground and connected the tap point to the A0 input on the CPU. The tap point is bypassed with a 0.1 uF capacitor to keep the noise level low, at this otherwise high impedance point. The ADC is set to use the internal reference of 1.1V - so Vmax at ADCmax = 1.1*(1e6+470e3)/470e3 = 3.44V  That then has to be converted to a useable percentage to suit Vera's battery devices.
More info here:

http://maniacbug.wordpress.com/2011/10/19/sensor-node/

This site suggests the operating current while sleeping could be lowered even further:

http://www.gammon.com.au/forum/?id=11497

It could be argued that the step up convertor is not required at all - just connect the PCB directly to the batteries. A few pro and cons:
  • Operating Voltage is held at 3V3 versus the brownout detector threshold of 2.7V kicking in for a direct connection - noting the latter can be disabled.
  • Batteries can be sucked totally dry using the regulator.
  • Regulator is 80% efficient while a direction connection is 100%.
I suppose you could try both methods and report back in a year or so!

When you think that all this sophisticated stuff can still run using a few microAmps, you really have to wonder at how science has progressed electronic devices over the last fifty years. Pity the bits are so frigging small you can't see them without a microscope, let alone trying to solder them together.
« Last Edit: January 04, 2014, 07:06:41 pm by a-lurker »

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Battery powered Arduino sensors
« Reply #4 on: December 26, 2013, 07:20:48 pm »
Thanks for a great post a-lurker!

Offline MDoc

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +3/-3
Re: Battery powered Arduino sensors
« Reply #5 on: January 20, 2014, 10:36:05 pm »
Ditto A-lurker...Your post helped a lot.

I'm also looking at how low of current I can get.  I'm using a Pro-Mini 3.3V, with the NRF24L01 radio.
I've removed the regulator and LED... Hek is already turning off the BOD (Brown Out Detection) and the A/D Convertor in SleepDelay and SleepWDT.

Right now, I'm not using a charge-pump (using direct... two AA Batteries).  I wanted to see how low of voltage the Pro-Mini would operate.  I know the radio should be good down to 1.8V.  At 8MHz, I believe the Pro-Mini should be able to run down to 2.4V.  The problem is that once I get down to about 2.8V, it stops running.  Have you tested to see how low of voltage yours can run?

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Battery powered Arduino sensors
« Reply #6 on: January 21, 2014, 01:12:49 am »
No I haven't tried this - I decided to use the charge pump, so I got 3V3 no matter what. I was a bit concerned my sensors would stuff up. The spec shows maximum Frequency vs. VCC line for between 1.8 and 2.7 V. The line equation is V = (F-k)/m, where from the spec k = -8 and m =6.6666 so for 8 MHz:  Vmin = 2.4V

I had this all going well for a couple of weeks and the battery Voltage was still looking really good. Then - for reasons unknown - I think the node lost contact with the gateway (gateway crashed?). It looks like the node goes into continuous TX retries at that point, which flattened the batteries in just one day  :-X

I've not looked at what the retry code does - but it looks like some code mods are required for anything that is battery powered. All needs a bit more investigation LOL

Just on reporting the Voltage, I just got the raw ADC value and integer divided by 10. So 100% in Vera = so 3.44 * 1000/1023 = 3.36 Volts


« Last Edit: June 21, 2014, 06:47:25 pm by a-lurker »

Offline veravance

  • Sr. Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: Battery powered Arduino sensors
« Reply #7 on: January 21, 2014, 02:45:00 pm »
for a-lurker
i have the same problem. My Gateway crash very often and i must reboot it.
The node with the arduino pro  goes into continuous TX retries like you.

For the Gateway crash this could be a problem with the power of the vera's usb because i have also an usb stick connected ?

Offline MDoc

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +3/-3
Re: Battery powered Arduino sensors
« Reply #8 on: January 21, 2014, 03:37:30 pm »
Thanks A-lurker.

Also see that.  As the voltage drops,  at some point the transmit light starts flashing rapidly (around 2.7V in my board).... I guess this is what you're talking about.   I could see where that would suck the battery dry.

Currently (because I'm using direct batteries) I'm using the internal 1.1V reference to get my battery voltage and then calculate the % to send to the gateway.  For that calculation I need to know how low I can go (voltage) thus the reason for this test.

EDIT:  I've had no issues with my gateway.  It's just when I lower my supply voltage to around 2.7 volts, the transmit light flashes rapidly just as you saw some type of oscillation)  Once I raise the supply voltage, it stops and transmits normally.

« Last Edit: January 22, 2014, 07:09:08 pm by MDoc »

Offline Derek Macias

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
Re: Battery powered Arduino sensors
« Reply #9 on: January 22, 2014, 02:19:15 am »
The gateway crashing could be your usb hub.  I'm on my third hub. First one seemed to get hot and was a bit bulky.  So I bought a mobile one but upon reboot the serial port wouldn't work and took too much effort to get serial to show up. Switched back to old one but it gets hot and so does Vera. I found an Inland usb hub with 3 ports and 1 usb mini plug for cameras which is perfect for arduino nano.  Now if I can just get it inside my Vera lite with the arduino and radio.

Edit: It didnt work. Usb flash drive kept dropping and vera would freeze up.
« Last Edit: January 23, 2014, 05:23:35 am by Derek Macias »

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: Battery powered Arduino sensors
« Reply #10 on: January 22, 2014, 03:12:49 am »
@Dere Macias
Did you experience Arduino GW hangs on your previous hubs?
What is your experience with the hub in the picture? Is it a powered hub? Where did you find it?


I also have allot of failures of the Arduino GW and have tried 2 different hubs but both work as bad.

Is there anyone out there using the combination Veralite + USB hub + Arduino GW without any problems? In that case what kind of USB hub do you use??
- Tomas

Offline Derek Macias

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +4/-0
Re: Battery powered Arduino sensors
« Reply #11 on: January 22, 2014, 10:41:56 am »
I just bought the one pictured a couple days ago. When I rebooted Vera the serial port was listed. It's been working fine for a couple days. I felt it this morning and it was not hot. It is not powered. I bought it at Microcenter. Just Google "usb hub with mini" and look at the pictures. I have the arduino nano with button, leds, and nrf24 radio with external antenna in a Veralite box and a 4GB usb nub plugged in.

Also my previous hub that would get hot did have an external power port but I didn't use it and it didn't hang.  The laptop hub I think was having problems.  The serial wouldn't show up most of the time on reboot also.

Edit: The one pictured didn't work out.  The usb drive kept dropping off, causing vera to freeze.  So I'm back to the 4 port powered hub that got hot. I'm going to try it powered.  I think powering the hub might be a must.
« Last Edit: January 23, 2014, 05:21:24 am by Derek Macias »

Offline p3tter

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Battery powered Arduino sensors
« Reply #12 on: February 03, 2014, 03:12:24 pm »
is anyone using the arduino nano with motion sensor and batteries?
i have 3x AA batteries connected to the 5v pin on the arduino, but the battery drrains around 3% each day.
i have disabled the red led. is it some other things i could do to get the battery last longer?
thanks

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Battery powered Arduino sensors
« Reply #13 on: February 03, 2014, 03:24:03 pm »


It takes power to drive the Ultrasonic Sensor ... I do not know if there is startup/learning time for the sensor ..
You might power down the sensor and the Arduino and wake it up and check for motion once per second or 1/2 second.


Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Battery powered Arduino sensors
« Reply #14 on: February 04, 2014, 05:51:39 am »
Hi. can u help me plz
at http://code.mios.com/trac/mios_arduino-sensor/wiki/TipsAndTricks#Case3
there is an example:
Code: [Select]
// Send the Battery Percentage to the Gateway
#define VBatMax 3.1             // The voltage of New Batteries
#define VBatDropout  1.8    // The battery dropout voltage
gw.sendBatteryLevel((readVcc()-(Dropout*1000)) /(((VBatMax-Dropout) *10)));

What the "Dropout" is?