How long to stay connected for

When the Imp connects to wifi it consumes much more power (battery in this case) than when sitting idle. What is the breakeven point (power-wise) for a device to stay online versus disconnecting and reconnecting.

In the options below, what is the value of [x] where the power consumed by option 1 is roughly the same as option 2.

Option 1 - work online:

  • Connect
  • Get instructions from agent
  • Do some stuff for a while [x seconds]
  • Send results
  • Disconnect

Option 2 - work offline:

  • Connect
  • Get instructions from agent
  • Disconnect
  • Do some stuff for a while [x seconds]
  • Connect
  • Send results

It depends - a lot - on which imp, performance of the local network (DHCP time, etc), how busy the local network is (ie, can you go into low power wifi mode and get to a decent idle power consumption).

As you can’t determine that for all sites, option 2 is the “safer” (more consistent battery life) option in general, though obviously less responsive.

That makes sense. Is there a minimum you would expect in “the average” situation?

Not really, no. Depends on the application. You need to measure current over time and experiment. There’s nowhere near enough information here to make a call on that (like: what other power users are there in the system, and what are their power consumptions over time? how long is “a while”? how much imp side processing is going on during this time? etc)

One thing you could do (as suggested by @ahoughton ) is that you could measure how long the initial connect took, and if it too “too long” then just stay connected vs disconnecting and reconnecting, as that indicates that wifi is hard to connect to - for whatever reason including weak signal strength etc - and that it’s worth holding onto a connection if possible. This may help give more consistent results across many end user sites.