Open rusudanion opened 1 year ago
Hey mate,
I have just achieved exactly what you were looking for also, so here you are - sorry, 1 year late :D
The following is my configuration, having set up everything with an "8 channel relay" module for rpi/Arduino. The typical ones with the Songle relay on it. Those are active low and accept 3.3V as high state luckily. I switch that by using an MCP23017 port expander, and the first two relays of this 8 relay module are dedicated to switch the first LED light physically on/off from mains automatically, while not appearing in the Web-IF/HomeAssistant as separate switches.
What I am doing (in short): Connect a mcp23017 via i2c. All address pins to GND = 0x20 address. Reset with resistor to VCC, VDD to GND (just like stated in all docs). Pins configured as inverted in esphome (see following config). Power the relay with 5V from power supply (not via the Wemos from USB, the relay needs 55mA per coil = 400mA all 8 enabled + the esp itself - not possible from USB !!!). Power the mcp23017 from 3.3V. Connect the A-Port pins (the ones on the side of the gnd pin if you are using dip8 package) to the relay input pins, as well as GND to esp-GND of course. Add the relay you want to trigger via the LED light as a switch in the config (see my config as example), but don`t give it a name ! Only ID ! This way, it is useable, but not visible in ESPHome Web-IF or HomeAssistant. Then, add the turn_on and turn_off functions to the lights config.
Tested, works.
With my setup, where I am working on the documentation, I use a Adafruit 16 channel servo pwm module for LED-PWM, so please don`t be irritated with that, it works just the same with the 24 channel module shown here in this repo.
If you are interested: Have a look at the pwm topic I posted - I explained there, how I use that 16 channel servo motor pwm module instead of the 24 one here, to be able to work without an additional power-supply and provide pwm dimming instead of voltage-dimming -> together with a 2 channel relay, set up as described here, you could use a 230V->5V/2A buck module to create your own zigbee style device, just "being hooked in" the ac-line of the lamp (having ac in- & output, in comes from mains, lamp goes to out). Relays switch both phases of the ac line to be safe (thats why you need 2 relays). This "pseudo"-zigbee could control quite a bunch of devices though, compared to the original one.
My case : I had that servo module before ordering the 24 channel one, so now I have both. For my use case, the 16 channel one fits better, together with a small circuit (transistor + resistor for each channel extra) for the LED-dimming - so I have the 24 channel one left - this can be used to make a fan controller out of it. Everything is working so far regarding that also - I only have to check, how much power consumption there will be overall if everthing is enabled, to check if there are power supplies that will fit those needs (ac=>12V or 5V with ~25W to ~30W, small enough to integrate into a bigger wire/plug).
hope this helps...
`substitutions: name: esphome-web-ed65b3 friendly_name: ESPHome Wemos
esphome: name: ${name} friendly_name: ${friendly_name} name_add_mac_suffix: false project: name: esphome.web version: '1.0'
esp8266: board: esp01_1m
logger:
api:
ota:
font:
i2c: sda: 4 scl: 5 scan: true frequency: "1MHz"
pca9685:
output:
light:
mcp23017:
switch:
platform: gpio icon: mdi:electric-switch id: relay1 pin: mcp23xxx: mcp23017_hub
number: 0 mode: output: True pullup: False inverted: True
platform: gpio icon: mdi:electric-switch id: relay2 pin: mcp23xxx: mcp23017_hub
number: 1 mode: output: True pullup: False inverted: True
platform: gpio name: "Relais 1" icon: mdi:electric-switch id: relay3 pin: mcp23xxx: mcp23017_hub
number: 2 mode: output: True pullup: False inverted: True
platform: gpio name: "Relais 2" icon: mdi:electric-switch id: relay4 pin: mcp23xxx: mcp23017_hub
number: 3 mode: output: True pullup: False inverted: True
platform: gpio name: "Relais 3" icon: mdi:electric-switch id: relay5 pin: mcp23xxx: mcp23017_hub
number: 4 mode: output: True pullup: False inverted: True
platform: gpio name: "Relais 4" icon: mdi:electric-switch id: relay6 pin: mcp23xxx: mcp23017_hub
number: 5 mode: output: True pullup: False inverted: True
platform: gpio name: "Relais 5" icon: mdi:electric-switch id: relay7 pin: mcp23xxx: mcp23017_hub
number: 6 mode: output: True pullup: False inverted: True
platform: gpio name: "Relais 6" icon: mdi:electric-switch id: relay8 pin: mcp23xxx: mcp23017_hub
number: 7 mode: output: True pullup: False inverted: True
globals:
display:
interval:
improv_serial:
sensor:
wifi:
ap: {}
ap
this allows the usercaptive_portal:
dashboard_import: package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main import_full_config: true
web_server: `
Hello.can you introduce a guide for connecting an relay to esp32 ,and use this relay for on/off the driver? Maybe when the dimming Is below 3% ,the relay openning and cut off the voltage of driver. Can anyone give me the esp settings for this progect ? iHave an xlg meanwell driver and i buy some esp32 one relay and this DAC converter € 2,00 5%di SCONTO | Modulo di espansione DAC Arduiuo kit fai da te convertitore di tensione da PWM a 0-5V/0-10V per NANO PRO MEGA esp8266 esp32 https://a.aliexpress.com/_Ew02Rgn . thankyou