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 constantPinWhat it is
PIN_OUT_112Switched output — relay / MOSFET channel, 5 V coil
PIN_IN_1A0Analog 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

  1. Build the MOSFET stage with the gate pull-down, and confirm the fan is off with the GPIO floating.
  2. Wire the sensor to A0 and check its reading against a known temperature.
  3. Flash and open the page: the manual channel switches the fan, the automatic channel follows the threshold.
  4. 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

Connection diagram for ESP8266 Web Fan Controller

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

Back to all project guides · Study the course