ESP32 & ESP8266 Connectivity · Beginner · Web control
ESP8266 Web Fan Controller
A 12 V fan under web control, with a temperature reading deciding when it should be on.
Firmware status: Generated from this project's own pin map and compiled with arduino-cli for esp8266:esp8266:nodemcuv2 before publication; bench validation on your hardware is still required.
Board: ESP8266 (NodeMCU v3 / Wemos D1 mini) · ESP8266EX @ 80 MHz · 3.3 V logic · build for esp8266:esp8266:nodemcuv2.
What you will build
An ESP8266 driving a fan through a MOSFET, with a temperature reading on the same page and a manual override.
Components
- ESP8266 board
- 12 V fan
- Logic-level MOSFET (IRLZ44N or similar)
- 10 kΩ gate pull-down
- Temperature sensor on A0 (thermistor or LM35)
- 12 V supply
Pin map for this build
| Sketch constant | Pin | What it is |
|---|---|---|
PIN_OUT_1 | 12 | Switched output — relay / MOSFET channel, 5 V coil |
PIN_IN_1 | A0 | Analog input — 3.3 V maximum at the pin |
Tools
- USB programming cable
- Multimeter
- Current-limited bench supply (for anything that switches a load)
- Small screwdriver and wire cutters
Build sequence
- Build the MOSFET stage with the gate pull-down, and confirm the fan is off with the GPIO floating.
- Wire the sensor to A0 and check its reading against a known temperature.
- Flash and open the page: the manual channel switches the fan, the automatic channel follows the threshold.
- Watch the reading move as the fan runs, and set the threshold from what you measure.
Test and expected result
The fan switches from the page, the reading responds to a real temperature change, and the gate stays low when the GPIO is not driven.
Acceptance checks
fan switches, temperature tracks, no reset on switching
Safety and limits
Inductive loads kick back: fit a diode across the fan. A 12 V rail must never reach the 3.3 V GPIO under fault.
Hardware scope
Single PWM channel through a MOSFET, one analog temperature input, HTTP control.
Connection diagram
Download the connection diagram (SVG)
Download the Arduino sketch (E06_esp8266_web_fan_controller.ino)
Guide source: the sketch on this page was generated from the pin map above and compiled for esp8266:esp8266:nodemcuv2 before publication.
Related projects
- ESP32 Captive Portal Wi-Fi Manager — Boot the ESP32 with no credentials and configure its network from a phone, with the portal saved to flash.
- ESP8266 Config Portal — The same idea on the cheapest board that can do it: an ESP8266 that configures itself from a browser.
- ESP8266 Sensor Portal Logger — A battery-minded sensor node you configure in the field, with the reading shown on its own setup page.