ESP32 sketch that logs electricity-related timestamps to local storage and uploads daily files to S3 via AWS Lambda.
- Every 5 min: Appends current time (HHMM) to a daily file on LittleFS. Filename format:
YYMMDD(e.g.250129). - Every 30 min: Uploads today’s file to an AWS Lambda URL (e.g. Lambda writes to S3). Uses
X-Device-TokenandX-Filenameheaders.
- Board: ESP32 (e.g. ESP32-DevKit with WiFi).
- Libraries: Built-in WiFi, HTTPClient, WiFiClientSecure, LittleFS, and time (NTP).
-
Config
- Copy
config.example.htoconfig.h. - Set
WIFI_SSID,WIFI_PASS,LAMBDA_URL, andDEVICE_TOKENinconfig.h. - Do not commit
config.h(it is gitignored).
- Copy
-
Arduino IDE
- Open the
powerlogsfolder as a sketch (main file ispowerlogs.ino). - Select your ESP32 board and port, then compile and upload.
- Open the
-
Lambda
- Expects
POSTwith body = file contents,X-Device-Token,X-Filename. Implement your Lambda to validate the token and store the body in S3 under the given filename (or your chosen key).
- Expects
powerlogs.ino— setup, loop, intervals, timezone.wifi.ino— WiFi connect.time.ino— NTP sync, daily filename, HHMM line.logging.ino— append HHMM to daily file.upload.ino— send today’s file to Lambda.
Configured for Kyiv (EET/EEST). Change TZ_UKRAINE in powerlogs.ino if needed.
Conventional commits — After cloning, run once so commit-msg validation uses the repo hooks:
./scripts/setup-hooks.shThis sets core.hooksPath to .githooks. Commit messages must follow type(scope)?: description (e.g. feat: add thing, fix(wifi): reconnect).