matthijsvisser / kamstrup-402-mqtt

This project provides a Python library that enables communication with the Kamstrup Multical 402 heat meter. The configured parameters will be read from the meter at a certain interval and published in MQTT messages.
MIT License
45 stars 11 forks source link

CRC error? #15

Closed TaoMao109 closed 10 months ago

TaoMao109 commented 10 months ago

Hello, I am currently working on implementing mqtt on my kamstrup 402. So far, mqtt sends the messages correctly, however they are all blank ( [] ).

I saw on the log that there are "CRC error" messages:

[2023-12-22 19:56:55 daemon.py run: 77 - INFO - Waiting 1 minute(s) for the next meter readout] [2023-12-22 19:57:55 kamstrup_meter.py open: 118 - DEBUG - Opened serial port] [2023-12-22 19:57:55 kamstrup_meter.py readparameter: 204 - WARNING - Message is invalid] [2023-12-22 19:57:56 kamstrup_meter.py recv: 188 - ERROR - CRC error] [2023-12-22 19:57:56 kamstrup_meter.py readparameter: 198 - WARNING - No response from meter] [2023-12-22 19:57:56 kamstrup_meter.py readparameter: 204 - WARNING - Message is invalid] [2023-12-22 19:57:56 kamstrup_meter.py recv: 188 - ERROR - CRC error] [2023-12-22 19:57:56 kamstrup_meter.py readparameter: 198 - WARNING - No response from meter] [2023-12-22 19:57:56 kamstrup_meter.py readparameter: 204 - WARNING - Message is invalid] [2023-12-22 19:57:56 kamstrup_meter.py close: 126 - DEBUG - Closed serial port] [2023-12-22 19:57:56 mqtt_handler.py publish: 46 - INFO - Publishing 'kamstrup/values' '{}' to ---.---.---.---] [2023-12-22 19:57:56 daemon.py run: 77 - INFO - Waiting 1 minute(s) for the next meter readout]

I can tell that the IR reader is correctly placed on the position, as there are two small bumps that keep it in place.

Does anyone know what the CRC error is? As far as I can tell, my serial port is ttyUSB0 (confirmed it via dmseg).

Any help is greatly appreciated! 😄

matthijsvisser commented 10 months ago

Hi,

With the meter head that I got I must position it a little above those "small bumps" for it it to read anything. See the attached photo in the repository.

TaoMao109 commented 10 months ago

I have now tested using the metertool app and I can verify that I am able to read the meter (through my phone) IMG20231222211222.jpg

Screenshot_2023-12-22-21-12-06-34_dad6c283c894d0b39489ed93c9349328.jpg

Perhaps the RPI is not sending the command through the right com port?

matthijsvisser commented 10 months ago

That could be, do you see the green led on the meter head blinking when sending a command with your phone? And does that also happen with the pi?

TaoMao109 commented 10 months ago

Yes, I can see the led indicator blinking, only when I plug the IR reader through my phone, but not through my RPI. I checked by disconnecting and reconnecting the usb and it is indeed ttyUSB0.

matthijsvisser commented 10 months ago

Restarting/rerunning the script will force to send a message to the meter, did you try that already?

TaoMao109 commented 10 months ago

I tried rebooting the RPI and running python3 daemon.py, however I still see from the log in the the [] message...

TaoMao109 commented 10 months ago

Okay, I have eventually figured it out. Turns out that the Ir reader should not be touching the small bumps as you said. What was strange is that when I used the app on my phone it was reading the outputs, but with RPI not. Case closed!