AllWize / mbus-payload

MBUS application layer payload encoder and decoder
GNU Lesser General Public License v3.0
33 stars 4 forks source link

Decoding errors #3

Open HWHardsoft opened 1 year ago

HWHardsoft commented 1 year ago

Hi,

First of all, thank you for this great library.

Based on your library, I wrote a demo program for a small consumption meter (MBUS slave) for the ESP32. That works fine too. For tests I used LorusFree and LibMBUS (on the Raspberry Pi). I can read my meter correctly with both programs. Lorusfree_test_meter

I am currently trying to write a similar program for a master that decodes the data on the ESP32 with your library. Unfortunately, there seems to be a couple of problems. MBUSPayload recognizes the 7 data fields of the meter, but only displays 5 as JSON code??

`

define DEBUG true

include "MBUSPayload.h"

include "ArduinoJson.h"

// Serial interface used for mbus to allow use of 8E1 encoding

include

HardwareSerial *customSerial;

define MBUS_BAUD_RATE 2400

define MBUS_ADDRESS 2

define MBUS_TIMEOUT 1000 // milliseconds

define MBUS_DATA_SIZE 255

define MBUS_GOOD_FRAME true

define MBUS_BAD_FRAME false

unsigned long loop_start = 0; unsigned long last_loop = 0; bool firstrun = true; int Startadd = 0x13; // Start address for decoding

void setup() { Serial.begin(115200); Serial.println(F("emonMbus startup")); Serial.println(F("mbus:")); Serial.print(F(" slave address: ")); Serial.println(MBUS_ADDRESS); Serial.print(F(" baud rate: ")); Serial.println(MBUS_BAUD_RATE); customSerial = &Serial1; customSerial->begin(MBUS_BAUD_RATE, SERIAL_8E1); // mbus uses 8E1 encoding delay(1000); // let the serial initialize, or we get a bad first frame }

void loop() { loop_start = millis();

/****

output

So the binary inputs and outputs are not decoded correctly.

HWHardsoft commented 1 year ago

Addendum:

When I try to decode the data from a commercial M-BUS device (whose payload is not encoded with MBUSPayload), things look even worse. I tried to decode the data of an elvaco MBUS thermostat. No problem with LorusFree. MBusPaypal does not find any data fields and reports 4 errors:

output2

Data from Thermostat (payload starts at address 19): 68 53 53 68 8 2 72 11 82 0 24 96 15 16 0 20 0 0 0 1 fd 1b 0 2 fc 3 48 52 25 74 62 17 22 fc 3 48 52 25 74 5c 17 12 fc 3 48 52 25 74 68 17 2 65 a2 8 22 65 9e 8 12 65 a2 8 1 72 0 72 65 0 0 b2 1 65 0 0 c 78 11 82 0 24 3 fd f 5 9 3 1f 9f 16

And here the decoding by LorusFree:

grafik

Zeppelin500 commented 11 months ago

Hello,

Thank you for the libary!

I have the same issue. Do you find a solution?

Try to develop a M-Bus MQTT gateway. It work, but only with the Engelmann Sensostar

Now i try to write a new version with the mbus-payload libary to enable more M-Bus devices, but there are some problems.

The M-Bus data part of the telegram is right received. I get error code 4, interpreted as "UNSUPPORTED_VIF" Right? The first 5 fields are decoded and inside the json string. The variable "fields" is 0. Next VIF (#6) is 0h3C and should be supported as I understood the libary.

I also tried your code above HWHardsoft, but exactly the same.

Zeppelin500 commented 11 months ago

Answer to myself:

It is just an issue of the size of the involved variables. In my case a M-Bus telegram with (L-Byte) 193 uses around 2k! byte more then 4k byte for serialize the json doc.

Now I have different issues, but step by step.

HWHardsoft commented 11 months ago

@Zeppelin500

I've tried your new version of MBUS Payload library today. Also I've increased the size of the JSON buffer to 4k but no change. The errors during decoding of data of elvaco thermostat are still the same. Did you've tried to decode my sampe data with your MBUS Payload version too?