gadget78 / inverter-homeassistant

Programmatically read data from your Voltronic, Axpert, Mppsolar PIP, Voltacon, Effekta etc Inverter and send it to Home Assistant via MQTT - Works with RS232 & USB!
GNU General Public License v3.0
15 stars 4 forks source link

/dev/ttyUSB0 not working #10

Open byte4geek opened 2 years ago

byte4geek commented 2 years ago

I'm trying to use the serial port but no response from the inverter:

Whit the same serial adapter and windows PC i'm able to connect to the inverter using the WatchPower tool.

pi@solarpi:~/docker-voltronic-homeassistant $ docker exec -it voltronic-mqtt bash -c '/opt/inverter-cli/bin/inverter_poller -d -1'
Fri Jun 10 11:59:13 2022 INVERTER: Debug set
Fri Jun 10 11:59:13 2022 DEBUG:  Current CRC: 49 C1
Fri Jun 10 11:59:13 2022 DEBUG:  Send buffer hex bytes:  ( 51 4d 4f 44 49 c1 0d )
Fri Jun 10 11:59:13 2022 DEBUG:  7 bytes written, 7 bytes sent, 0 bytes remaining
Fri Jun 10 11:59:19 2022 DEBUG:  QMOD read timeout
Fri Jun 10 11:59:20 2022 DEBUG:  Found reply <cr> at byte: 1
 configuration options for the actual inverter polling process...p bytes.  Buffer: QMODI▒

# The device to read from...
# Use: /dev/ttyS0 if you have a serial device,
#      /dev/ttyUSB0 if a USB<>Serial,
#      /dev/hidraw0 if you're connecting via the USB port on the inverter.

#device=/dev/hidraw0
device=/dev/ttyUSB0
#device=/dev/ttyS0
# How many times per hour is the program going to run...
# This is used to calculate the PV & Load Watt Hours between runs...
# If unsure, leave as default - it will run every minute...

# (120 = every 30 seconds)...
# run_interval=322 don;t need it anymore for HA

# This allows you to modify the amperage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
amperage_factor=1.0

# This allows you to modify the wattage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
watt_factor=1.0

# The following settings allow you to modify runtime buffers.
# N.B. These values
Fri Jun 10 11:59:20 2022 DEBUG:  Current CRC: B7 A9
Fri Jun 10 11:59:20 2022 DEBUG:  Send buffer hex bytes:  ( 51 50 49 47 53 b7 a9 0d )
Fri Jun 10 11:59:20 2022 DEBUG:  8 bytes written, 8 bytes sent, 0 bytes remaining
Fri Jun 10 11:59:26 2022 DEBUG:  QPIGS read timeout
Fri Jun 10 11:59:27 2022 DEBUG:  Found reply <cr> at byte: 1
configuration options for the actual inverter polling process...top bytes.  Buffer: QPIGS▒▒

# The device to read from...
# Use: /dev/ttyS0 if you have a serial device,
#      /dev/ttyUSB0 if a USB<>Serial,
#      /dev/hidraw0 if you're connecting via the USB port on the inverter.

#device=/dev/hidraw0
device=/dev/ttyUSB0
#device=/dev/ttyS0
# How many times per hour is the program going to run...
# This is used to calculate the PV & Load Watt Hours between runs...
# If unsure, leave as default - it will run every minute...

# (120 = every 30 seconds)...
# run_interval=322 don;t need it anymore for HA

# This allows you to modify the amperage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
amperage_factor=1.0

# This allows you to modify the wattage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
watt_factor=1.0

# The following settings allow you to modify runtime buffers.
# N.B. These values
Fri Jun 10 11:59:27 2022 DEBUG:  Current CRC: F8 54
Fri Jun 10 11:59:27 2022 DEBUG:  Send buffer hex bytes:  ( 51 50 49 52 49 f8 54 0d )
Fri Jun 10 11:59:27 2022 DEBUG:  8 bytes written, 8 bytes sent, 0 bytes remaining
Fri Jun 10 11:59:33 2022 DEBUG:  QPIRI read timeout
Fri Jun 10 11:59:34 2022 DEBUG:  Found reply <cr> at byte: 1
configuration options for the actual inverter polling process...top bytes.  Buffer: QPIRI▒T

# The device to read from...
# Use: /dev/ttyS0 if you have a serial device,
#      /dev/ttyUSB0 if a USB<>Serial,
#      /dev/hidraw0 if you're connecting via the USB port on the inverter.

#device=/dev/hidraw0
device=/dev/ttyUSB0
#device=/dev/ttyS0
# How many times per hour is the program going to run...
# This is used to calculate the PV & Load Watt Hours between runs...
# If unsure, leave as default - it will run every minute...

# (120 = every 30 seconds)...
# run_interval=322 don;t need it anymore for HA

# This allows you to modify the amperage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
amperage_factor=1.0

# This allows you to modify the wattage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
watt_factor=1.0

# The following settings allow you to modify runtime buffers.
# N.B. These values
Fri Jun 10 11:59:34 2022 DEBUG:  Current CRC: B4 DA
Fri Jun 10 11:59:34 2022 DEBUG:  Send buffer hex bytes:  ( 51 50 49 57 53 b4 da 0d )
Fri Jun 10 11:59:34 2022 DEBUG:  8 bytes written, 8 bytes sent, 0 bytes remaining
Fri Jun 10 11:59:40 2022 DEBUG:  QPIWS read timeout
Fri Jun 10 11:59:41 2022 DEBUG:  Found reply <cr> at byte: 1
configuration options for the actual inverter polling process...top bytes.  Buffer: QPIWS▒▒

# The device to read from...
# Use: /dev/ttyS0 if you have a serial device,
#      /dev/ttyUSB0 if a USB<>Serial,
#      /dev/hidraw0 if you're connecting via the USB port on the inverter.

#device=/dev/hidraw0
device=/dev/ttyUSB0
#device=/dev/ttyS0
# How many times per hour is the program going to run...
# This is used to calculate the PV & Load Watt Hours between runs...
# If unsure, leave as default - it will run every minute...

# (120 = every 30 seconds)...
# run_interval=322 don;t need it anymore for HA

# This allows you to modify the amperage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
amperage_factor=1.0

# This allows you to modify the wattage in case the inverter is giving an incorrect
# reading compared to measurement tools.  Normally this will remain '1'
watt_factor=1.0

# The following settings allow you to modify runtime buffers.
# N.B. These values
Fri Jun 10 11:59:41 2022 DEBUG:  Start loop
Fri Jun 10 11:59:42 2022 DEBUG:  Start loop
Fri Jun 10 11:59:43 2022 DEBUG:  Start loop
Fri Jun 10 11:59:44 2022 DEBUG:  Start loop
Fri Jun 10 11:59:45 2022 DEBUG:  Start loop
Fri Jun 10 11:59:46 2022 DEBUG:  Start loop
Fri Jun 10 11:59:47 2022 DEBUG:  Start loop
Fri Jun 10 11:59:48 2022 DEBUG:  Start loop
byte4geek commented 2 years ago

some time i have this:

Fri Jun 10 13:25:06 2022 INVERTER: Debug set
Fri Jun 10 13:25:07 2022 DEBUG:  Current CRC: 49 C1
Fri Jun 10 13:25:07 2022 DEBUG:  Send buffer hex bytes:  ( 51 4d 4f 44 49 c1 0d )
Fri Jun 10 13:25:07 2022 DEBUG:  7 bytes written, 7 bytes sent, 0 bytes remaining
Fri Jun 10 13:25:07 2022 DEBUG:  5 bytes read, 5 total bytes:  10 00 00 28 42 e7 c9 0a
Fri Jun 10 13:25:13 2022 DEBUG:  QMOD read timeout
Fri Jun 10 13:25:14 2022 DEBUG:  Found reply <cr> at byte: -35295495
kryspirit commented 1 year ago

i discover that sometimes this docker can't establish serial speed, this cause random error of parse bytes read from serial. I suggest you to schedule this python script at boot:

crontab -e @reboot python3 /home/cristian/set_serial.py > /home/cristian/set_serial_out.txt

root@srvubuntu:/home/cristian# cat set_serial.py

import serial
serialport = serial.Serial("/dev/ttyUSB0", 2400, timeout=0.5)

serialport.write(b"QMOD 4\r")
response = serialport.readlines(None)
print(response)

serialport.write(b"QPIGS 5\r")
response = serialport.readlines(None)
print(response)

My inverter.conf value:

device=/dev/ttyUSB0
qmod=5
qpigs=110
qpiri=103
qpiws=32