New smart meter driver written in Berry #22415
Replies: 3 comments 2 replies
-
Great. Took a quick peek at the code (not having such a smart meter), I noticed a thing about your handling of timing and the multitasking/multithreading Tasmota does not have. This means that all your code is blocking, and busy-waiting is bad practice, like this:
The preferred way is use driver callbacks like And your |
Beta Was this translation helpful? Give feedback.
-
First I tried as you said, by implementing every_xxx() functions (I still use I'm fully aware there's no parallel multitasking, even though the ESP32 model I use has 2 cores and in theory, WiFi is handled on the other core. But actually, and according to the docs, Oh no, berry is fairly slow. But anything using a native function is fast. First I tried to avoid regexes, but then I saw that its performance impact is negligible. The CRC16 function is written in Berry, because the one in the module uses a different algo and poly. For 1132 bytes, the CRC is around 550 ms without |
Beta Was this translation helpful? Give feedback.
-
Well, about Thanks, I've quickly tried your version of the CRC16 code, and it's indeed a lot faster this way, about 116 ms (vs. ~550 ms) for the same 1132 bytes. Maybe with a LUT it could be sped up more. I'll definitely change the algo in my code to this one but I see further optimizations pointless in this case. Using the list approach you mentioned for serial might speed things up a bit, but I doubt I'd gain a lot. |
Beta Was this translation helpful? Give feedback.
-
Since the utility company mounted a new smart meter with P1 port in our fuse box, I've been struggling with reading the P1 port it's equipped with. The native smart meter interface is pretty good, but since I receive bad telegrams quite frequently and that driver can't really deal with random outliers or outright bad values (even with the median filter active), and doesn't support checking the embedded CRC, I decided to make my own driver that tries to solve this, this time using Berry. It's only for OBIS ASCII telegrams ("DSMR" data).
The driver and some usage docs are here: https://github.com/kobuki/tasmota-smr-berry
It aims to be mostly compatible with the metric descriptors of the original Tasmota driver, so those can be used with my driver, too. A few things are not supported, like summary for the previous month and some detail settings like number of digits after the dot for numeric values, posting frequency (instantly vs. teleperiod - it's always instantaneous), the main page and teleperiod sensors got a separate config, etc. I hope it can be useful for others. If you try it out, I'd be glad to receive some feedback aobut your setup and how it works for you.
PS: my meter has a surprisingly flaky P1 output. Sometimes I only get a 20% good packets, but sometimes it's almost perfect, around 90% as validated by CRC. At first glance seems to correlate with the temperature of the device. It's the best around 44-45°C, and in the colder nights nowadays it's routinely 20% or sometimes worse. Weird.
Beta Was this translation helpful? Give feedback.
All reactions