Best way to power digital input (switch)?


#1

So, with Photons I’ve gotten lazy and supply power from 3.3v to the switch and have pull-down resistors on the inputs. That’s not a good technique with the bluz due to battery life issues.

What I’m wondering is what’s the “best” way to power external switches that are brought into digital inputs. I guess if it’s being used with an interrupt, it needs power all the time. However, if I have a loop that runs, say, every 1 to 5 seconds, should I use a digital output to power the circuit or simply tie into 3.3?


#2

It all comes down to how much time the switch spends closed.

When it is open, the only current flowing, even with an external pulldown, is the input leakage current for the nrf51 chip (which I can’t actually find documented in the product spec) - but should be in the fractional uA range.

Only when the switch is closed do you have significant current flowing through the pulldown. If that concerns you because the switch is closed for long periods, you can increase the value of the pulldown, as long as you are aware of what that will do to responsiveness (since the time constant of parasitic capacitance and the pull down will increase.)

You are correct, for ultra-low power applications, you can power the high side of the switch from a GPIO pin, instead of Vcc, and only drive that GPIO high when you want to read the switch state. Be aware that the time constant I mention above will have an effect, and you will likely need to let the output pin settle before taking a reading,


#3

Thanks for the feedback.

I’m looking at updating my present wall-powered non-bluz garage door system to a battery powered bluz system to eliminate some of the wiring. I’ll also have a Photon connected to a ControlEverything 2 relay board to operate the doors.

I think I’ll opt for a period of, say, 5 seconds to have each bluz wake up, sense the condition of its switch, push an update to the cloud if it’s different and then go back to sleep. I’ll just wire a digital output to the switch and have the other side of the switch tied to a digital input configured with an internal pull-down.

I’m hoping with this configuration, I can get at least a year out of a CR2032. Otherwise, I’d simply use a Photon and a wall adapter since there’s an outlet next to each door.


#4

:thumbsup: excellent ultra-low-power coding.

However, be aware of the data in this thread.

The radio wakes up at 30mS intervals (can be cranked back to 4 sec, I believe, but not easily just yet)

The CPU wakes up at 100mS intervals and runs stack/loop() stuff.

Ideally, I’d like to see hardware timers wake us up, and the CPU stack/loop() stuff be configurable. For instance:

  • I could declare that loop() is totally empty, don’t even bother running it, everything happens off timers/interrupts
  • The frequency of stack calls could be tuned to the radio cadence (not much point running the stack at 10Hz when the radio is running at 0.25Hz.)

So your desired endpoint may require a few more features to roll out before you realize the full battery life, but I’m confident that we can get there.