So I have a ventilation system with 4 positions 0,1,2, and 3. I connected 4 relayboard to it. That I connected to a ESP8266 and loaded with this sketch:
esphome:
name: "wesp5"
esp8266:
board: esp01_1m
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-D7E69D"
password: "pAPakYpmsgzC"
switch:
- platform: gpio
name: "Relay_1"
pin: GPIO14
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: "Relay_2"
pin: GPIO12
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: "Relay_3"
pin: GPIO13
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: "Relay_4"
pin: GPIO15
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
It doesn´t get any simpeler. And it works a treat! When I push button one in HA it goes to position 1 etc.
Now I want to have the ventilation react on the Co2 level in a room and I connected a Co2 sensor to a ESP8266 and had that working.
Made an automation in HA to have it go on:
Trigger
type: carbon_dioxide
platform: device
device_id: e05baeb2a6dce5fe7161124e9c559691
entity_id: sensor.senseair_co2_value
domain: sensor
above: 600
Action:
type: turn_on
device_id: 2fe28959819a45af0813c33184f5f725
entity_id: switch.relay_4
domain: switch
And off:
Trigger.
type: carbon_dioxide
platform: device
device_id: e05baeb2a6dce5fe7161124e9c559691
entity_id: sensor.senseair_co2_value
domain: sensor
below: 600
Action
type: turn_off
device_id: 2fe28959819a45af0813c33184f5f725
entity_id: switch.relay_4
domain: switch
(I used the visual editor to do this)
And it works. I expanded it to all the positions and CO2 levels.
But…
When it comes down to position 1, the automation tells the switch to go off, (I get confirmation in the ESPhome log of the ESP board that is connected to the relais), the light on the relaisboard goes out, but the ralais won´t fall off. I first thought it was a fault on the board, but changing to the spare relais (4) didn´t help.
Now if i hammer the switch on my phone a few times I can get it to go off, you hear a different click on the relaisboard. When I use the button to control the relay, it works 100 out of 100 times, on and off.
Could it be that the automation gets the relais to bounce? I learned about debouncing when getting familiar with Arduino. I tried to figure out how to debounce in this situation, but I don´t see how.
The relaisboard is this one
https://nl.banggood.com/Geekcreit-5V-4-Channel-Relay-Module-For-PIC-ARM-DSP-AVR-MSP430-Geekcreit-for-Arduino-products-that-work-with-official-Arduino-boards-p-87987.html?rmmds=myorder&cur_warehouse=CN
And I removed the jumper and used 3.3v for the control of the board and 5v for controlling the relays.
Any help for this newby is much appriciated!
Willem