01 GENERAL - patience4711/ESP8266_read_p1meter GitHub Wiki
working
This ESP-P1-METER consists of an ESP8266 module and a 6-core wire with an RJ11 jacket. The ESP module is via the serial port connected to the P1-meter.
The ESP38266 is capable of communicating with the meter via a serial connection. The data is transmitted in the form of a text document, called a 'telegram'. This telegram is processed and the extracted values are displayed in a webinterface and are broadcasted via Mosquitto. Therefore the device should be connected to your home network (wifi).
polling
The program polls data in a configurable frequency 0.5, 1, 5 minutes. It starts pulling the Rx of the meter high which triggers data transmission by the meter.
The P1-meter data has the form of a textdocument. This document consists of lines that each represent a value. The program reads the serial port until a startcharacter is found. Now the next incoming bytes are stored in a char array until the endcharacter is encountered.
Next the checksum calculation is done and when the char array is approved, the interesting values can be extracted. Since we have the complete telegram stored, we can serve it on request. see picture:
LED signals
You can connect an external led to the ESP, this has the same behaviour as the blue on-board LED. When the LED:
- is continuously on: An accespoint has been opened.
- flashes 3 times at boot: Wifi connected.
- flashes once: Polling is done
- flashes serveral times: zigbee is initializing
- goes on when pushing the button: reboot when button released.
- goes on and off when pusshing the button: Drop wifi and start AP
external button / led
You can connect an external tactile switch to the ESP, this has the same behaviour as the on-board flash button. An eventual external led does the same as the blue onboard led.
functions of the button / led
The led flashes 3 times at boot, meaning that a connection to wifi is made. When it lights up continuously, the accesspoint is opened. When the program is running, the led flashes at every succesfull poll.
-
Reboot: Keep the button pressed, the LED goes on after a few moments. If you release it now, the ESP-ECU will reboot.
-
Reset WIFI: Keep the button pressed. The LED goes on and after a few seconds off again. If you release the button now, the ESP-ECU will drop the wifi credentials and reboots into the accesspoint.