Skip to content
All guides

Getting Started with Wokwi

Create an ESP32 project in the free Wokwi simulator, understand its three files, add libraries, run it, use the Serial Monitor — and move to real hardware when you are ready.

Wokwi is a free online simulator for microcontrollers. It runs in your browser: you get an ESP32, sensors, LEDs and relays, you write Arduino code, and the simulator behaves like the real circuit — including Wi-Fi. No installation, no hardware, nothing can burn out.

Create an ESP32 project

Open wokwi.com/projects/new/esp32. A new project opens with three areas:

  • on the left, the code editor with tabs for the project files,
  • on the right, the simulation area with an ESP32 DevKit board,
  • below the simulation, the Serial Monitor (it appears when the simulation runs).

You do not need an account to start. You only need one to save your work (see step 6).

Know the three files

Every exercise on this site gives you the same three files. Each one goes into the Wokwi tab with the same name:

File What it contains
sketch.ino The Arduino program that runs on the ESP32
diagram.json The circuit: which parts there are, where they sit and how they are wired
libraries.txt The Arduino libraries the program needs, one per line

diagram.json is the quickest way to get the circuit: open the diagram.json tab, select all its content, delete it and paste ours. The parts and wires appear immediately. You can still move parts around with the mouse — Wokwi updates the file for you.

Add the libraries

Our programs use two libraries: DHT sensor library for ESPx (for the DHT22 sensor) and PubSubClient (for MQTT, from Exercise 2 on).

  1. Open the Library Manager tab in the code editor.
  2. Click the + button, search for the library name and select it.
  3. Repeat for each line of our libraries.txt.

Wokwi then creates a libraries.txt file in your project. You can also create that file yourself and paste our list — the result is the same.

Run the simulation

Press the green Start button (the play symbol). Wokwi compiles the program — this takes a few seconds the first time — and starts the simulation.

The Serial Monitor shows everything the program prints with Serial.print() and Serial.printf(). It is your window into the device: if something does not work, look here first. Compilation errors are shown in the same place before the simulation starts.

Press the Stop button to stop. After a code change, simply press Start again.

Interact with the sensors

While the simulation is running you can change the world around the ESP32:

  • DHT22: click the sensor. A small window opens with sliders for temperature and humidity. Drag them and watch the Serial Monitor.
  • Potentiometer: turn its knob with the mouse. In our exercises it stands for the vibration level of the machine (0–100 %).
  • LED and relay: you cannot click them — they show what the program decided.

Wi-Fi: Wokwi simulates an open network called Wokwi-GUEST (no password) with internet access, so the ESP32 can reach MQTT brokers and cloud platforms. Wokwi monitors this traffic for security reasons — never send private or sensitive data through it.

Save and share

To save your project, sign in to Wokwi (free) and click Save. Your project gets its own address that you can open again later or share with your teacher.

Optional: use real hardware

Every program on this site also runs on a real ESP32 DevKit. The parts are listed on the hardware page. You need the free Arduino IDE 2:

  1. Install the ESP32 boards: open the Boards Manager, search for esp32 and install esp32 by Espressif Systems.
  2. Select the board: Tools → Board → esp32 → ESP32 Dev Module, then select the port of your board under Tools → Port.
  3. Install the libraries in the Library Manager: DHT sensor library for ESPx and PubSubClient — the same names as in libraries.txt.
  4. Change the Wi-Fi settings: use your school network’s name and password and remove the channel number:
const char* WIFI_SSID = "School-WiFi";      // your network
const char* WIFI_PASS = "your-password";
WiFi.begin(WIFI_SSID, WIFI_PASS);          // no ", 6" on a real network
  1. Upload the program and open the Serial Monitor at 115200 baud.

If the upload stops at “Connecting…”, hold the BOOT button on the board until the upload starts. If no port appears at all, try a different USB cable — many cables can only charge.