Skip to content
Smart Devices

How to Control a Fan From Your Phone With an ESP32

Switch your fan on and off and change its speed from your phone with a small ESP32 board and a free web remote. No app to install.

T ToolPoint Team 2 min read
A fan with speed buttons and a Wi-Fi signal
In this post
  1. What you need
  2. Safety first
  3. Step 1: Try the remote in demo mode
  4. Step 2: Pick how to connect
  5. Step 3: Get the code and upload it
  6. Step 4: Connect and control
  7. Other fan remotes

Want to switch your fan on and off from your bed, and change its speed from your phone? You can, with a small ESP32 board and our free Web Fan Remote. You do not need to install any app. It works in your phone's browser.

What you need

  • An ESP32 board (an ESP8266 also works)
  • A relay module or a fan regulator module that can control a fan
  • Jumper wires and a safe power supply for the board
  • A fan
  • A qualified electrician for the mains wiring

Wiring idea: phone, Wi-Fi, ESP32, relay module and fan, with a mains power warning

Safety first

A fan runs on mains power (230 V), and mains power can kill. Please:

  • Ask a qualified electrician to do any wiring that touches mains power.
  • Use a proper relay module, a fuse and a closed box (enclosure).
  • Keep a normal wall switch, so you can always turn the fan off by hand.
  • Never use a web remote as the only way to stop a machine.

Step 1: Try the remote in demo mode

Open the Web Fan Remote. You will see a fan with a power button, five speed steps, normal, breeze and sleep modes, and an auto-off timer. Play with it. The fan in the preview spins faster when you raise the speed. Nothing is connected yet, so this is completely safe.

Step 2: Pick how to connect

Press Connect my device. You can connect your ESP32 by:

  • Bluetooth
  • Wi-Fi hotspot (no router needed)
  • Home Wi-Fi
  • USB cable
  • The internet (MQTT)

Bluetooth and Wi-Fi hotspot are the easiest to start with.

Step 3: Get the code and upload it

Press Get the code for this. We write the Arduino code for the way you chose. Open it in the Arduino IDE, choose your board and upload it.

Step 4: Connect and control

Connect from the remote. Now the buttons control your real fan. If something does not work, go back to demo mode to check that the screen itself works, then check the wiring with your electrician.

Other fan remotes

Have a different kind of fan? Try the Web Exhaust Fan Remote, or the Web Temperature-Based Fan Controller, which can switch a fan on when the room gets hot.

Tools from this post

Keep reading

All posts