@@ -420,3 +420,43 @@ def system_time(self):
420
420
time_now_unix = iridium_epoch_unix + int (secs_since_epoch )
421
421
return time .localtime (time_now_unix )
422
422
return None
423
+
424
+ @property
425
+ def energy_monitor (self ):
426
+ """The current accumulated energy usage estimate in microamp hours.
427
+
428
+ Returns an estimate of the charge taken from the +5V supply to the modem,
429
+ in microamp hours (uAh). This is represented internally as a 26-bit unsigned number,
430
+ so in principle will rollover to zero after approx. 67Ah (in practice this is usually
431
+ greater than battery life, if battery-powered).
432
+
433
+ The accumulator value is set to zero on a power-cycle or on a watchdog reset.
434
+ Note that while +5V power is supplied to the Data Module but the module is powered off
435
+ by its ON/OFF control line, it will still be consuming up to a few tens of microamps,
436
+ and this current drain will not be estimated in the +GEMON report.
437
+
438
+ The setter will preset the energy monitor accumulator to value n (typically, <n> would
439
+ be specified as 0, to clear the accumulator).
440
+
441
+ Note: Call Processor/BOOT Version: TA16005 is known to not support the AT+GEMON energy
442
+ monitor command. It is however known to work on TA19002 (newer) and TA12003 (older).
443
+ You may use the revision function to determine which version you have. Function will
444
+ return None if modem cannot retrieve the accumulated energy usage estimate.
445
+
446
+ Returns
447
+ int
448
+ """
449
+
450
+ resp = self ._uart_xfer ("+GEMON" )
451
+ if resp [- 1 ].strip ().decode () == "OK" :
452
+ return int (resp [1 ].strip ().decode ().split (":" )[1 ])
453
+ return None
454
+
455
+ @energy_monitor .setter
456
+ def energy_monitor (self , value ):
457
+ if 0 <= value <= 67108863 : # 0 to 2^26 - 1
458
+ resp = self ._uart_xfer ("+GEMON=" + str (value ))
459
+ if resp [- 1 ].strip ().decode () == "OK" :
460
+ return True
461
+ raise RuntimeError ("Error setting energy monitor accumulator." )
462
+ raise ValueError ("Value must be between 0 and 67108863 (2^26 - 1)." )
0 commit comments