Skip to content

Commit

Permalink
Merge pull request #8 from psvanstrom/e360-fix
Browse files Browse the repository at this point in the history
E360 fix
  • Loading branch information
psvanstrom committed Apr 3, 2021
2 parents f0f16a5 + adf62b3 commit a7d87ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Please note that the project currently doesn't support the Aidon meter from Tekn

## Verified meter hardware / supplier
* [Sagemcom T211](https://www.ellevio.se/globalassets/uploads/2020/nya-elmatare/ellevio_produktblad_fas3_t211_web2.pdf) / Ellevio
* [Landis+Gyr E360](https://eu.landisgyr.com/blog-se/e360-en-smart-matare-som-optimerarden-totala-agandekostnaden)

*Note:* There's currently a bug in the E360 firmware, causing it to stop sending out data after a while. Check this comment for more info: https://github.com/psvanstrom/esphome-p1reader/issues/4#issuecomment-810794020

## Hardware
I have used an ESP-12 based NodeMCU for my circuit. Most ESP-12/ESP-32 based controllers would probably work. The P1 port on the meter provides 5V up to 250mA which makes it possible to power the circuit directly from the P1 port.
Expand Down
7 changes: 7 additions & 0 deletions p1reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class P1Reader : public Component, public UARTDevice {
if (available()) {
uint16_t crc = 0x0000;
ParsedMessage parsed = ParsedMessage();
bool telegramEnded = false;

while (available()) {
int len = readBytesUntil('\n', buffer, BUF_SIZE);
Expand All @@ -273,6 +274,7 @@ class P1Reader : public Component, public UARTDevice {
int crcFromMsg = (int) strtol(&buffer[1], NULL, 16);
parsed.crcOk = crc == crcFromMsg;
ESP_LOGI("crc", "Telegram read. CRC: %04X = %04X. PASS = %s", crc, crcFromMsg, parsed.crcOk ? "YES": "NO");
telegramEnded = true;

// otherwise pass the row through the CRC calculation
} else {
Expand All @@ -296,6 +298,11 @@ class P1Reader : public Component, public UARTDevice {
}
// clean buffer
memset(buffer, 0, BUF_SIZE - 1);

if (!telegramEnded && !available()) {
// wait for more data
delay(40);
}
}

// if the CRC pass, publish sensor values
Expand Down

0 comments on commit a7d87ec

Please sign in to comment.