Water Meter device is intended to count pulses on 2 water flow meters (hot and cold water) and then publish counted value to consumers via MQTT protocol. Additionally device displays current values on a SSD1306 based display.
The device is based on ESP8266 module (ESP-07 or ESP-12).
This github space contains firmware for the device. Additionally you may refer to
The firmware is written in micropython. Since ESP8266 module has a very limited amount of RAM some trick are required to reduce RAM consumption.
- Some classes have to be pre-compiled so that ESP8266 does not require to compile them (executes bytecode)
- Library classes have to be burned into the firmware so that so that ESP8266 executes bytecode directly from the flash (refer to 'frozen bytecode' in micropython documentation)
So the here is the building algorithm:
- Build the micropython firmware
- Download and build ESP Open SDK
- Download Micropython sources
- Put 'Libraries' directory contents into Micropython's ports/esp8266/modules directory
- Build Micropython accoring to Micropython ESP8266 port instructions
- Flash built firmware into ESP8266 module (e.g. with esptool.py)
- Upload files in 'Src' directory to module internal filesystem
- Rename config.txt.template to config.txt and fill your configuration parameters inside
- Pre-compile all .py files in 'Src' directory with mpy-cross (except for main.py)
- Upload config.txt, all .mpy files and main.py to the device (e.g. with ampy.py)
For build convenience some libraries were copied into this repository. Here is the list of libraries used with the links to origin
- mqtt_as
- uasyncio and collections libraries came from micropython-lib