I’m using this custom component to create modbus slaves from my ESP - GitHub - epiclabs-uc/esphome-modbus-server: ESPHome Modbus Server component.
This is a part of my slave YAML file:
external_components:
- source: github://arpiecodes/esphome-modbus-server@master
refresh: 3d
components:
- modbus_server
uart:
id: modbus_serial_port
tx_pin: 1 #TX
rx_pin: 3 #RX
baud_rate: 115200
modbus_server:
- id: modbuserver
uart_id: modbus_serial_port
address: 2 # slave address
#de_pin: 17
#re_pin: 17
holding_registers:
- start_address: 1 # in this example we map register 200 to a switch
number: 1
on_write: |
ESP_LOGI("ON_WRITE", "This is a lambda. address=%d, value=%d", address, value);
if(value)
id(led_strip)->turn_on();
else
id(led_strip)->turn_off();
return value;
on_read: |
return id(led_strip)->state ? 1 : 0;
- start_address: 2
number: 1
on_write: |
ESP_LOGI("ON_WRITE", "This is a lambda. address=%d, value=%d", address, value);
if(value)
id(wlan)->enable();
else
id(wlan)->disable();
return value;
on_read: |
return id(wlan)->is_disabled() ? 0 : 1;
light:
- platform: neopixelbus
type: GRB
id: led_strip
variant: WS2812
pin: GPIO4
num_leds: 26
name: "NeoPixel Light"
effects:
- random:
- strobe:
- flicker:
- addressable_rainbow:
- addressable_color_wipe:
- addressable_scan:
- addressable_twinkle:
- addressable_random_twinkle:
- addressable_fireworks:
- addressable_flicker:
I would like to control the LED from my MASTER esp but I’m not sure if it’s possible. As you can see, I tried to atleast turn on/off the LED in the address 1 but that didn’t work. Is there a way to control the LED from the MASTER with all the functionality(color change,brightness etc.)?