Index
WebREPL (Web-based Read-Eval-Print Loop) lets you wirelessly interact with your ESP32 running MicroPython — using a web browser or terminal. It’s incredibly useful when your board is deployed in a hard-to-reach place or when USB access isn’t practical.
Why Use WebREPL?
- Access the MicroPython prompt over Wi-Fi (REPL = Python shell).
- Upload/download
.py
files wirelessly. - Debug without physically connecting your ESP32 to a USB.
- Great for remote monitoring or testing in enclosures.
Step-by-Step: Setup WebREPL on ESP32
1. Flash MicroPython (if not already done)
Make sure your ESP32 is running MicroPython. You can flash it using tools like esptool.py
or the Thonny IDE.
2. Connect via USB & open REPL
You can use:
- Thonny IDE (best for beginners)
- Or command-line tools like
mpremote
,rshell
,ampy
3. Enable WebREPL
In REPL, run:
import webrepl_setup
It will prompt:
Would you like to (E)nable or (D)isable WebREPL? E
Would you like to change the password? Y
New password (4-9 chars): 12345678
→ This creates/edits a file named webrepl_cfg.py
in the ESP32 filesystem.
🔹 4. Reboot the Board
import machine
machine.reset()
After reboot, WebREPL starts automatically (unless disabled).
5. Connect ESP32 to Your Wi-Fi
Before WebREPL can be used, your ESP32 needs to be on the same Wi-Fi as your computer.
Example:
import network
sta = network.WLAN(network.STA_IF)
sta.active(True)
sta.connect('YOUR_SSID', 'YOUR_PASSWORD')
while not sta.isconnected():
pass
print('Connected:', sta.ifconfig())
Note the IP address printed — that’s how you’ll connect to WebREPL.
6. Connect from Your Browser
- Go to: http://micropython.org/webrepl/
- Enter the IP address shown earlier (e.g.,
192.168.1.42
) - Click Connect
- Enter your WebREPL password
You now have a wireless MicroPython terminal in your browser!
Uploading & Downloading Files
Use the file selector in the WebREPL interface to:
- Upload
.py
scripts - Download log or data files from the ESP32
This is a game-changer for deploying updates over-the-air without needing USB access.
Optional: Use webrepl_cli.py
(Command Line)
MicroPython provides a command-line tool (webrepl_cli.py
) for uploading/downloading files.
Install it:
git clone https://github.com/micropython/webrepl
cd webrepl
Upload a File:
python3 webrepl_cli.py main.py 192.168.1.42:password
❗ Things to Keep in Mind
- ESP32 must be on the same Wi-Fi network.
- WebREPL uses port 8266, ensure it’s not blocked by a firewall.
- You cannot flash firmware via WebREPL — it’s for debugging and file access only.