Skip to content

Instantly share code, notes, and snippets.

@atomicparade
Last active July 31, 2025 11:10
Show Gist options
  • Save atomicparade/d0f93b84d00b6fedfc58df4f78957071 to your computer and use it in GitHub Desktop.
Save atomicparade/d0f93b84d00b6fedfc58df4f78957071 to your computer and use it in GitHub Desktop.
Using the Wokwi simulator in Visual Studio Code

Using the Wokwi simulator in Visual Studio Code

You can develop for ESP32 devices using only a computer using Wokwi. You can use Wokwi directly in your web browser, though you can only save files publicly and compilation may fail if the Wokwi servers are busy.

This guide will show how to create a new PlatformIO ESP32 project and and run it on your computer with Wokwi.

Installing Visual Studio Code, PlatformIO, and Wokwi

Installing Visual Studio Code

Download and install Visual Studio Code.

Installing PlatformIO

  1. In Visual Studio Code, open the Extensions pane.

  2. Search for platformio.

  3. Install the PlatformIO IDE.

    bd12d17f-73fb-42fe-99dd-ee7c546fc20c

Installing and activating Wokwi

  1. In Visual Studio Code, open the Extensions pane.

  2. Search for wokwi.

  3. Install the Wokwi Simulator.

    714914cd-bed8-478f-bacc-6d23b2bd80cf

  4. Press Ctrl+Shift+P to open the Command Palette. In the Command Palette, type wokwi. (Do not press Enter.)

  5. Select Wokwi: Request a New License.

    39c98a19-c746-4de3-946f-0dd724cd6dc7

  6. Click Open.

    49ede691-49c3-49e5-81a0-f22984ac18f8

  7. Click Get Your License.

    c952d797-ff2e-4c9d-85bf-bac5e0ae1f08

  8. Copy the license key.

    3cba2144-5e6f-4e8d-b338-b7c416c429cb

  9. Press Ctrl+Shift+P to open the Command Palette. In the Command Palette, type wokwi. (Do not press Enter.)

  10. Select Wokwi: Manually Enter License Key.

    d573598f-88f8-4653-b639-3420290acb70

  11. Paste the license key in and press Enter.

    ec50f0fa-1215-4819-8e5c-910dc0cccc0d

Creating a new PlatformIO ESP32 project and running it with Wokwi

Creating a new Wokwi diagram

  1. Open the Wokwi website at https://wokwi.com/.

  2. Click the ESP32 tile.

    66fca762-3a5f-4b6e-b6b0-8d2d93302f06

  3. Scroll down to Starter Templates and select the first ESP32 tile.

    fab1473d-1d68-4a75-b914-5cb2ca15a526

  4. Use the Wokwi diagram editor to add and wire up new components.

    For more information about creating Wokwi diagrams, see the Interactive Diagram Editor page in the Wokwi documentation.

    50662d57-86d2-4280-9e65-940035fc20d4

    817da694-9b3a-4092-b102-408070a101bf

  5. Once you've created a diagram, select the diagram.json tab. We will return here once we've created the PlatformIO project.

    image

Creating a new PlatformIO project in Visual Studio Code

  1. In Visual Studio Code, open the Explorer pane.

  2. Click Open Folder.

    ee4e5556-7651-4ef3-92e7-ee01e0f1f8ec

  3. Navigate to where you want to store the project files and then create a new folder for your project or select an existing folder.

  4. Click Add.

    f63cdedb-78e2-40a0-ba4e-20ef5c00c3aa

    You might receive a warning when you select the folder. If you do, click Yes to continue.

    aeabbd33-6551-42ac-b905-9088070d9ca3

  5. Click the New File button.

    3e44ebba-726c-4366-9793-4ce99cea58e9

  6. Name the new file platformio.ini.

    ac82c7bc-4aac-44f5-9fe1-41237277d79a

  7. Copy and paste the following configuration into platformio.ini. Then save the file.

    Additional information about PlatformIO configuration is available in the PlatformIO documentation (Project Configuration File, ESP32 Dev Module).

    [env:esp32dev]
    platform = espressif32
    framework = arduino
    board = esp32dev
    

    eec78582-efde-4df3-9b26-6033f35aa9f1

  8. In the Explorer pane, click the New File button.

  9. Name the new file wokwi.toml.

    ef03887c-2e60-4c38-8c73-f4556522b438

  10. Copy and paste the following Wokwi configuration into the file. Then save the file.

    This will tell Wokwi where to find the code compiled by PlatformIO.

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

    836af8fe-06d6-454f-ab20-851d5612a5f1

Adding the Wokwi diagram

  1. In the Explorer pane, click the New File button.

  2. Name the new file diagram.json.

    e69ec731-3e2f-4a10-8085-6701ac5cfd10

  3. Visual Studio Code will open diagram.json in the Wokwi editor. However, while you will not be able to use the editor in Visual Studio Code without a paid license, you can copy and paste in diagrams created using the online Wokwi editor.

    Right-click the diagram.json tab.

  4. Select Reopen Editor With....

    5056991c-448f-4220-91fe-c8ee22074a58

  5. Select Text Editor.

    4270078a-a5da-4d95-bd2a-4279f1771716

  6. Copy and paste the contents of diagram.json in the online Wokwi editor to diagram.json in Visual Studio Code. Then save the file.

    921786bb-3a1c-43ad-a4be-bf215a616031

Adding the program code

  1. In the Explore pane, click the New Folder button.

    180259ff-bb3d-45ec-9d50-9737533a8ca0

  2. Name the new folder src.

    f14d3e36-1eb5-4340-9d95-3c96aaaf714b

  3. In the src folder, create a new file with a name of your choice, with the file extension ino.

    46dc747e-9dac-4432-aaff-1d2045528668

  4. Add your program code to the rainbow_led_strip.ino file. Then save the file.

    bccc15a4-e438-478d-943f-41cf2485c4d5

Building and running the program

  1. Press Ctrl+Shift+P to open the Command Palette. In the Command Palette, type platformio. (Do not press Enter.)

  2. Select PlatformIO: Open PlatformIO Core CLI.

    679cf641-491a-4335-ab53-7fee27ade667

  3. A terminal window will appear at the bottom of the window. Type pio run and press Enter.

    17e9e7e9-a3e4-4443-ac49-78471707e44c

    0d74cb68-d9f9-43f3-aa94-5bc045d61e85

  4. Press Ctrl+Shift+P to open the Command Palette. In the Command Palette, type wokwi. (Do not press Enter.)

  5. Select Wokwi: Start Simulator.

    f8cfe1d1-60a7-470e-b1bf-dc2ec2c7adfb

    The Wokwi simulator should show the diagram. Serial output will be displayed at the bottom of the window.

    da4c7dbd-59e3-4343-a1d7-dfdaca86550c

Optional: Installing libraries

If you would like to use libraries, you will need to install them using PlatformIO.

  1. Press Ctrl+Shift+P to open the Command Palette. In the Command Palette, type platformio. (Do not press Enter.)

  2. Select PlatformIO: PlatformIO Home.

    5d806a79-7d0d-426d-85ca-ef4546056004

  3. Within the PlatformIO homepage, open the Libraries pane.

  4. Enter the name of the library you want to install and press Enter.

  5. Click on the library you want to install.

    7ca708c3-6937-47fb-98ec-5d3fc9cdbabc

  6. Click Add to Project.

    36362302-f7fa-4ef9-99d0-5173fedae9cb

  7. In the project dropdown menu, select the folder for the current project.

  8. Click Add.

    fdd5d2be-bb1c-4fa1-9723-ae4f54f30f43

    You can now use the installed library.

    aded9056-ac24-4efd-b4f1-254855a9b60c

Additional tips

Setting up a keyboard shortcut to run the Wokwi simulator

  1. Press Ctrl+Shift+P to open the Command Palette. In the Command Palette, type wokwi. (Do not press Enter.)

  2. Click the gear icon in the Wokwwi: Start Simulator entry.

    625e6631-0dd4-439e-aba1-46ca2de99ecb

  3. Click the pencil icon next to Wokwi: Start Simulator.

    5d502b3e-8be6-4e69-96e8-e90e09079c96

  4. Press the keyboard shortcut you want to use to start the Wokwi Simulator. Then press Enter.

    00f72de1-ecc7-4248-b0cb-9e06576ae684

Viewing both the source code and simulator simultaneously

You can click and drag the Wokwi Simulator tab to view your code and the simulator side-by-side.

3f6738d5-19a9-4b78-979e-3d8a1a398847

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment