Moteino RFM69HW putting radio to sleep immediately

Started by hexibot43, February 04, 2014, 01:32:21 PM

hexibot43

     I am seeing more battery usage than I had expected on my weather station node.  I wanted to ask if there is a problem with putting the radio right back to sleep after once initializing it.  If you are doing a Radio.sendWithRetry() do you need to wait before issuing the command to sleep? And lastly if I find I don't need all the power the radio  can produce, how do I turn it down?  Or can I?

Thanks,

Marcello

Felix

Can call sleep() any time.
No need to wait before sleep, sendWithRetry() does everything including the waiting.
Use setPowerLevel(0-31) to reduce output power.

Look in the header file for all available functions: https://github.com/LowPowerLab/RFM69/blob/master/RFM69.h


hexibot43

I'm curious how many times does radio.sendwithretry() try by default to get the data sent out?  I see the entry in the library has more entries than I was using.  My wife unplugged my Raspberry PI and the Gateway Moteino.  So there was no gateway there to respond, and confirm the data being sent successfully. Would the node sit there and continue to send until it gets a confirmation?  Or as I see it, if I don't supply a value for the last two pieces of data they would be given the values of 2 and 15 respectively. 

Everything was looking good with power consumption when I put a new battery in and tried again with the Base gateway back up and running. 

I've since modded my code some more to cut the time it is on in half.  I start the library for the Dallas Temperature Sensors, and instead of just waiting 750ms.  I then start up the DHT sensor library, which takes  approximately 500ms and then just add in a 250ms delay.  My loop is running at a little over 1000ms from start to completion now.

I had been running the sensors directly off the rail, and am going to quickly go back to powering them via the Moteino. 

My one year plan turned into a little over a week.  Oops.



Code grabbed from the RFM69 library -
bool sendWithRetry(byte toAddress, const void* buffer, byte bufferSize, byte retries=2, byte retryWaitTime=15);


Code as I had it on my NODE -
radio.sendWithRetry(GATEWAYID, (const void*) (&Packet), sizeof(Packet));

Felix

As seen in the header file, there are 2 retries, which means if the first try fails, it will retry 2 more times then return false if no success or true if an ACK was received at any of those tries.

fgomes

I'm calling the sleep() methode to reduce the power consumption, but the total power used by the RFM69HW plus the ATMEGA is very high (arround 80 mA) so it seems the radio doesn't go to sleep mode. The following code is at the end of the loop function, and should put the radio sleeping and the ATMEGA also sleeping using the lowpower lib:

  Serial.flush();
  radio.sleep();
  for(int i=0; i<7; i++)
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);


I have two doubts regarding the power consumption:

- Is it necessary any special precaution before putting the radio sleeping (calling the sleep() method)? I observe that the node is running the loop only about one time per second like it should (because it sleeps 7 times 8s according to the code above), but during this period it is still consuming a lot of power. I have removed the rest of the electronics connected to the board, the only thing that it is still being powered is the ATMEGA and the RFM69HW.
- Is it necessary to wake up the radio after the sleeping period? In the RFM12B lib there is a Wakeup method, but this is not present in the RFM69 lib.

Thanks in advance!

Fernando

Felix

80mA sounds very very very wrong. Maybe bad wiring or some kind of short, or hooked up some sensor or another device that eats current. The radio and atmega will not be higher than 20mA when fully awaken. In sleep mode you should be way under 1mA, probably a few micro amps.
How are you measuring the amps?

fgomes

Hi Felix

I'm measuring the current using a resistor in series with the supply, measuring the voltage on the resistor through a scope or a voltmeter, but for now please forget this issue, it seems it was a problem in my test setup. I was measuring using 3 AA batteries (nominal 4.5V), but since the batteries were a bit exhausted the voltage was lower, and with the resistor in series taking some more milivolts the total voltage that gets to the board was already below the minimum acceptable, causing these problems (I found out after posting here the problem that the total voltage that gets to the board was already about 2.4V, and this should be the problem). I'm now powering the node using a 5V power supply (through a 10 ohm resistor) and the node is working well and behaving as expected. During the waiting period the current is minimal, around 10uA (ATMEGA+RFM69HW+DHT22).

Fernando

Felix

Yeah 10uA sounds a lot better. Mind that if you got a FLASH chip you should put that to sleep as well to save a few more uA.
And no, there is no wakeup for the radio, just put it to sleep, then start sending to wake it up. For the FLASH however will need to call sleep() and wakeup().