Author Topic: Help with battery powered Moteino sketch  (Read 22253 times)

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Help with battery powered Moteino sketch
« on: May 04, 2016, 02:31:49 PM »
Hello Everyone -

I am new to the Moteino, having just received my first 5 units with the RFM69HW radio and flash onboard. I am looking to use it as a sensor node that measures the level of my pool water and transmits this information back to emoncms. I am using a product called eTape manufactured by Milone Tech and sold by Adafruit.

The sketch works great and does exactly what it is supposed to do, but I am monitoring the battery voltage (4 x AA) and just overnight I have seen a drop in voltage from 5.78 volts to 5.625 which means at this rate I will be replacing batteries often! I have read in several plaes to connect my batteries to 3.3V OUT as opposed to VIN.


Here are my connections:


A0 connected to 560 Ohm resistor
One side of eTape connected to same side of resistor and A0
Other side of resistor connected to 3.3V OUT
4 x AA Batteries connected to GND & also to same 3.3V OUT pin as above
Other side of eTape connected to GND


I used some of the code from a previous 'arduino' like unit to make it work and I just do not know
if I have somehow now set up the power reduction stuff correctly.

I have attached the sketch as well...any ideas would be greatly appreciated....



TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Help with battery powered Moteino sketch
« Reply #1 on: May 04, 2016, 02:47:34 PM »
Hello Everyone -

I am new to the Moteino, having just received my first 5 units with the RFM69HW radio and flash onboard. I am looking to use it as a sensor node that measures the level of my pool water and transmits this information back to emoncms. I am using a product called eTape manufactured by Milone Tech and sold by Adafruit.

The sketch works great and does exactly what it is supposed to do, but I am monitoring the battery voltage (4 x AA) and just overnight I have seen a drop in voltage from 5.78 volts to 5.625 which means at this rate I will be replacing batteries often! I have read in several plaes to connect my batteries to 3.3V OUT as opposed to VIN.
NO NO NO!  You can ONLY do this if you are using TWO AA batteries!  No more than 3.3V.
Quote


Here are my connections:


A0 connected to 560 Ohm resistor
One side of eTape connected to same side of resistor and A0
Other side of resistor connected to 3.3V OUT
4 x AA Batteries connected to GND & also to same 3.3V OUT pin as above
Other side of eTape connected to GND


I used some of the code from a previous 'arduino' like unit to make it work and I just do not know
if I have somehow now set up the power reduction stuff correctly.

I have attached the sketch as well...any ideas would be greatly appreciated....
Also, I have an alternative circuit for you for the eTape (which works REALLY well as long as you don't get the top connector strip wet).  I'll post the circuit in another post, hopefully later today.

Tom

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Help with battery powered Moteino sketch
« Reply #2 on: May 04, 2016, 03:08:29 PM »
4 x AA Batteries connected to GND & also to same 3.3V OUT pin as above
Did the Moteinos survive this?  :-\

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #3 on: May 04, 2016, 03:09:56 PM »
Tom -

Thanks! I looked everywhere for information on connecting batteries to the moteino and didn't find anything except people saying to connect it to the output and not the input.

The eTape that I am using is their newest version with the tape sealed in a plastic enclosure and the leads sealed in the top so hopefully I won't have any issues with them getting wet!

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #4 on: May 04, 2016, 03:12:24 PM »
4 x AA Batteries connected to GND & also to same 3.3V OUT pin as above
Did the Moteinos survive this?  :-\

Well it ran all night and is still running now...hopefully I didn't damage it too bad! If so, I have 4 more that I bought as well and now I know better!

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #5 on: May 04, 2016, 03:14:16 PM »
Interesting...now that I moved my batteries to VIN, my voltage as reported by the sketch is now only 3.31 volts so something is not right for sure (in my code)!
« Last Edit: May 04, 2016, 03:19:05 PM by G550_Pilot »

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Help with battery powered Moteino sketch
« Reply #6 on: May 04, 2016, 03:25:54 PM »
See https://lowpowerlab.com/forum/index.php/topic,1860.msg13476.html#msg13476 for my implementation.

Re your voltage reading, this sounds right to me, what did you expect?

Tom

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #7 on: May 04, 2016, 03:29:05 PM »
See https://lowpowerlab.com/forum/index.php/topic,1860.msg13476.html#msg13476 for my implementation.

Re your voltage reading, this sounds right to me, what did you expect?

Tom

Thanks Tom. Well I have almost 5.8 volts when I measure the batteries with my meter, I guess I was expecting 5.8 volts. I guess I am not sure why it would be in the 3 volt range, is there some limit to measuring voltage above 3.3v? Or is something in my code screwed up? (I reused this code):


Code: [Select]
long readVcc()
{
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
  ADMUX = _BV(MUX3) | _BV(MUX2);
#else
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif

  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA, ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
  uint8_t high = ADCH; // unlocks both

  long result = (high << 8) | low;

  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Help with battery powered Moteino sketch
« Reply #8 on: May 05, 2016, 08:36:13 AM »
When you use the internal voltage reference you can only measure the VCC of the MCU. That is 3.3v always for the Moteino since it is regulated from VIN (the "3.3v" pin is an OUTPUT from the regulator so never feed input to that pin, unless you desolder the regulator - in which case you should not supply more than 3.5v or you will damage the radio).
What you need is a voltage divider from your original voltage into an analog pin of the Moteino. Something like this.
« Last Edit: May 05, 2016, 09:34:30 AM by Felix »

davegravy

  • Jr. Member
  • **
  • Posts: 56
  • Country: ca
Re: Help with battery powered Moteino sketch
« Reply #9 on: May 05, 2016, 09:05:05 AM »
If you want to use the 3.3V input, you could take your 4 AA batteries and wire them so that you have two sets of 3V pairs in parallel... ie, 3V at double the AH capacity.

Then you could connect the battery pack to 3.3V, but you'd also need to set fuses to use the 8mhz internal oscillator, and de-solder the regulator IC.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Help with battery powered Moteino sketch
« Reply #10 on: May 05, 2016, 09:33:43 AM »
If you want to use the 3.3V input, you could take your 4 AA batteries and wire them so that you have two sets of 3V pairs in parallel... ie, 3V at double the AH capacity.

Then you could connect the battery pack to 3.3V, but you'd also need to set fuses to use the 8mhz internal oscillator, and de-solder the regulator IC.
An easier alternative is to remove the VR, get rid of 4 AA batteries and switch to 2 Lithium (Eveready Ultimate) AA batteries.  These will give you up to about 3.4V nominally and will last two summers with the right power management code and you won't have to change any fuses in the Mote.

Tom

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #11 on: May 05, 2016, 12:31:51 PM »
Thanks Everyone -

I really have no desire to run 4 x AA batteries, that is just what I had in hand for battery holders when I started this project. This is my first run with the Moteinos.

What worried me was that I saw a rapid decline in battery power when first running my code on the Moteino that was was running on another clone making me think that I do not have my power reduction stuff in my sketch correct. Looking at the drop, it looked like I would be replacing my batteries (Energizer Advanced Lithium) every two months.

So far I have learned NOT to connect anything more than 3.3V to the 3.3 pin and some other great information, but I am still lookng for some help in glancing over my sketch to see if I have made any obvious errors in my power saving than others familiar with the best practices with the Moteino may spot right away.

Thanks

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Help with battery powered Moteino sketch
« Reply #12 on: May 05, 2016, 03:14:55 PM »
I am still lookng for some help in glancing over my sketch to see if I have made any obvious errors in my power saving than others familiar with the best practices with the Moteino may spot right away.
Sorry, I TOTALLY missed that you had posted the sketch.  I've downloaded and will try to look at it sometime today.

Tom

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #13 on: May 05, 2016, 03:18:50 PM »
Tom -

Thank you!! It is much appreciated. I 'think' I have it right, but just don't know for sure.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Help with battery powered Moteino sketch
« Reply #14 on: May 05, 2016, 05:24:15 PM »
I looked at your sketch and, unfortunately, I know nothing about the jeelib library and can not comment on what power savings you should expect from that.

However, assuming that everything else is perfect, you have a relatively large current drain with your sensor wiring.   Because it is always powered the current (in mA) will be

Isensor = 1000 * 3.3 / (560 + Rsensor)

so, if your sensor is 560 ohms, you will have a continuous current drain of approximately 3mA.  This does not explain the large drop you were seeing, but running at 6V I'd say your radio is probably toasted, flash too (if you have it), and they would be a very large current drain.  Did you actually get any radio signal?

Tom