lilygo_battery - wolfen351/public-micropython-iot-platform GitHub Wiki

Overview

The LilyGoBattery module is responsible for monitoring and managing the battery voltage and percentage for a LilyGo device. It provides telemetry data, processes commands, and manages sleep cycles to optimize power usage.

Features

  • Reads battery voltage using an ADC pin.
  • Calculates battery percentage based on voltage readings.
  • Logs battery voltage and percentage periodically.
  • Implements a light sleep mechanism to conserve power.
  • Automatically reboots the device after 100 hours of uptime.

UI Hardware / Pinout Configuration

  • Pin 2: Used as an ADC input to read battery voltage.

Telemetry Provided

  • voltage: The current battery voltage (in volts).
  • voltagePercent: The current battery percentage (calculated).

Telemetry Consumed

  • None.

Commands Provided

  • None.

Commands Consumed

  • None.

Additional Information

  • Battery voltage is checked every 5 seconds.
  • The device enters light sleep for 10 minutes if the battery percentage is below 90% and it has been running for more than 2 minutes.
  • The ADC is configured with an attenuation of ADC.ATTN_11DB to support a full range of 3.3V.
  • The device reboots automatically if it has been running for more than 100 hours.