basking-in-the-sun2000 / solar-logger

A datalogger for a solar inverter. Stores data in influxdb and displays it in grafana. Has load diverting capability, to use the inverter's excess power
GNU General Public License v3.0
97 stars 31 forks source link

add new connection type ModbusRTU #43

Closed andysu closed 2 years ago

andysu commented 2 years ago

for cable connection as many inverters may connect via cable, but no tcp

in this case you may connect many inverters to 1 logger. (I have logger with 3huawei+1 solis inverters by one line)

basking-in-the-sun2000 commented 2 years ago

I have no way to test this. It should be possible, but don't want to release it with out a good testing beforehand

andysu commented 2 years ago

propose my help. I have many inverters via tcp and via rtu I can give you remote access to my loggers

andysu commented 2 years ago
pi@rpi2:/srv/http/commapps $ ./info.py 
2022-05-28 02:41:06,721 MainThread      DEBUG    transaction    :127      Current transaction state - IDLE
2022-05-28 02:41:06,722 MainThread      DEBUG    transaction    :131      Running transaction 1
2022-05-28 02:41:06,723 MainThread      DEBUG    transaction    :283      SEND: 0x4 0x2b 0xe 0x1 0x88 0xbc 0x11
2022-05-28 02:41:06,723 MainThread      DEBUG    sync           :77       New Transaction state "SENDING"
2022-05-28 02:41:06,724 MainThread      DEBUG    transaction    :304      Changing transaction state from "SENDING" to "WAITING FOR REPLY"
2022-05-28 02:41:06,875 MainThread      DEBUG    transaction    :408      Changing transaction state from "WAITING FOR REPLY" to "PROCESSING REPLY"
2022-05-28 02:41:06,876 MainThread      DEBUG    transaction    :319      RECV: 0x4 0x2b 0xe 0x1 0x1 0x0 0x0 0x3 0x0 0x6 0x48 0x55 0x41 0x57 0x45 0x49 0x1 0x7 0x53 0x55 0x4e 0x32 0x30 0x30 0x30 0x2 0x11 0x56 0x32 0x30 0x30 0x52 0x30 0x30 0x32 0x43 0x30 0x30 0x53 0x50 0x43 0x31 0x33 0x30 0x6d 0xc5
2022-05-28 02:41:06,877 MainThread      DEBUG    rtu_framer     :185      Getting Frame - 0x2b 0xe 0x1 0x1 0x0 0x0 0x3 0x0 0x6 0x48 0x55 0x41 0x57 0x45 0x49 0x1 0x7 0x53 0x55 0x4e 0x32 0x30 0x30 0x30 0x2 0x11 0x56 0x32 0x30 0x30 0x52 0x30 0x30 0x32 0x43 0x30 0x30 0x53 0x50 0x43 0x31 0x33 0x30
2022-05-28 02:41:06,878 MainThread      DEBUG    factory        :347      Factory Response[ReadDeviceInformationResponse': 43]
2022-05-28 02:41:06,879 MainThread      DEBUG    rtu_framer     :106      Frame advanced, resetting header!!
2022-05-28 02:41:06,879 MainThread      DEBUG    transaction    :495      Adding transaction 4
2022-05-28 02:41:06,880 MainThread      DEBUG    transaction    :507      Getting transaction 4
2022-05-28 02:41:06,880 MainThread      DEBUG    transaction    :229      Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
{0: b'HUAWEI', 1: b'SUN2000', 2: b'V200R002C00SPC130'}

some example via modbusrtu (pymodbus script)

basking-in-the-sun2000 commented 2 years ago

don't have any way to test this. Just added what I think is needed for rtu connections. Let me know if this works for you

There is a new branch; testing https://github.com/basking-in-the-sun2000/solar-logger/commit/1af38e06056c8aa0ed594d376be4954b7484d834

andysu commented 2 years ago

add 3 pull requests but WORKING with errors but influx -

name: Huawei_info time Derating Grid Insulation ModelID Power_off Power_on SN Shutdown Start Time location ---- -------- ---- ---------- ------- --------- -------- -- -------- ----- ---- -------- 1654096083089770651 100 1 1.281 43 0 0 2022-05-31 20:54:39 2022-06-01 04:14:17 2022-06-01 17:55:22 main 1654096142782453409 100 1 1.281 43 0 0 2022-05-31 20:54:39 2022-06-01 04:14:17 2022-06-01 17:56:22 main 1654096203416776375 100 1 1.281 43 0 0 2022-05-31 20:54:39 2022-06-01 04:14:17 2022-06-01 17:57:23 main 1654096862948127692 100 1 1.281 43 0 0 2022-05-31 20:54:39 2022-06-01 04:14:17 2022-06-01 18:08:23 main 1654096923061975943 100 1 1.281 43 0 0 2022-05-31 20:54:39 2022-06-01 04:14:17 2022-06-01 18:09:23 main 1654096982695953072 100 1 1.281 43 0 0 2022-05-31 20:54:39 2022-06-01 04:14:17 2022-06-01 18:10:23 main

SELECT * FROM "Huawei" name: Huawei time Frequency I_A PF PF_comp PV_I1 PV_I2 PV_I3 PV_I4 PV_In PV_P PV_U1 PV_U2 PV_U3 PV_U4 PV_Un P_accum P_active P_daily P_peak P_reactive Q/S Temp U_A U_A-B U_B location η ---- --------- --- -- ------- ----- ----- ----- ----- ----- ---- ----- ----- ----- ----- ----- ------- -------- ------- ------ ---------- --- ---- --- ----- --- -------- -- 1654096083211710788 49.99 3801.147 1 1 2.1 0 1 0 3.1 4.062 617.4 617.4 596.4 596.4 606.9 129396.68 3.981 201.94 33 0 0 47.7 234.3 404.3 231.7 main 98.01 1654096142820898562 50 3735.609 1 1 2 0 1 0 3 3.974 623.5 623.5 594.9 594.9 609.2 129396.75 3.893 202.01 33 0 0 47.7 234.3 404.2 231.7 main 98 1654096203455788452 50.01 3735.609 1 1 2 0 1 0 3 3.936 617.5 617.5 590.7 590.7 604.1 129396.81 3.864 202.07 33 0 0 47.7 234.3 404.2 231.5 main 97.14 1654096862991843607 49.99 2162.72 0.999 1 1 0 0.5 0 1.5 2.203 599.5 599.5 578.7 578.7 589.1 129397.37 2.145 202.63 33 0 0 47.2 232.6 400.8 229.7 main 95.56 1654096923103187994 49.98 2097.184 0.999 1 1 0 0.5 0 1.5 2.18 599.5 599.5 580.8 580.8 590.15 129397.41 2.131 202.67 33 0 0 47.2 232.1 400.2 229.7 main 97.76 1654096982743979204 49.97 2097.184 0.999 1 1 0 0.5 0 1.5 2.19 599.5 599.5 584.7 584.7 592.1 129397.44 2.122 202.7 33 0 0 47.1 232.5 400.3 229.5 main 97.05

`

basking-in-the-sun2000 commented 2 years ago

the info registers should only be written only when a value changes, unless you restart the program.

What errors are you getting? The only value that looks off is I_A. A 4000A phase current sounds a bit high unless you are a utility company.

Also, though it is ok, your insulation resistance seems low. Did you set the grid to your location? You have grid id 1 (China NB/T 32004), so just wondering?

andysu commented 2 years ago

I_A I_B I_C values fixed. Ins resistance - ok in my case grid code 1 (NB/T 32004 - its china magic -only in private messages)))

but ModbusRTU - working!