Since I plan to use MOSFETs to turn the power to the fans off and on, I wanted to make sure I understood how that should be wired up. I wrote the equivalent of the ubiquitous "blink" program in ESPHome configuration.
substitutions:
node_name: esp32-blink
log_level: DEBUG
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
ota_password: !secret ota_password
LED: 'GPIO14'
esphome:
name: ${node_name}
platform: esp32
board: esp32dev
wifi:
ssid: ${wifi_ssid}
password: ${wifi_password}
ota:
password: ${ota_password}
switch:
- platform: gpio
name: "${node_name} LED"
id: i_led
internal: true
pin:
number: ${LED}
inverted: yes
interval:
- interval: 0.5s
then:
- switch.toggle: i_led
- GPIO14 is the control signal. It's wired to the Gate of the MOSFET. Because I've seen it illustrated a couple of places, I also used a resistor for current limiting.
- The MOSFET Source is wired to one of the ground pins of the ESP32.
- The MOSFET Drain is wired through a current limiting resistor to the cathode leg of an LED.
- The anode leg of the LED is wired directly to the 3.3v output pin of the ESP32.
- The ESPHome configuration toggles the GPIO14 control signal every 0.5 seconds.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.