Photon power and delay()

So, hopefully simple question. Does delay busy loop or is it a true low power operation where the CPU is idle? I’m curious about this, as I’m trying to maximize the time I can run an LED display off of battery. I’m not talking about sleep, just how to run a program such that it consumes as little energy as possible. If delay() isn’t good, what would be a good alternative?

Some quick searching tells me that a delay(ms) loop basically polls to see if the time has passed with arduinos. This behavior could be very different on the core/photon though, it is completely dependent on how delay(ms) is written in the firmware. I don’ think it reduces power consumption though.

What are you planning to show on the LED display? Does it require WiFi? If not, you will save a lot by turning the WiFi module off by using wifi.off(); . Differently, if your display has memory it will remember what it has to show even when you disconnect the photon as long as the display still gets power.

If you require WiFi, you could check once per hour for new data and put it to sleep in between that to save power.

Edit: How about e-ink? You can put text on it and then completely disconnect it from power, it will still show your text! :smile: To infinity… and beyond!

1 Like

@TheHawk1337 is right there, on Core/Photon delay() is just looping and even servicing the cloud connection from time to time, so there is no power preservation in using delay().

But as also pointed out there are several ways to preserve energy - one easy one to start with: Rather use a Photon than a Core :wink:

Others are

  • turn off WiFi when not needed
  • look into the different sleep modes
  • trim your external power consumption (eInk is a good one :+1: - even OLED should do better than LED)
1 Like

No, this is just a few NeoPixels, only have Photon’s, nothing too big. I can turn off WiFi, but I use WiFi to sync time for calculating sunrise and sunset accurately. I also use it so I can reprogram and run a couple of functions to change which LED pattern is running. I think I can turn WiFi off and on every now and then pretty easily, which would do a lot. If it’s only on for a few minutes every hour (say 5 minutes at the top and 5 at 30 past), then that saves 5/6 the energy anyway.

That may be the best choice. I get some flexibility and save a lot of power over the long run. Thanks for the suggestion. Digging into WiFi seems to be the right path. Will take other suggestions though.

If you only want to check sunrise/sunset times and sync time then connecting once per day should be plenty(the internal timer is pretty accurate so once per day sync is fine).

I’m pretty sure that with WiFi off the NeoPixels are the most power hungry so you could reduce their power consumption by making them less bright :smile:

1 Like

To sync time, I’d agree again with @TheHawk1337 - once per day or even less often should give you enough precision.
As for OTA or WiFi functions you could incorporate a button that connects/disconnects WiFi when needed.

2 Likes

I may be able to do a button, but it’s tough. This is a hack on the instructables TikiTorch, but more flexible. However, it’s still uses a Tiki pole outside, so I’m limited in what I can do without some aesthetic compromises. A button, even a small one, might be difficult or ugly.

Interesting idea though if I can figure out how to make it work.

Have you got space in the top section of the torch?
The button doesn’t need to be external. If you use a print button accessible through a peep-hole (e.g. via paper clip) you’ll not see it at all.
You’ll want to hide the Photon anyway, I guess, so there should be a concealed place for the button too.

Or use an optical switch, like an IR receiver :sunglasses:

I use a reed switch inside my case and a magnet to keep my photon awake for OTA updates. Nothing visible on the outside and since my case is outside, no holes for water to get in.

5 Likes

Good thoughts. I’m going to look into it as an option this week. Thank you.