Battery powered Arduino sensors

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.

Hi, could u share your scheme? I’m interesting in arduino u use, power supply how it was connected?
Thx!

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.

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:

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

  1. 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 = (t0I0 + t1I1 … + 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:

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

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:

[ul][li]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.[/li]
[li]Batteries can be sucked totally dry using the regulator.[/li]
[li]Regulator is 80% efficient while a direction connection is 100%.[/li][/ul]

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.

Thanks for a great post a-lurker!

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?

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

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 ?

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.

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.

@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??

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.

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

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.

Hi. can u help me plz
at TipsAndTricks – Arduino Sensor Plugin
there is an example:

// 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?

The voltage at which the battery does not have enough power to power the arduino.

  • Garrett

I see, but there is no such a var in this code. The correct is “VBatDropout”?

It should be VBatDropout, not DropOut. The code returns 100% at VBatMax (3.1V) and 0% at VBatDropout (1.8V). readVcc() returns the current Voltage in milliVolts.

Yep, My bad! axii… can you change Dropout to VBatDropout in the calculation sent to the gateway?

It is necessary to power up the radio all the time when waking from sleep. Or may be will be better to power up the radio if only temperature has changed .
Will it save some mA? Or radio needs some time for power up befor sending data?