psvanstrom / esphome-p1reader

ESPHome custom component for reading P1 data from electricity meters.
MIT License
267 stars 116 forks source link

Iskra AM550 - Data not published, CRC error #36

Open osfog opened 2 years ago

osfog commented 2 years ago

Hi is there anyway of troubleshooting issues with the crc checksum - looking at the log the received data indeed seems off however it doesn't seem quite like just poor wiring given how the positions where we see invalid data seems to be following a pattern... well at least a bit.

The meter is an Iskra AM550. I tried tweaking the delay and buffer size but no effect...

[09:41:26][D][data:305]:

[09:41:26][I][crc:317]: Telegram read. CRC: BF63 = F8D6. PASS = NO

[09:41:36][D][data:305]:

[09:41:36][I][crc:317]: Telegram read. CRC: D65B = F1BC. PASS = NO

[09:41:46][D][data:305]:

[09:41:46][I][crc:317]: Telegram read. CRC: 630E = 8190. PASS = NO

[09:41:56][D][data:305]:

osfog commented 2 years ago

In the meantime i have changed to that i ignore the crc check and instead rely on the atio to returl non 0 and sending the i.e.:


`    if (atof(value) != 0)
    {
      if (strncmp(obisCode, "1.8.0", 5) == 0)
      {
        parsed->cumulativeActiveImport = atof(value);
        cumulativeActiveImport->publish_state(parsed->cumulativeActiveImport);
      }`
CarbonCollins commented 2 years ago

I am also getting this issue with the same model of power meter. similar log output too:

[21:38:04][D][data:265]:

[21:38:04][I][crc:276]: Telegram read. CRC: 7374 = 1A56. PASS = NO

CarbonCollins commented 2 years ago

I spent a bit more time looking into the log output and noticed that in both mine and @johansvenson log outputs, there seems to be an inconsistency with some of the output. for instance:

This telegram has two blank lines:

[11:44:44][D][data:265]:

[11:44:44][D][data:265]:

[11:44:44][I][crc:276]: Telegram read. CRC: C779 = B587. PASS = NO

whereas this one seems to have some malformed data part way through the telegram...:

[11:45:24][D][data:265]:

[11:45:24][I][crc:276]: Telegram read. CRC: 3AB6 = 0904. PASS = NO

you can also see this in the telegram I posted above too...

CarbonCollins commented 1 year ago

Hi again,

I've been looking into the issue a bit more as of late and think I may have come to a idea as to what was occuring.

It seems that the AM550 was pushing data faster than what the reader was processing causing the internal serial buffer to fill up and drop data. This is mainly from the way the data was malformed in the previous telegrams I posted. I had success doing one of two things:

  1. decrease the delay at the end of the while loop from 40 to 10 which makes the reader empty the serial buffer more frequently.

  2. Increase the internal serial buffer from the 256 default to 1024 by adding Serial.setRxBufferSize(1024); in the setup function.

In either of these two cases I did not get CRC check errors nor any malformed telegrams. Ive been running it live for the last month or so without any issues here!

I'm not sure which option would be the better choice to raise as a PR though, any thoughts on this?