syssi / esphome-solax-x1-mini

ESPHome component to monitor a Solax X1 mini via RS485
Apache License 2.0
39 stars 11 forks source link

Add flow control pin support #18

Closed beocycris closed 2 years ago

beocycris commented 2 years ago

Hey guys,

thank for this modules. In my case I try to use it with a Solax X1 mini 1.5 V2. And I only receive the text which is mentioned in the title. May anyone has the same issue and can help me to fix it.

regards frank

syssi commented 2 years ago

Could you provide some details about your setup? A photo of your wiring (incl. the RS485 module) and the important parts (uart section) of your configuration yaml?

Another interpretation of the log message is: "The device doesn't respond". Therefore we must make sure your device is connected properly. If this is the case it's possible your device version uses another protocol. Let's start with the wiring!

beocycris commented 2 years ago

I won´t be at home till friday - so I decided to do a small scheme of the cabling.

solax_issue.pdf

And the code too:

substitutions:
  name: solar-powermeter

esphome:
  name: ${name}
  platform: esp8266
  board: d1_mini

external_components:
  #- source: github://syssi/esphome-modbus-solax-x1@add-solax-x1-mini-g2-compatibility
  - source: github://syssi/esphome-modbus-solax-x1@main
    refresh: 0s

uart:
  baud_rate: 9600
  tx_pin: GPIO2
  rx_pin: GPIO1

solax_x1:
  serial_number: "3132333435363737363534333231"
  address: 0x0A
  update_interval: 2s

text_sensor:
  - platform: solax_x1
    mode_name:
      name: "${name} mode name"
    errors:
      name: "${name} errors"

thanks!

syssi commented 2 years ago

I assume your RS485 module isn't handled properly:

https://electronics.stackexchange.com/questions/153500/correctly-using-re-and-de-with-rs485

I will add a flow control pin to the component to support your rs485 module. At the moment DE/RE isn't used correctly.

syssi commented 2 years ago

I've introduced a flow control pin here:

https://github.com/syssi/esphome-modbus-solax-x1/pull/19

Please use this new feature branch for your tests:

external_components:
  - source: github://syssi/esphome-modbus-solax-x1@add-flow-control
    refresh: 0s

The next step is to update your configuration to use flow control pin:

https://github.com/syssi/esphome-modbus-solax-x1/pull/19/files#diff-dbc81de7d9fb76af6e67b9c8b02f69c8ea7f35b243a2898f26520c759e0d7b6d

This should fit for you

uart:
  id: uart0
  baud_rate: 9600
  tx_pin: GPIO5
  rx_pin: GPIO4

modbus_solax:
  id: modbus0
  uart_id: uart0
  flow_control_pin: GPIO0

solax_x1:
  modbus_solax_id: modbus0
  serial_number: "3132333435363737363534333231"
  address: 0x0A
  update_interval: 2s

I just found another issue. Your configuration doesn't align with your schema. Your schema shows:

The yaml configuration uses:

Please update your wiring.

beocycris commented 2 years ago

Do i have to change my wiring physically? Or may I can use the: D1=GPIO4 as tx to the RS485-pin RO, D2=GPIO5 as rx to the RS485-pin DI and GPIO0 as flowcontrole pin, connected to the bridged RS485-pins RE/DE ?

Or shell I change GPIO5 to the original tx-pin and the GPIO to the rx-pin on the microcrontroller?

Because I changed the my code to your provided one and nothing different happened than the issue above.

syssi commented 2 years ago

The tx_pin must connected to DI not RI. If you use GPIO4 and GPIO5 a software serial implementation is used by ESPHome because these GPIOs doesn't support native UART. I would use the hardware/native UART pins of the ESP8266. The best wiring would look like this:

https://github.com/KlausLi/Esp-Soyosource-Controller/blob/main/BastelPlan3000_Soyosource_Controller_by_BavarianSuperGuy.png

api:
ota:
logger:
  level: INFO
  baud_rate: 0  # <--- super important!

uart:
  id: uart0
  baud_rate: 9600
  tx_pin: GPIO1
  rx_pin: GPIO3

modbus_solax:
  id: modbus0
  uart_id: uart0
  flow_control_pin: GPIO0

solax_x1:
  modbus_solax_id: modbus0
  serial_number: "3132333435363737363534333231"
  address: 0x0A
  update_interval: 2s
beocycris commented 2 years ago

Ah ok got you.

So my config:

uart:
   id: uart0
   baud_rate: 9600
   tx_pin: GPIO4
   rx_pin: GPIO5

modbus_solax:
   - id: modbus0
     uart_id: uart0
     flow_control_pin: GPIO2

solax_x1:
   modbus_solax_id: modbus0
   serial_number: "3132333435363737363534333231"
   address: 0x0A
   update_interval: 2s

Won´t work properly. Then I really have to wait till weekend, when I´m able to solder the pins to tx and rx instead using GPIO4 and GPIO5. GPIO2 also seems to be wrong and has to be GPIO0.

syssi commented 2 years ago

How did you check this? You are from Germany aren't you? My inverter is offline already because it's dark out there. Without solar energy the device doesn't respond /shuts down.

beocycris commented 2 years ago

1.: Wow - tell me "the stupid guy". 2.: Yes I´m from Germany. 3.: You're right. 4.: See 1. ......

So I have to give it another try tomorrow! Thank you!!!!

beocycris commented 2 years ago

I´m just trying to receive the data stream. But like yesterday in the evening, no changes .....

Do i have to change any setting in the invertermenu ? Maybe the ModbusRTU to enable?

syssi commented 2 years ago

Please check your wiring this weekend. It's super important RE/DE is connected properly.

Inverter settings: I don't have any menu items to enable/disable modbus. There is also no menu item to change the modbus address / device id for example. At my firmware version modbus is always enabled. Are you able to control something in this regard?

beocycris commented 2 years ago

Yes - I will check, if RE/DE is connected properly

I have the enabling option and also a menu to change the address of modbus.

But like you said, I´m only able to check that on friday.

What if I change the address to 10. Do I have to change the yaml to 0x0A or 0x10 ?

syssi commented 2 years ago

The different menu sounds like real modbus rtu (polling selected registers). There are multiple things we should try as soon you have access to your device. ;-)

syssi commented 2 years ago

Could you provide your exact model name of the type label (something like X1-2.0-S-D(L)), the software versions (master/manager) of your device and may be some photos of the menu structure? It should help to compare your device with well known devices/protocols.

beocycris commented 2 years ago

Good morning. Well- the sun is shining so I was able to take a look at my settings. It s a X1 1.5 SD(L)

98104732-855C-4ED5-95ED-414F37072CA0 E04E064C-AC28-40C7-86FA-FF6AFB52C1A6 57965506-2EFB-435B-A9D1-366E1952EBE4

syssi commented 2 years ago

Could you look for some firmware versions at the menu?

beocycris commented 2 years ago

image image

Do you need these?

syssi commented 2 years ago

Perfect! Next wish: Could you provide a photo of the type label (on the right side of the device)?

syssi commented 2 years ago

Please provide some photos of your new wiring as next step. Enable the debug output of the UART component:

https://github.com/syssi/esphome-modbus-solax-x1#debugging

and provide some logs. It would like to know there is some serial traffic (outgoing & incoming) or not.

beocycris commented 2 years ago

Sorry for the bad quality: TX= DI = blue cable RX = RO = green cable D4 = DE/RE = brown cable IMG_6977 IMG_6973

syssi commented 2 years ago

Alright! Next step is to collect some serial traffic. Could you provide some logs (debug output of the uart component enabled)?

syssi commented 2 years ago

Could you provide your configuration yaml? I would like to check you are using D4 = GPIO2 vs. D3 = GPIO0.

beocycris commented 2 years ago
Bildschirmfoto 2022-03-20 um 08 56 25

I think there ist some communication......

beocycris commented 2 years ago
Bildschirmfoto 2022-03-20 um 08 57 49
syssi commented 2 years ago

Looks good! :-) Issue solved.

beocycris commented 2 years ago

Thank you very much for supporting me!

syssi commented 2 years ago

Please make sure to set the logger to 0 baud if you use GPIO1 and 3. Otherwise log messages are transmitted to the inverter too. ;-)

syssi commented 2 years ago

I will merge the flow control support into main now. Please update the feature branch at the external components section to @main again later the day.

beocycris commented 2 years ago
Bildschirmfoto 2022-03-20 um 09 32 10

Of course. It should be fine like this!

syssi commented 2 years ago

Perfect! Last question about your device: You've enabled the ModbusRTU setting and the device address is set to 1. Right? I would like to improve the docs.

beocycris commented 2 years ago

No is disabled the RTU option. C267EAEE-F9B1-4A4C-B5D0-AD5D308B8345 C817022E-34F8-4E67-8536-6D1CD9DD6F64