Skip to content

Instantly share code, notes, and snippets.

@edwios
Created February 24, 2016 00:10
Show Gist options
  • Save edwios/4e4962395a80f65ce240 to your computer and use it in GitHub Desktop.
Save edwios/4e4962395a80f65ce240 to your computer and use it in GitHub Desktop.
Calculate the number of days a battery would last given various operation characteristics
#!/usr/local/bin/python3
#DEEP SLEEP MODE
#System.sleep(SLEEP_MODE_DEEP,60) **~61uA**
#STOP MODE
#System.sleep(long seconds) **~ 2.8mA!**
def findDays(cb, ti, iq, ta, ia):
td = 3600*cb*ti/(86400*((ti-ta)*iq+ia*ta))
return td
Cb = 800 # Battery capacity (mAh)
Ti = 10*60 # Interval between each operation (s)
Ta = 10 # Time required for each operation (s)
Iq = 0.01+5 # Current consumption during deep sleep / standby mode (mA)
Ia = 180 # Current consumption during active operation (mA)
Td = findDays(Cb, Ti, Iq, Ta, Ia)
print ("Battery can sustain a max of ", Td, " days")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment