jourdant / esphome-lgap

16 stars 2 forks source link

Lilygo T-RSC3 Question #4

Open jourdant opened 5 months ago

jourdant commented 5 months ago

Just moving this content out to a separate issue to have a discussion:

Hi I would like to use lilygo t-rsc3 for 2 projects one with rs232 and one with rs485, I was trying rs485 with esphome apparently it doesn't work, could you give me some help?

this is what I need to insert into rs485

captive_portal:

button:
    - platform: restart
      id: mppt4880
      name: "${friendly_name} Restart"

uart:
  tx_pin: GPIO3
  rx_pin: GPIO1
  id: mod_bus
  baud_rate: 9600
  stop_bits: 1

modbus:
  #flow_control_pin: 23
  uart_id: mod_bus
  id: mod_bus_mppt

modbus_controller:
  - id: mppt
    ## the Modbus device addr
    address: 0x1
    modbus_id: mod_bus_mppt
    command_throttle: 200ms
    setup_priority: -10
    update_interval: 5s

sensor:
#   - platform: modbus_controller
#     modbus_controller_id: mppt

#     name: Rated Current
#     address: 10009
#     register_type: holding
#     value_type: U_WORD
#     register_count: 1
#     filters:
#       - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: mppt

    name: Charger Workstate
    address: 15201
    register_type: holding
    value_type: U_WORD
    register_count: 1
#   - platform: modbus_controller
#     modbus_controller_id: mppt

#     name: MPPT state
#     address: 15202
#     register_type: holding
#     value_type: U_WORD
#     register_count: 1

#   - platform: modbus_controller
#     modbus_controller_id: mppt

#     name: Charging state
#     address: 15203
#     register_type: holding
#     value_type: U_WORD
#     register_count: 1

  - platform: modbus_controller
    modbus_controller_id: mppt
    id: pv_input_voltage
    name: pv_input_voltage
    address: 15205
    unit_of_measurement: "V" ## for any other unit the value is returned in minutes
    register_type: holding
    value_type: U_WORD
    register_count: 1

    accuracy_decimals: 1
    icon: mdi:sine-wave
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: mppt
    id: batt_input_voltage
    name: batt_input_voltage
    address: 15206
    unit_of_measurement: "V" ## for any other unit the value is returned in minutes
    register_type: holding
    value_type: U_WORD
    register_count: 1

    accuracy_decimals: 1
    icon: mdi:sine-wave
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: mppt
    id: batt_input_current
    name: batt_input_current
    address: 15207
    unit_of_measurement: "A"
    register_type: holding
    value_type: U_WORD
    register_count: 1
    filters:
      - multiply: 0.1
    accuracy_decimals: 1

  - platform: modbus_controller
    modbus_controller_id: mppt
    id: pv_input_power
    name: pv_input_power
    address: 15208
    unit_of_measurement: "W" ## for any other unit the value is returned in minutes
    register_type: holding
    value_type: U_WORD
    register_count: 1

    accuracy_decimals: 1
    icon: mdi:sine-wave

  - platform: modbus_controller
    modbus_controller_id: mppt

    name: MPPT temperature
    address: 15209
    unit_of_measurement: "°C" ## for any other unit the value is returned in minutes
    register_type: holding
    value_type: U_WORD
    register_count: 1

  - platform: modbus_controller
    modbus_controller_id: mppt

    name: MPPT energy
    address: 15217
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_WORD
    register_count: 1

number:

  - platform: modbus_controller

    name: MPPT Float Volatge
    address: 10104
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "V"
    icon: mdi:timer-sand
    min_value: 24
    max_value: 56
    step: 1
    lambda: "return  x * 0.1; "

  - platform: modbus_controller
    id: mppt_max_current
    name: MPPT Corrente Max
    address: 10108
    value_type: U_WORD
    register_type: holding
    unit_of_measurement: "A"
    icon: mdi:timer-sand
    min_value: 1
    max_value: 80
    step: 1
    lambda: "return  x * 0.1; "
    write_lambda: |-
      ESP_LOGD("main","Modbus Number incoming value = %f",x);
      uint16_t b_capacity = x*10  ;
      payload.push_back(b_capacity);
      return x  ;

Originally posted by @grydo in https://github.com/jourdant/esphome-lgap/issues/1 and since moved here

jourdant commented 5 months ago

Hi @grydo - I haven't had any issues using the RS485 interface (or RS232 for that matter) with esphome so far. Here's a link to a sample file that was working with modbus successfully for me on this board: https://github.com/jourdant/esphome-lgap/blob/main/ref/modbus_esphome.yaml.

A couple of things to note about that particular file: