[Python] Huawei modbus access with python

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to read the data of consumption, production and current exchange with the network from the Modbus of the Huawei solar power plant, which uses the dongle Huawei SDongleA-05.

    mbpoll -m tcp -a 1 -r 32000 -c 2 192.168.0.101

    returns the result

    [32000]: 0
    [32001]: 6
    -- Polling slave 1... Ctrl-C to stop)


    but attempts using pymodbus are unsuccessful.

    Python test code:

    from pymodbus.client.tcp import ModbusTcpClient
    import logging

    # Omogući logovanje za debug
    logging.basicConfig()
    log = logging.getLogger()
    log.setLevel(logging.DEBUG)

    # Podesi konekciju
    client = ModbusTcpClient('192.168.0.101', port=502)

    if client.connect():
    # Čitanje holding registara 32000 i 32001
    result = client.read_holding_registers(32000, 2, unit=1)

    if not result.isError():
    print("Register 32000:", result.registers[0])
    print("Register 32001:", result.registers[1])
    else:
    print("Modbus greška:", result)

    client.close()
    else:
    print("Greška: Nema konekcije sa inverterom")


    But the result is

    python3 testhuawei.py

    DEBUG:pymodbus.logging:Connection to Modbus server established. Socket ('192.168.0.110', 60006)
    DEBUG:pymodbus.logging:Current transaction state - IDLE
    DEBUG:pymodbus.logging:Running transaction 1
    DEBUG:pymodbus.logging:SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0x7d 0x0 0x0 0x2
    DEBUG:pymodbus.logging:New Transaction state "SENDING"
    DEBUG:pymodbus.logging:Changing transaction state from "SENDING" to "WAITING FOR REPLY"
    DEBUG:pymodbus.logging:Transaction failed. (Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received))
    DEBUG:pymodbus.logging:processing:
    DEBUG:pymodbus.logging:Getting transaction 1
    DEBUG:pymodbus.logging:Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
    Modbus greška: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received)


    Any idea? Thanks in advance Bojan

    Continue reading...

Compartilhe esta Página