Author Topic: Looking for Radio-Only Low Power Code Examples  (Read 410 times)

handyguy

  • Newbie
  • *
  • Posts: 21
Looking for Radio-Only Low Power Code Examples
« on: January 02, 2019, 05:47:31 PM »
Hi folks. Long-time lurker, first-time poster.

I have a very basic project I'm trying to put together, mostly as a learning exercise but it has some practical (for me) applications. In short, I have 2 Moteinos ("sender" and "receiver"). The sender waits for a button click, and then sends a radio signal to the receiver to do some light blinking. Once the lights blink on the receiver it sends a radio signal back to the sender. Both are also connected to a gateway node for stats gathering, notification etc.

I've got it all working pretty well when everything is connected to power sources via USB and the motes are receiving full power, but my ultimate goal is to have everything battery operated. So I figure I need to go into low power mode, enable deep sleep, etc. That's where my troubles begin. The "blink" signal will come from the sender at random times, and must be processed by the receiver as soon as it is received, so a "watchdog" function on the receiver or some type of message queuing operation on the sender won't work for this application.

I've seen lots of examples of how to recognize and wake from a physical trigger (like a button push, sensor reading, or hardware interrupt) but little on how to identify and wake from a radio transmission (i.e., from the receiver getting the "blink the lights" message from the sender) then go back to sleep when done. The things I have found have been either partial information ("just use this and that interrupt"), refer to deprecated libraries or "future" functions (i.e., really old postings), or don't follow the whole process from beginning to end. I've read everything I could find on this forum and elsewhere, including the example sketches from the RFM69 repository (old and new). From that research I've learned a lot about all aspects of the Moteino and low-power operation, so it's not time wasted at all, and thanks to everyone who has taken the time to document all this stuff. But I can't seem to find a single, end-to-end guide on how to handle low-power, radio-only operation in a sketch that pulls all of these pieces together. If I could find a working example or even some code snippets for the core functions needed I know I could take it from there.

Can anyone suggest a source that could help me move this project along? Thanks in advance for any help.

TomWS

  • Hero Member
  • *****
  • Posts: 1877
Re: Looking for Radio-Only Low Power Code Examples
« Reply #1 on: January 02, 2019, 06:28:42 PM »
Search for "Listen Mode Wake"

handyguy

  • Newbie
  • *
  • Posts: 21
Re: Looking for Radio-Only Low Power Code Examples
« Reply #2 on: January 03, 2019, 08:11:34 PM »
Thanks, Tom. I made a quick pass through the search results and it looks like the information I am looking for is there. Not sure why I didn't put it together before, as many of the posts were ones I had previously seen. Anyway, thanks for the pointer.

One last (probably not) beginner question: what's the best way to determine the power consumption of my units so I can see if/how much power I'm using/saving on batteries? Is there someplace I can strategically place the leads of my multimeter to take continuous power readings?

Thanks again,

hg

TomWS

  • Hero Member
  • *****
  • Posts: 1877
Re: Looking for Radio-Only Low Power Code Examples
« Reply #3 on: January 03, 2019, 09:01:53 PM »
One last (probably not) beginner question: what's the best way to determine the power consumption of my units so I can see if/how much power I'm using/saving on batteries? Is there someplace I can strategically place the leads of my multimeter to take continuous power readings?
It depends on how much you want to invest in finding this information.  The Current Ranger would give you the best information you can get in a hobbyist price range.  You could place its sensing pins between the positive supply pin from your power source and the Moteino. 

The trickiest part of measuring power is that the load is extremely widely varying in time (from uA to 100 mA).  If your duty cycle is low, and you've confirmed this, the best thing you can do is to measure the load ONLY in the sleeping state - with low duty cycle, the bulk of your battery life is consumed by 'sleeping' current.  Measure this and then you can easily calculate battery life based on duty cycle and taking a swag at 'awake' current. 

For example, if you measure 7.5uA sleeping, that's pretty good ballpark to be in.  Then, if you wake up every 60 seconds to say that the temperature is pretty much the same as it was 60 seconds ago, your duty cycle is roughly 0.045/60 (assuming 45mS to get your packet transmitted) which gives you 0.075% duty cycle.  Now, multiply this by the power (100mA) and you have an average of 75uA power consumed for your frequent updates.  Now, report only every 10 minutes and this drops down to 7.5uA average power, only doubling your quiescent current - something you might be able to live with.  If you aren't 300yards from your radio, you'll probably be able to dial back the power and, if you're within 100 feet, you could get by with a W, rather than HW radio, and now your power is at a level that doesn't require a massive battery and you can actually report your slowly varying temperature much much faster than it's actually needed.   :D

Tom
PS: Any snarkiness you sense in this post is NOT aimed at you.  There are many who think they need to report ambient temperature every ten seconds...
« Last Edit: January 03, 2019, 09:03:49 PM by TomWS »

handyguy

  • Newbie
  • *
  • Posts: 21
Re: Looking for Radio-Only Low Power Code Examples
« Reply #4 on: January 04, 2019, 10:28:23 AM »
Tom,

No offense taken, and I love a good, well-placed snark. ;-)

The Current Ranger is a bit beyond the budget for now, so I ended up just placing the multimeter inline between the battery + lead and vin on the mote. That's good enough for my purposes. Thanks for the measurement tips, they'll come in handy as I tune down the power consumption on my project.

hg