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:
- Basic display test
- Basic I2C test
- Full example of humidity monitor, includinf WiFi provisioning and posting to MQTT
- Full example of soil moisture monitor, includinf WiFi provisioning and posting to MQTT
- Weather forecast example
- BLE peripheral example
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.