our solution design uses a Nano IOT as the BLE advertising system.
the product placement does not reliably have wall power nearby, so battery power is critical.
looking thru the reports here and our measurements, running 100% active won't work, so some sort of cyclic reduction in power consumption is required.
these measurements have been done with 9v and 2s Lipo at 7.4v.
with the Radio on for advertising I see approx 60ma
with radio off, approx 12ma (same as just empty loop())
so I have been investigating using one of the low power approaches
the Adafruit SleepyDog library or the Arduino Lowpower library
advertise for 5 seconds every 25, and sleep for 20 seconds. (not finally tuned)
i have also customized our app to advertise and have the arduino never advertise
until the app is nearby. Measurements says this is not helpful, as the power consumption goes to 60ma, as soon as we scan or advertise.
when asleep, power consumption drops to just over 3ma.
but.. it appears in both cases the millisecond clock is turned off, and not corrected on return from sleep
and my code timing loops no longer function reliably.
running on USB without sleep the sketch works reliably and start/stops BLE as expected
on battery with sleep, we get erratic behavior as if the millis() return value is not consistent.
loop(){
now = millis()
if(not Advertising){
if(now >startedScanning+timeScanning){(5 seconds)
scanning = false;
lastScanning=now
stopScanning(), then sleep(20 seconds)
amperage drops to 3.3ma here
}
// after a few cycles (10), there is a period where power draw is 12ma, for 20 seconds
// then high power for 5 seconds (scanning started)
// then low power (3.3ma) so scanning stopped
// after 15-18 cycles, power is 60ma, so the radio is on all the time
// I have commented out the later code that toggle advertising, and still get stuck
// once we wake up, this time limit should be expired
// as last scanning was saved BEFORE sleep
if(now >lastScanning+SleepTime){ (
startScanning()
scanning=true
startedScanning=now
amperage climbs to 60ma here
}
}
// commented out for testing
if(scanning){
if a peripheral beacon arrives
and its our client {
startedAdvertising=now
startAdvertsing()
}
if(now > startedAdvertising+AdvertisingLimit){
stopAdvertising()
}
} // end if scanning
} // end loop
as a next step, I'm considering the power off approach with the external rtc.
are there any projections on how many power cycles the iot can take before failing.
this is seconds between, not minutes.
lets say on/off every 7 seconds, 9 times a minute ~ 13000 times a day
hard turn off every 7 seconds..