TechSmartSolutions / 0-10v-lighting-controller-for-Home-Assistant

The purpose of this repo is to explain how you can build 0-10v controllers that can be used for controlling lighting and other compatible devices (such as certain dehumidifiers and air conditioners) using an ESP, ESPhome and Home Assistant.
16 stars 2 forks source link

Can introduce an relay for on/off dimmer power. #8

Open rusudanion opened 1 year ago

rusudanion commented 1 year ago

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

p1ngb4ck commented 4 months 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

Enable logging

logger:

Enable Home Assistant API

api:

Allow Over-The-Air updates

ota:

font:

i2c: sda: 4 scl: 5 scan: true frequency: "1MHz"

pca9685:

output:

light:

mcp23017:

8 individual relays

switch:

globals:

display:

interval:

Allow provisioning Wi-Fi via serial

improv_serial:

Example configuration entry

sensor:

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: `