Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A16S Modbus control
#1
Hi,

I would like to control my A16S board with modbus protocol. The controller is an ESP32 with esphome firmware. The switch part of the esphome config is as follows:

switch:

  - platform: modbus_controller
    name: 'testsw1'
    address: 0
    register_type: coil
    bitmask: 1
…. to switch 8

  - platform: modbus_controller
    name: 'testsw8'
    address: 7
    register_type: coil
    bitmask: 1

  - platform: modbus_controller
    name: 'testsw9'
    address: 8
    register_type: coil
    bitmask: 1

Everything works perfectly as long as only the first 8 switches are defined. However, if relay 9 is also configured, when it is switched on, the 9th relay switches but the status feedback comes back from the first relay (in esphome 1st relay on - 9th relay off ; on the relay board 9th relay on 1st off) and vice versa. How to program esphome so that it works correctly? 

   
   
Reply
#2
whether switch 1--8 correctly?
whether switch 9-16 error? need details. You'd better list switch9-16 , how these works.
Reply
#3
Sorry I was misunderstood. 
If 8 switches are defined on esphome side, everything works perfectly. The order is irrelevant, any 8 switches can be defined like: 1-2-9-10-11-12-13-14-15. It works perfectly.
The moment a 9th switch is defined, the following pairs start to malfunction: 1-9, 2-10, .....7-15, 8-16.
The flow when 16 switches are defined: switching 1st HA - 1st relay switch - 1st switch turns off in HA and 9th turns on. On relay board the 1st relay is still on.
The error may be somewhere on the esphome side, or I'm trying to use the wrong configuration:

switch:
  - platform: modbus_controller
    name: 'testsw1'
    address: 0
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw2'
    address: 1
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw3'
    address: 2
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw4'
    address: 3
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw5'
    address: 4
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw6'
    address: 5
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw7'
    address: 6
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw8'
    address: 7
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw9'
    address: 8
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw10'
    address: 9
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw11'
    address: 10
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw12'
    address: 11
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw13'
    address: 12
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw14'
    address: 13
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw15'
    address: 14
    register_type: coil
    bitmask: 1
  - platform: modbus_controller
    name: 'testsw16'
    address: 15
    register_type: coil
    bitmask: 1
Reply
#4
Do you have downloaded KCS firmware to KC868-A16S board's ESP32?
Reply
#5
Yes I did. Not the latest but 2.1.9
Reply
#6
you can send modbus command to A16S by PC serial port tool, test whether every 16 modbus command for ON/OFF relay is correctly.
Reply
#7
I only want to switch a maximum of 3 relays from one point, so the current interworking error is not a problem for me. I will report it on the esphome forum.
Reply
#8
ok, good.
Reply


Forum Jump:


Users browsing this thread:
2 Guest(s)