Close

Firmware overview

A project log for Paper WiFi

WiFi/BLE-enabled low power e-paper display devboard

albertas-micknasAlbertas Mickėnas 03/09/2023 at 19:410 Comments

Fully functional firmware supporting low power operation is provided and can be found in the github repository.

Since we are using deep sleep, all the action happens in the setup function, only few state bytes are kept in RTC memory that is retained between wakeups:

void setup() {
  Serial.begin(9600);
  Serial.println(String("Hello, is_first_run:") + is_first_run);

  SensorsInit();
  SensorsPowerOn();
  SensorReadings new_readings = SensorsRead();
  if (is_first_run) {
    sensor_readings = new_readings;
  }
  SensorsPowerOff();

  if (is_first_run || sensor_readings != new_readings) {
    DisplayInit();
    NetworkInit();
    DisplayData(new_readings, is_wifi_connected);
    Serial.println(String("is_wifi_configured:") + is_wifi_connected);
    if (is_wifi_connected) {
      MqttSetup();
      MqttPublish(new_readings);
    } else {
      Serial.println("Wifi not connected");
    }
    sensor_readings = new_readings;
  }
  is_first_run = false;
  DeepSleep(DEEP_SLEEP_TIME);
}

WifiManager library is used to support WiFi credential provisioning. 

GxEPD library is used to access the display.

Examples available:

Discussions