如图所示风扇的空洞是非常大,想装什么就装什么!!!!
风扇用了有一年多了,买回来的时候就想改装了 ,太太怀孕了 ,所以~~~
增加一颗光感,懒怠的人能不动手就不动手。~~无光自己关风扇。
材料 :220V转5V,ESP32,4路继电器,杜邦线。
本来想使用esp8266但共需要用10个GPIO,只能使用esp32。接线原理:
1、强电区------风扇电机是4线,分别是红(高速),白(中速),蓝(低速),和黑(零线); 摇头是独立的低 速电机。以上使用一个4路继电器控制。
2、弱电区------原来的1档2档3档和摇头档位,分别连接GPIO用binary_sensor来接入,目得是纯物理的情况下也可以控制风扇。
(esphome 不会使用风扇组件来写,确实看不懂。求大神指教)
固件使用esphome 代码如下:
esphome:
name: esp32_01_fan
platform: ESP32
board: nodemcu-32s
wifi:
ssid: "***"
password: "****"
fast_connect: on
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32 01 Fan"
password: "****"
manual_ip:
static_ip: 192.168.10.9
gateway: 192.168.10.1
subnet: 255.255.255.0
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "****"
ota:
password: "****"
#esp32_ble_tracker:
i2c:
sda: 21
scl: 22
scan: True
id: bh_a
sensor:
- platform: bh1750
name: "BH1750"
i2c_id: bh_a
address: 0x23
update_interval: 60s
switch:
- platform: restart
name: "rst_esp32_fan"
- platform: gpio
name: "yaotou"
pin: 16
# pin: GPIO13
inverted: yes
id: yt
- platform: gpio
name: "fanlow"
pin: 17
inverted: yes
id: low
interlock: [mid, fast]
- platform: gpio
name: "fanmid"
pin: 18
inverted: yes
id: mid
interlock: [low, fast]
- platform: gpio
name: "fanfast"
pin: 19
inverted: yes
id: fast
interlock: [low, mid]
binary_sensor:
- platform: status
#连接状态
name: "esp32_fan"
- platform: gpio
name: "yttouch"
pin: {number: GPIO14, mode: INPUT_PULLUP, inverted: True}
filters: [{delayed_on: 40ms}, {delayed_off: 40ms}]
on_state: [{switch.toggle: yt}]
- platform: gpio
name: "lowtouch"
pin: {number: GPIO25, mode: INPUT_PULLUP, inverted: True}
filters: [{delayed_on: 40ms}, {delayed_off: 40ms}]
on_state: [{switch.toggle: low}]
- platform: gpio
name: "midtouch"
id: midt
pin: {number: GPIO26, mode: INPUT_PULLUP, inverted: True}
filters: [{delayed_on: 40ms}, {delayed_off: 40ms}]
on_state: [{switch.toggle: mid}]
- platform: gpio
name: "fasttouch"
pin: {number: GPIO27, mode: INPUT_PULLUP, inverted: True}
filters: [{delayed_on: 40ms}, {delayed_off: 40ms}]
on_state: [{switch.toggle: fast}]
~~~~目前还需在写二个自动化是当风扇1档2档3档都关闭,摇头自动关闭;在19-01时光感为0,关闭风扇。(我还没有写,因为风扇这几天还不用)
|