Follow this complete walkthrough to install Wokwi, initialize a PlatformIO project, configure circuit diagrams, link compilation binaries, and run your project seamlessly.
Step 1: Install Wokwi
2. Search for Wokwi Simulator and click Install.
3. Make sure the PlatformIO IDE extension is also installed in your editor.
Step 2: Set Up a PlatformIO Project
Click the PlatformIO icon on the VS Code Activity Bar
Under Quick Access, select Create New Project.
In the Project Wizard dialog, enter the project configurations:
Board:
DOIT ESP32 DEVKIT V1Framework:
ArduinoLocation: Use default location
Name:
Test
Click Finish and wait for PlatformIO to set up the directories.
Step 3: Write Initial Firmware & Compile
- In the VS Code file tree, expand the src folder and click main.cpp.
- Add your ESP32 test code (e.g., an LED blink routine using GPIO 12):
- In the VS Code file tree, expand the src folder and click main.cpp.
- Add your ESP32 test code (e.g., an LED blink routine using GPIO 12):
- Run the Build task by clicking the checkmark build icon located in the bottom status bar.
- Take note of the terminal output confirming successful compilation and displaying the file paths for the generated .bin and .elf files inside .pio/build/esp32doit-devkit-v1/.
Step 4: Request and Activate a Wokwi License
Wokwi requires a generated license token to activate simulation inside the editor:
Press F1 (or Ctrl+Shift+P) to open the Command Palette.
Type and choose Wokwi: Request a New License.
Click Open when prompted to open the external browser link.
On the Wokwi page, click GET YOUR LICENSE.
Authorize the browser to open the link back in VS Code. VS Code will show a confirmation toast: Wokwi: License activated for [your name].
Press F1 (or Ctrl+Shift+P) to open the Command Palette.
Type and choose Wokwi: Request a New License.
Click Open when prompted to open the external browser link.
On the Wokwi page, click GET YOUR LICENSE.
Authorize the browser to open the link back in VS Code. VS Code will show a confirmation toast: Wokwi: License activated for [your name].
Step 5: Create and Configure diagram.json
The circuit schematic in Wokwi is defined using a JSON file called diagram.json placed in the project root.
Right-click in the root explorer pane and choose New File.
Name the file diagram.json.
When clicked initially, the file opens in the interactive Wokwi graphical editor view (which will appear blank).
Right-click on diagram.json in the Explorer list, select Open With..., and choose Text Editor (Default).
Paste your JSON circuit layout defining the ESP32 board, LED, resistor, and pin connections:
Save the file (Ctrl+S / Cmd+S).
Switch back to the Wokwi Diagram Editor tab; the interactive schematic showing the ESP32 connected to the resistor and LED will now load immediately.
Right-click in the root explorer pane and choose New File.
Name the file diagram.json.
When clicked initially, the file opens in the interactive Wokwi graphical editor view (which will appear blank).
Right-click on diagram.json in the Explorer list, select Open With..., and choose Text Editor (Default).
Paste your JSON circuit layout defining the ESP32 board, LED, resistor, and pin connections:
Save the file (Ctrl+S / Cmd+S).
Switch back to the Wokwi Diagram Editor tab; the interactive schematic showing the ESP32 connected to the resistor and LED will now load immediately.
Step 6: Create and Configure wokwi.toml
Wokwi requires a configuration file named wokwi.toml in the project root to map your circuit diagram to the compiled binary files produced by PlatformIO.
Right-click in the root explorer pane and choose New File.
Name the file wokwi.toml.
Open wokwi.toml and paste the following base structure:
[wokwi]
version = 1
firmware = "path-to-your-firmware.bin"
elf = "path-to-your-firmware.elf"
Replace the placeholder paths with the actual output paths generated by PlatformIO during compilation:
[wokwi]
version = 1
firmware = ".pio/build/esp32doit-devkit-v1/firmware.bin"elf = ".pio/build/esp32doit-devkit-v1/firmware.elf"
Save the file (Ctrl+S / Cmd+S).
Right-click in the root explorer pane and choose New File.
Name the file wokwi.toml.
Open wokwi.toml and paste the following base structure:
version = 1
firmware = "path-to-your-firmware.bin"
elf = "path-to-your-firmware.elf"
Replace the placeholder paths with the actual output paths generated by PlatformIO during compilation:
Save the file (Ctrl+S / Cmd+S).
Step 7: Run the Circuit Simulation
Open diagram.json in the editor.
Click the green Start the simulation button located at the top-left corner of the canvas.
The virtual ESP32 boots up and executes your code. You will see the connected red LED blink ON and OFF at 1-second intervals.
Open diagram.json in the editor.
Click the green Start the simulation button located at the top-left corner of the canvas.
The virtual ESP32 boots up and executes your code. You will see the connected red LED blink ON and OFF at 1-second intervals.
Step 8: Adding Serial Communication
You can monitor serial print outputs directly inside the VS Code integrated terminal.
Open src/main.cpp and update the sketch to initialize the serial port and print status messages:
#include <Arduino.h>
#define LED1 12
void setup() {
pinMode(LED1, OUTPUT);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
digitalWrite(LED1, HIGH);
Serial.println("LED ON");
delay(1000);
digitalWrite(LED1, LOW);
Serial.println("LED OFF");
delay(1000);
}
Troubleshooting Tip: Ensure every statement ends with a semicolon ; before compiling. Omitting semicolons will trigger build errors in the PlatformIO console.
Click Build to recompile your modified project.
Return to diagram.json and start the simulation.
Look at the embedded Terminal / Serial Monitor console in VS Code. Alongside the blinking LED, real-time log messages will stream continuously:
LED ON
LED OFF
LED ON
LED OFF
Open src/main.cpp and update the sketch to initialize the serial port and print status messages:
pinMode(LED1, OUTPUT);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
digitalWrite(LED1, HIGH);
Serial.println("LED ON");
delay(1000);
digitalWrite(LED1, LOW);
Serial.println("LED OFF");
delay(1000);
}
Click Build to recompile your modified project.
Return to diagram.json and start the simulation.
Look at the embedded Terminal / Serial Monitor console in VS Code. Alongside the blinking LED, real-time log messages will stream continuously:
LED OFF
LED ON
LED OFF
Recommended project structure
TEST/
├── .pio/
├── .vscode/
├── include/
├── lib/
├── src/
│ └── main.cpp
├── test/
├── diagram.json
├── platformio.ini
└── wokwi.toml
The .pio directory is generated by PlatformIO, while diagram.json and wokwi.toml are the Wokwi-specific files that make the local VS Code simulation possible.
├── .pio/
├── .vscode/
├── include/
├── lib/
├── src/
│ └── main.cpp
├── test/
├── diagram.json
├── platformio.ini
└── wokwi.toml
The complete workflow is
- ·
Install the Wokwi Simulator
extension in VS Code.
- ·
Create or open a PlatformIO
ESP32 project.
- ·
Configure the target board and
Arduino framework in platformio.ini.
- ·
Write the ESP32 application
code in main.cpp.
- ·
Request/activate the Wokwi
license when required.
- ·
Create diagram.json for the
virtual circuit.
- ·
Build the PlatformIO project to
generate firmware.
- ·
Open diagram.json with Wokwi
and start the simulator.
- ·
Verify the simulated LED
behavior.
