mitchese / shm-et340

Sunny Home Manager emulator in a Victron ESS System (replaces ET340)
GNU General Public License v3.0
30 stars 9 forks source link

Use shm-et340 with SMA Energy meter (SHM1.0) #7

Open hoschult opened 2 years ago

hoschult commented 2 years ago

Hi, tried to use your code with my SMA Energy meter (SHM1.0). Seems to be working - at least partly:

DEBU[0019] Received datagram from meter                 
DEBU[0019] Uid: 262816                                  
DEBU[0019] Serial: xxxxxx                           
DEBU[0019] Total W: -7757.2                             
DEBU[0019] Total Buy kWh: 18513.638899999998            
DEBU[0019] Total Sell kWh: 32970.4046                   
INFO[0019] Meter update received: 18513.64 kWh bought and 32970.40 kWh sold, -7757.2 W currently flowing 
DEBU[0019] +-----+-------------+---------------+---------------+ 
DEBU[0019] |value|   L1     |     L2    |   L3      |          
DEBU[0019] +-----+-------------+---------------+---------------+ 
DEBU[0019] |  V  |     1.00     |     1.00  |     1.00  |  
DEBU[0019] |  A  |    -1.70     |     1.30  |    -0.70  |  
DEBU[0019] |  W  |    -1.70     |     1.30  |    -0.70  |  
DEBU[0019] | kWh | 1721346537.27    | 3285096407.88     | 4848846278.50     | 
DEBU[0019] | kWh | 1799534030.79    | 3363283901.41     | 4927033772.02     | 
DEBU[0019] +-----+-------------+---------------+---------------+ 

UID, Serial and 'Total W' are correct; V/A/W seems to be not decoded correctly (neither for any phases). Tried to look at the datagrams to be captured of speedwire multicast: https://github.com/datenschuft/SMA-EM/blob/master/speedwiredecoder.py - However I was not able to translate towards your code....

Are you foresee to implement also the readings of SHM1.0 (SMA Energy meter)? That would be fantastic.... I can offer my help by supporting the tests.

Thanks, Holger

hoschult commented 2 years ago

there is a guy at victron community stating the following:

I have used your GIT hub code to hack my SMA EM v1 to work on this. There is essentially a 4 byte offset on the decodePhaseChunks.

hoschult commented 2 years ago

... found a explanation for the 4 byte offset; SHM2 takes also grid frequency into account, SHM1 does not. According to a specification of the speedwire datagram (found at https://openwb.de/forum/viewtopic.php?p=51576 ), grid frequency is at position 160-163:

image

hoschult commented 2 years ago

Got meter working with SMA EM (SHM1); Need to put an offset at decodePhaseChunks in main.go

L1 := decodePhaseChunk(b[156:300]) L2 := decodePhaseChunk(b[300:444]) L3 := decodePhaseChunk(b[444:588])

That's it.... At least for my setup. To do that in a more general way, offset can be determined on the Revision of the EM; Needs to be investigated since which revision frequency (offset) need to be added (or removed).

brezel1965 commented 2 years ago

I also have an SMA Energy Meter and my consumption is incorrect. Unfortunately I don't understand how to write this offset in main.go and compile it, maybe someone can provide the modified shm-et340. Thank you Martin

hoschult commented 2 years ago

hi Martin. I compiled you the shm10 binary, see download link attached: https://magentacloud.de/s/EdWHd267ffLLkZf

buttermaker11111 commented 8 months ago

Hello Holger, can you provide the modified shm-et340 again? Under the link is no file anymore.

Thanks Olaf