https://github.com/13rac1/esp8266-remote-fan-relay
Convert a manual four-way switched fan to remote WiFi control using a four channel relay and a ESP8266 microcontroller
https://github.com/13rac1/esp8266-remote-fan-relay
arduino esp8266 esp8266-arduino esp8266-projects esp8266-webserver home-assistant home-automation iot-device openhab platformio
Last synced: about 1 month ago
JSON representation
Convert a manual four-way switched fan to remote WiFi control using a four channel relay and a ESP8266 microcontroller
- Host: GitHub
- URL: https://github.com/13rac1/esp8266-remote-fan-relay
- Owner: 13rac1
- Created: 2021-05-07T18:28:03.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-16T07:04:50.000Z (almost 4 years ago)
- Last Synced: 2025-03-14T21:12:58.997Z (about 1 month ago)
- Topics: arduino, esp8266, esp8266-arduino, esp8266-projects, esp8266-webserver, home-assistant, home-automation, iot-device, openhab, platformio
- Language: C
- Homepage:
- Size: 126 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ESP8266 Remote Fan Relay
Convert a manual four-way switched fan to remote WiFi control using a four
channel relay.## Parts
* A fan (or other device) with a four position switch: off, low, medium, high.
* [ESP8266 NodeMCU CP2102 ESP-12E Development Board](https://amzn.to/3tsSgZ2)
* [4 Channel 5V Relay Module](https://amzn.to/3tnwi9S)
* [120V AC to DC 5V 2A/10W Power Supply](https://amzn.to/3bbZUAH)
* Wire, Solder, Heatshrink, & Tools
* Optional: [Dustproof Weatherproof IP65 Electrical Box - Project Enclosure](https://amzn.to/3h91ZBi)## Directions
1. Setup [PlatformIO](https://platformio.org/)
2. Copy the `src/credentials.h.example` file to `src/credentials.h`.
3. Add the WiFi SSID and password to `src/credentials.h`.
4. Test the network connection and confirm the web form appears on port 80.
5. Now "just" assemble the hardware and install fit in your fan. YMMV depending
on device. In this case, the fan has been wired so the manual control works
as a failsafe when the power relay is unpowered. *See example wiring below*.
6. Done? Now control your fan with:
* The HTML form
* [OpenHAB HTTP binding](https://v2.openhab.org/addons/bindings/http1/)
* [Home Assitant RESTful Command
integration](https://www.home-assistant.io/integrations/rest_command/)
* Android - [HTTP Request Shortcuts](https://play.google.com/store/apps/details?id=ch.rmy.android.http_shortcuts&hl=en_US&gl=US)### Android HTTP Request Shortcuts Example
Create in-app shortcuts `GET` requests to the following URLS:
* `http://device-ip-address/?speed=off`
* `http://device-ip-address/?speed=low`
* `http://device-ip-address/?speed=medium`
* `http://device-ip-address/?speed=high`Enables creation of a Homescreen folder of fan control shortcuts:
[](android-fan-control.png)Note: Linux, Windows, MacOS, and iOS can use Zeroconf/Bonjour/mDNS `.local`
domains, [only Android cannot](https://github.com/Waboodoo/HTTP-Shortcuts/issues/230) 🙄## Wiring
### Before
[](mermaidjs-fan-before.png)
MermaidJS Source
```mermaidjs
graph TB
subgraph 120V[120 Volt AC]
+120[+120VAC]
-120[-120VAC]
endsubgraph S[4 Way Switch]
S-IN[IN]
S-OUT1[OUT 1]
S-OUT2[OUT 2]
S-OUT3[OUT 3]
endsubgraph M[3 Speed Fan Motor]
M-GND[GND]
M-LOW[Low]
M-MED[Medium]
M-HIGH[High]
end-120-->M-GND
+120-->S-IN
S-OUT1-->M-HIGH
S-OUT2-->M-MED
S-OUT3-->M-LOW
```### After
[](mermaidjs-fan-after.png)
MermaidJS Source
```mermaidjs
graph TB
subgraph 120V[120 Volt AC]
+120[+120VAC]
-120[-120VAC]
endsubgraph S[4 Way Switch]
S-IN[IN]
S-OUT1[OUT 1]
S-OUT2[OUT 2]
S-OUT3[OUT 3]
endsubgraph M[3 Speed Fan Motor]
M-GND[GND]
M-LOW[Low]
M-MED[Medium]
M-HIGH[High]
endsubgraph T[5V DC Transformer]
T+120[+AC]
T-120[-AC]
T+5[+DC]
T-5[-DC]
endsubgraph ESP[ESP8266]
VIN
GND
subgraph D[Digital Out]
D1
D5
D6
D7
end
endsubgraph R[4 channel 5V relay]
DC+
DC-
subgraph R1[Relay 1]
IN1[In]
NO1[Normally Open]
COM1[Common]
NC1[Normally Closed]
end
subgraph R2[Relay 2]
IN2[In]
NO2[Normally Open]
COM2[Common]
NC2[Normally Closed]
end
subgraph R3[Relay 3]
IN3[In]
NO3[Normally Open]
COM3[Common]
NC3[Normally Closed]
end
subgraph R4[Relay 4]
IN4[In]
NO4[Normally Open]
COM4[Common]
NC4[Normally Closed]
end
end
%% Original Wiring
-120-->M-GND
S-OUT1-->M-HIGH
S-OUT2-->M-MED
S-OUT3-->M-LOW+120-->T+120
-120-->T-120
+120-->COM1
T+5-->VIN
T-5-->GND
T+5-->DC+
T-5-->DC-D5-->IN1
D6-->IN2
D7-->IN3
D1-->IN4%% Stock switch powered when relay is unpowered
NC1-->S-IN
%% Relays 2,3,4 powered by relay 1
NO1-->COM2
NO1-->COM3
NO1-->COM4NO2-->S-OUT3
NO3-->S-OUT2
NO4-->S-OUT1
```## Background
I have a HEPA filter in an out-of-the-way, but awkward to access location.
Problem, solved.## License
MIT