Popup

Wait! Don’t Go Yet! 👋

Become a Member Today and Unlock Access to All eBooks! 😍

Thousands of eBooks at your fingertips. Read, learn, and grow anytime, anywhere ✨

Wokwi in VS Code: How To Simulate ESP32 Projects in VS Code!

Don’t have any hardware at hand? Not a problem with Wokwi for VS Code!
In this guide, I’ll show you how to install the Wokwi extension in Visual Studio Code, allowing you to simulate ESP32 projects without requiring any physical hardware.

This is useful for tinkering around or when you don’t have access to a real ESP32 and the components at the moment.

What is Wokwi?

Wokwi is a free online simulator that supports a wide range of microcontrollers, including the ESP32. It lets you build virtual circuits with components like LEDs, buttons, sensors, motors, and a lot more.

What is Wokwi

Most developers probably know the Wokwi editor in the browser, which is available at wokwi.com. However, there’s also a Visual Studio Code extension that lets you make use of the Wokwi simulation software directly inside your favorite code editor/IDE.

Key Features of Wokwi

  • Supports ESP32, ESP8266, Arduino (Uno, Mega, Nano), Raspberry Pi Pico
  • Easy-to-use drag-and-drop interface
  • Real-time simulation
  • Many electronic components
  • Runs in the browser while offering VS Code integration
  • Huge project library

Step 1: Install Visual Studio Code & PlatformIO

Top 6

ESP32 eBooks

From Zero to Professional

ESP32 Projects

If you haven’t installed VS Code yet, that’s the first step. The process is straightforward: simply visit the official download page, select the version compatible with your operating system, run the installer, and follow the instructions. It’s quick and straightforward, so I’ll assume you don’t need any more help with that.

Inside VS Code, you’ll need to install the PlatformIO extension to be able to write and compile code for your ESP32. Check out this post for a detailed PlatformIO setup guide.

Step 2: Install the Wokwi Extension

Let’s install the Wokwi VS Code extension.
To do so, simply head to the extensions tab (4 blocks) on the left of your VS Code window, search for “Wokwi Simulator” and install the extension.

vs code wokwi install

When you are asked whether to trust the publisher of the extension, confirm and install the extension. This is just a security check from VS Code, as some extensions might be malicious. However, that’s not the case for the Wokwi extension – it’s safe to install.

Step 3: Request a Wokwi License

In order to be able to use Wokwi within Visual Studio Code, we need to request a license.

The license is completely free for personal use and is valid for 30 days. After 30 days, you can always request a new license.

To get your free personal license, open the search bar at the top of your VS Code window (or press F1) and type “>wokwi“. Then, select “Wokwi: Request a New License“.

request wokwi license

When you are asked whether to open the external website, hit open.
This will take you to Wokwi’s website, where you can get a license.

GET YOUR LICENSE

After clicking on “GET YOUR LICENSE”, the browser should take you to VS Code again, where you have to confirm to open the URI. This will automatically update your license.

Step 4: Create a New ESP32 Simulation Project

Top 6

Arduino eBooks

From Zero to Professional

Arduino Projects

Inside Visual Studio Code, open or create a PlatformIO project where your code and Wokwi setup will go.

Next, create a new file inside your project’s root folder called “wokwi.toml“. Inside that file, we specify where Wokwi can find the build files. Also, if you plan to create a web server on your ESP32, we can make it accessible from localhost.

[wokwi]
version = 1
elf = ".pio/build/esp32/firmware.elf"
firmware = ".pio/build/esp32/firmware.bin"

# If you want to access your ESP32's web server
[[net.forward]]
from = "localhost:8100"
to = "target:80"

Make sure the paths to the elf and bin files are correct, as they may vary!

wokwi project setup

Create a Wokwi Circuit Diagram

Let’s try to simulate a simple ESP32 blink project.

To be able to run the simulation, we need a circuit diagram, which is defined using a “diagram.json” file. We can’t edit the circuit diagram directly inside VS Code. Instead, head to the online editor, create your circuit, and copy the contents of the diagram.json file there. You can use this sample LED project for testing.

wokwi diagram json

Place the diagram.json file inside your project’s root folder.

When you click on the diagram.json file, VS Code should open the circuit diagram, where you will be able to simulate your project. If you don’t want to open the simulation view but edit the file, right-click on it, select “Open With…“, and choose “Text Editor“.

diagram in vs code

Inside your main.cpp, or wherever your sketch will go, paste this simple blink sketch.

#include <Arduino.h>

#define LED_PIN 27

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(500);
  digitalWrite(LED_PIN, LOW);
  delay(500);
}

Then, build your project with PlatformIO by hitting F1 and typing “PlatformIO: Build“.
You can also hit the build button (check mark) on the very bottom of the VS Code window.

PlatformIO Build

Next, open your circuit diagram and hit the green run button.
If everything works, the simulation should run, and the LED should flash.

LED should flash

Conclusion

Wokwi + VS Code gives you an amazing platform to prototype ESP32 projects without needing real hardware. From blinking LEDs to simulating full IoT circuits, you can save time, avoid wiring mistakes, and experiment freely.
Give it a try with your next project!


Share your experience with Wokwi in VS Code in the comments below!

Thanks for reading, happy making!

Links marked with an asterisk (*) are affiliate links, which means we may receive a commission for purchases made through these links at no extra cost to you. Read more on our Affiliate Disclosure Page.

Share your love

🚀 Discover the world of electronics and innovation!

✨ Create, program, and experiment with all your creative ideas with ease.

Spotpear

Leave a Reply

Your email address will not be published. Required fields are marked *

Secure Payments
Securing online payments is a shared responsibility, and everyone can contribute.
Free Shipping
You get unlimited free shipping on eligible items with Ebokify, with no minimum spend.
24/7 Support
Sales gifts are helpful tools often used to show appreciation to clients for their purchase.
Gifts & Sales
Our customer care service is offered in the form of 1st or 2nd level support.