Author Topic: low power moteino node, but not enough??  (Read 5017 times)

mapal123

  • NewMember
  • *
  • Posts: 5
low power moteino node, but not enough??
« on: January 10, 2016, 06:12:57 AM »
Hi,

Looking for advice.
 I built a simple node (moteino + RFM69HW) it is supposed to emulate two nodes (21 and 23) :

- the first checks 2 reed switch to see if a window has opened (or was opened and closed) and sends the status only if there's been a change (this should happen every 8s)
- the second sends the temperature, but only every 8 loops (that is 64s)
At the end of the void loop i send the moteino to deep sleep for 8s.

After every radiosend I put the radio back to sleep.
I also send as low power as possible " radio.setPowerLevel(16);" should be the minimum I've read.

All this is powered by 3 x AAA rechargeable batteries and this made it last about 1 month. I was hoping more for 1 year or so, since I only send radio every 60s or so and do nothing special.
Something I forgot?   Could someone give a look at my code? it's not so clean I now, but also very short..

Thanks in advance!!

pyndot

  • NewMember
  • *
  • Posts: 6
Re: low power moteino node, but not enough??
« Reply #1 on: January 11, 2016, 12:08:30 AM »
Hi mapal123,

Firstly, why are you using two radios/nodes? Can't you send both sets of data through the one node?

Anyway that question aside from a quick read of your code you have put in a delay(10) between radio.sendwithretry() and radio.sleep()... You should be able to sleep the radio as soon as sendwithretry has completed. As the code stands the motino is awake a lot longer than it is asleep because of your use of the delay function.

Also I think that setting the radio power level to a low value may be counterproductive when used with sendwithretry. It may just make the radio retry more often since you are only broadcasting with the week signal?? This will depend on how far  apart your nodes are of course... (I may be wrong about all this - anyone please step in if I'm missing something).

mapal123

  • NewMember
  • *
  • Posts: 5
Re: low power moteino node, but not enough??
« Reply #2 on: January 11, 2016, 08:23:02 AM »
Hi, I am using one physical nodes, but different messages are sent for temperature and window status, so my gateway "sees" two different messages.

- I saw somewhere the delay to be sure that transmission is completed but maybe it serves no purpose.
Also I thought 10 ms was pretty small compared to 8s sleep mode but if it's no use I will take it out.

- I set the power very low because my nodes are just a wall apart and even with that the RSSI received by the gateway is pretty high (-50/-60 I think), but I'll check again just in case.

- I also hope the temperature sensor is not consuming anything in sleep mode (I connected his VCC to a digital pin that I raise and lower).
Still I read that the DHT11 takes a lot of time for taking the reading, so maybe even reading temperature every 8 cycles (64s) is not neglectable.

Does the RFM69 radio "lights up" when the moteino comes online?? Because in that case energy is spent even when no message is sent (no new windows status, nor temperature sent...)

Can you guys see other current leaks? I mean did I implement the sleep mode correctly, as well as radio off?  Do you have a way to simulate arduino and know how much time it is on or keeps it on?

From the examples I saw by Felix and other people here, I honestly thought that with my simple sketch 3xAAA would power the moteino for at least 1 year no problemo..! If I can get only 1 month of power then my following projects will be probably have to be revised..

Thanks everybody for any ideas / advices!!

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: low power moteino node, but not enough??
« Reply #3 on: January 11, 2016, 08:31:33 AM »
You could use RFM69_ATC and set the target RSSI to -80 to -90, then that will be automatic. See my recent blog post about that.
Then of course you must ensure all your hardware is sleeping in the lowest possible power mode. Moteino has the atmega, the radio, the optional FLASH. Then any sensors that can be cutoff from power should be. Reduce any current spikes as much as you can and eliminate blinky LEDs if not needed. How much runtime you'll get is hard to guesstimate but 3xAAA should last a long time if you do it right.
Rather than guessing your way through, do it the scientific way and hook up a multimeter and/or scope to see what your circuit is doing.

spambake

  • NewMember
  • *
  • Posts: 9
Re: low power moteino node, but not enough??
« Reply #4 on: January 11, 2016, 01:29:44 PM »
I'm not sure it enough to matter but it looks like your reed relays might be eating up some power.  If the relays are normally closed they will draw continuously through the pullup resistors.  Probably less than 300uA but more than the other parts.

mapal123

  • NewMember
  • *
  • Posts: 5
Re: low power moteino node, but not enough??
« Reply #5 on: January 11, 2016, 03:20:59 PM »
Well, my question then is specifically about standby mode

To use my reed sensors I pull them up in the setup and the other end is connected to Ground.
pinMode(PIN_FINA,INPUT_PULLUP);

So, when the window is closed the current is indeed flowing from the pin to ground  but this should happen only when the sensor is not in standby, so during a very short time compared to 8sec sleep.

Shall I pull them down to 0?

For the DHT11 temp/humi sensors, I am feeding them VCC through an output "switching them on before reading and off after.
Is this correct?

digitalWrite(PIN_V_DHT, HIGH);
    float h = dht.readHumidity();
    float t = dht.readTemperature();
    digitalWrite(PIN_V_DHT, LOW);   


So basically, during sleep mode issued with this command
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
I was thinking all the digital pins would be off and no current would flow to ground (through the closed reed switches).
Is this incorrect? Do you think current is still flowing somewhere?


Thanks , I will try to measure although I don't know if my multimeter is accurate enough, and if I can catch sleeping time..

Actually it would be very interesting to know how long last the different parts of the code to know how long is the radio on, how long does the temp sensor read and so on...but I guess I'd need some advanced simulator, or a cool oscilloscope for that..!!
« Last Edit: January 11, 2016, 04:45:14 PM by Felix »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: low power moteino node, but not enough??
« Reply #6 on: January 11, 2016, 03:25:37 PM »
Looks and sounds correct. But it's pointless to keep on guessing where the problem might be, it's like chasing chickens.
Do you have a true RMS multimeter?

mapal123

  • NewMember
  • *
  • Posts: 5
Re: low power moteino node, but not enough??
« Reply #7 on: January 11, 2016, 03:36:08 PM »
Yepp I think the multimeter is RMS.

Now the sensor is inside a box near the ceiling with recharged batteries, but I'll put together a second prototype with a spare moteino and longer delays to let me measure the different states.


Last two questions, then I'll stop guessing and try to give you some current measurements in the next days.

1) When the moteino comes back from standby does it run setup() again, or does it goes back to void() loop?

2) So, is the RFM69 radio switched on coming back from standby, or only when the send routine is launched (this could have an impact I guess lastly...)

Thanks  ;-)
« Last Edit: January 11, 2016, 04:45:27 PM by Felix »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: low power moteino node, but not enough??
« Reply #8 on: January 11, 2016, 04:51:11 PM »
setup() only runs 1 time after atmega328 Reset.
RFM69 is not switched on unless you switch it on, has no reason to automatically do that right?
Standby is very different than sleep, I assume by standby you mean sleep.
« Last Edit: January 16, 2016, 10:00:21 PM by Felix »

spambake

  • NewMember
  • *
  • Posts: 9
Re: low power moteino node, but not enough??
« Reply #9 on: January 11, 2016, 05:46:07 PM »
Quote
So, when the window is closed the current is indeed flowing from the pin to ground  but this should happen only when the sensor is not in standby, so during a very short time compared to 8sec sleep.

Shall I pull them down to 0?

The pullup persists in sleep mode, so you should cancel the pullup before sleep and reset it after sleep.  I don't know if just setting the pin to INPUT will cancel the pullup.

Quote
1) When the moteino comes back from standby does it run setup() again, or does it goes back to void() loop?

To be accurate, the code just continues executing after sleep mode.   So if you had additional code after sleep it would execute and would not go directly to loop().

I have more guesses but I agree that it is time for a multimeter.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: low power moteino node, but not enough??
« Reply #10 on: January 11, 2016, 08:43:58 PM »
From the examples I saw by Felix and other people here, I honestly thought that with my simple sketch 3xAAA would power the moteino for at least 1 year no problemo..!
Yes, you can get one year from AAA batteries if you work at it.  A AAA battery will supply approximately 1200mAH, which, if you want to run for a year, means that your average current needs to be less than 137uA.  Wow, that's a lot!  However, it's not a lot if you're using 8second power off intervals with 10s of mS on times (where ON = 16mA or more).  After you work on this a bit, you should be able to get below 25uA average current, but you need to understand what it takes to get there.

The recipe for maximum battery life is knowing:
1. how much power each of your devices consume when ON and when sleeping.
2. knowing how often you NEED to send data.  Does the parameter you're sensing really need 8 second sampling time?  What will you do will all this data?
3. knowing and being able to control when each device is ON and when it's sleeping or OFF.
4. running your processor at a speed commensurate with the task.  If you're just moving data, 8MHz or less is sufficient (hint: 8MHz is a very important number)
5. providing just enough voltage to perform the task and devices you need.  Do you need 4.5V?  I doubt it.
6. learn enough about battery technology so you know what kinds of batteries will supply the voltage you need without wasting power reducing too much voltage to the voltage you need.

Others have provided good tips for the programming side if you understand this basic recipe.

AND, finally, good for you for asking questions and welcome to the 'clan'!

Tom

mapal123

  • NewMember
  • *
  • Posts: 5
Re: low power moteino node, but not enough??
« Reply #11 on: January 16, 2016, 11:22:14 AM »
Hey,

first of all thanks everybody.

I managed to did some measurements. The problem was indeed with the "input_pullup" that stays on while the device in powerdown/sleepmode. And since when my windows are closed, reed switch is short circuit, current is always flowing from pins to ground.

Now I put my window pin in pullup only before measure and then back to output low.

So for the measurements:
- Around 7 mA during loop, no idea how much when the radio is transmitting
- 0.02 mA if sleeping but 0.12 if a switch is closed and 0.21 when two are closed.

So basically when pullup is on 0.1 mA per pin are flowing always into ground.

Since the rest of the circuit seemed ok and with the old sketch I got around 1month and a half of working time,  with this small improvement I will hopefully get almoust 1 year with 3 AAA battery, more then enough...!
I could also lower clock rate but will do this another time.

Next step, play with more sensors, maybe implement interrupts to wake up moteino, and build a kind of alarm system,
but main hard task are:

- MEASURE BATTERY VOLTAGE to know when to change batteries.
- build nice looking small plastic boxes to encase the sensors.

Both are paramount for having something of practical use and install it in family's houses!

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: low power moteino node, but not enough??
« Reply #12 on: January 16, 2016, 06:53:56 PM »
Hey,

first of all thanks everybody.

I managed to did some measurements. The problem was indeed with the "input_pullup" that stays on while the device in powerdown/sleepmode. And since when my windows are closed, reed switch is short circuit, current is always flowing from pins to ground.

Now I put my window pin in pullup only before measure and then back to output low.

So for the measurements:
- Around 7 mA during loop, no idea how much when the radio is transmitting
- 0.02 mA if sleeping but 0.12 if a switch is closed and 0.21 when two are closed.

So basically when pullup is on 0.1 mA per pin are flowing always into ground.

Since the rest of the circuit seemed ok and with the old sketch I got around 1month and a half of working time,  with this small improvement I will hopefully get almoust 1 year with 3 AAA battery, more then enough...!
I could also lower clock rate but will do this another time.

Next step, play with more sensors, maybe implement interrupts to wake up moteino, and build a kind of alarm system,
but main hard task are:

- MEASURE BATTERY VOLTAGE to know when to change batteries.
- build nice looking small plastic boxes to encase the sensors.

Both are paramount for having something of practical use and install it in family's houses!
Good work! Good job sticking to the problem and analyzing cause and effect, plus following up on verifying the cause - very nice.  Congratulations on joing the microamp club!

Be aware that to "MEASURE BATTERY VOLTAGE" will require either very high value resistors or a 'load switch' arrangement that will switch off the resistor divider when not measuring if you want to prevent the battery monitor from draining away your microamps.  Personally I prefer a load switch, but this will require more circuitry than the high value resistors.  With high value resistors you only need to add two resistors (to divide down to < 3.3V) and a capacitor (0.1uF) to the analog input.

Tom