Can introduce an relay for on/off dimmer power.
Opened this issue · 1 comments
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
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
Enable logging
logger:
Enable Home Assistant API
api:
Allow Over-The-Air updates
ota:
font:
- file: "gfonts://Roboto"
id: my_font
size: 20
i2c:
sda: 4
scl: 5
scan: true
frequency: "1MHz"
pca9685:
- frequency: 1000
output:
- platform: pca9685
channel: 0
id: pwm01
inverted: True
min_power: 0.06
max_power: 0.80 - platform: pca9685
channel: 1
id: pwm02
inverted: True
min_power: 0.06
max_power: 0.80 - platform: pca9685
channel: 2
id: pwm03
inverted: True - platform: pca9685
channel: 3
id: pwm04
inverted: True - platform: pca9685
channel: 4
id: pwm05
inverted: True - platform: pca9685
channel: 5
id: pwm06
inverted: True - platform: pca9685
channel: 6
id: pwm07
inverted: True - platform: pca9685
channel: 7
id: pwm08
inverted: True - platform: pca9685
channel: 8
id: pwm09
inverted: True - platform: pca9685
channel: 9
id: pwm10
inverted: True - platform: pca9685
channel: 10
id: pwm11
inverted: True - platform: pca9685
channel: 11
id: pwm12
inverted: True - platform: pca9685
channel: 12
id: pwm13
inverted: True - platform: pca9685
channel: 13
id: pwm14
inverted: True - platform: pca9685
channel: 14
id: pwm15
inverted: True - platform: pca9685
channel: 15
id: pwm16
inverted: True
light:
- platform: monochromatic
name: "GROW LED Channel 1"
output: pwm01
gamma_correct: 1
on_turn_on:- switch.turn_on: relay1
- switch.turn_on: relay2
on_turn_off: - switch.turn_off: relay1
- switch.turn_off: relay2
- platform: monochromatic
name: "GROW LED Channel 2"
output: pwm02
gamma_correct: 1 - platform: status_led
name: "Status LED"
pin:
number: GPIO2
inverted: true
mcp23017:
- id: 'mcp23017_hub'
address: 0x20
8 individual relays
switch:
-
platform: gpio
icon: mdi:electric-switch
id: relay1
pin:
mcp23xxx: mcp23017_hubUse pin A0
number: 0
mode:
output: True
pullup: False
inverted: True -
platform: gpio
icon: mdi:electric-switch
id: relay2
pin:
mcp23xxx: mcp23017_hubUse pin A1
number: 1
mode:
output: True
pullup: False
inverted: True -
platform: gpio
name: "Relais 1"
icon: mdi:electric-switch
id: relay3
pin:
mcp23xxx: mcp23017_hubUse pin A2
number: 2
mode:
output: True
pullup: False
inverted: True -
platform: gpio
name: "Relais 2"
icon: mdi:electric-switch
id: relay4
pin:
mcp23xxx: mcp23017_hubUse pin A3
number: 3
mode:
output: True
pullup: False
inverted: True -
platform: gpio
name: "Relais 3"
icon: mdi:electric-switch
id: relay5
pin:
mcp23xxx: mcp23017_hubUse pin A4
number: 4
mode:
output: True
pullup: False
inverted: True -
platform: gpio
name: "Relais 4"
icon: mdi:electric-switch
id: relay6
pin:
mcp23xxx: mcp23017_hubUse pin A5
number: 5
mode:
output: True
pullup: False
inverted: True -
platform: gpio
name: "Relais 5"
icon: mdi:electric-switch
id: relay7
pin:
mcp23xxx: mcp23017_hubUse pin A6
number: 6
mode:
output: True
pullup: False
inverted: True -
platform: gpio
name: "Relais 6"
icon: mdi:electric-switch
id: relay8
pin:
mcp23xxx: mcp23017_hubUse pin A7
number: 7
mode:
output: True
pullup: False
inverted: True
globals:
- id: dht11_temperature
type: double
initial_value: "0.00" - id: dht11_humidity
type: double
initial_value: "0.00"
display:
- platform: ssd1306_i2c
id: ssd1306
model: "SSD1306 128x64"
address: 0x3C
pages:- id: page1
lambda: |-
it.printf(50, 24, id(my_font), "%.1f°", id(dht11_temperature)); - id: page2
lambda: |-
it.printf(46, 24, id(my_font), "%.1f%%", id(dht11_humidity));
- id: page1
interval:
- interval: 5s
then:- display.page.show_next: ssd1306
- component.update: ssd1306
Allow provisioning Wi-Fi via serial
improv_serial:
Example configuration entry
sensor:
- platform: dht
pin: GPIO0
id: dht11
temperature:
id: dht11_temp
name: "DHT11 Temperature"
on_value:
then:
- lambda: |-
id(dht11_temperature) = id(dht11_temp).state;
humidity:
id: dht11_rh
name: "DHT11 Humidity"
on_value:
then:
- lambda: |-
id(dht11_humidity) = id(dht11_rh).state;
update_interval: 10s
wifi:
Set up a wifi access point
ap: {}
In combination with the ap
this allows the user
to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
import_full_config: true
To have a "next url" for improv serial
web_server:
`