I’m new to MODBUS and trying to figure it out but from a very particular use-case scenario. I just installed a bigger solar controller which uses RS485 and MODBUS to report data. I did a bunch of search on here and other places and I think I understand what is supposed to happen but I can’t figure out how to make it happen.
Goal: Get the solar data from the controller and into Home Assistant.
Method: Preferably via ESP32 (or ESP8266 but it seems software UART can be an issue) and RS485 to TTL board. I have both the C25B and auto flow-control versions on hand.
Info gained so far:
I know a bunch of guys have done this already for other solar controllers and I have tried to use as much of their work to learn as I can. The issue there is that each controller (slave device) uses different parameters and I cannot find anything on the Ampinvt controller for this use case.
I watched a video on Youtube where a guy named Antony Cartwright explains there is an issue with ESP32 MODBUS implementation but his video was above my knowledge level.
I know that I need to send a command from the ESP32 (master) to the controller (slave) in order for the controller to send the data back to the ESP32.
I have the MODBUS data sheet from the manufacturer here.
My ESP32 YAML is:
esphome: name: esp32-solar-monitor comment: PuraVida | Solar Monitor esp32: board: esp32dev framework: version: recommended type: arduino logger: # baud_rate: 9600 level: VERY_VERBOSE logs: scheduler: DEBUG api.service: DEBUG wifi: manual_ip: static_ip: 192.168.10.151 gateway: 192.168.10.1 subnet: 255.255.255.0 dns1: 192.168.10.1 dns2: 0.0.0.0 ap: ssid: "Fallback_SolarMonitor" password: "" ap_timeout: 1min domain: .local reboot_timeout: 15min power_save_mode: NONE fast_connect: false output_power: 20.0 networks: - ssid: !secret wifi_ssid password: !secret wifi_password priority: 0.0 use_address: 192.168.10.151 captive_portal: api: password: !secret api_password port: 6053 reboot_timeout: 15min ota: password: !secret ota_password safe_mode: true port: 8266 uart: id: uart_bus tx_pin: 17 rx_pin: 16 baud_rate: 9600 debug: time: - platform: homeassistant id: esptime # - platform: sntp on_time: - seconds: 15 then: - uart.write: [0x01, 0xA1, 0x00, 0xFF] button: - platform: restart name: "Solar Monitor Restart" switch: - platform: gpio pin: 4 name: "Solar Controller Writing mode" #if "on" reading from inverter doesn't work! internal: true #switch is not exposed to HA frontend, should you ever need to write to the inverter, just comment this line
I can see the ESP32 sending the uart.write command but I’m getting nothing back at all from the controller in response. I do, on occasion, get a bunch of zeros.
My current thought is that I have no idea if the uart.write command is correct. I’m trying to learn about registers etc. but the knowledge online is very generic and I suspect that there is a very definitive aspect to this that is not ordinary. While I continue down that path, I figure I’d ask the hive-mind here if anyone can share suggestions.