Innovation Made Easy: 7 Hidden Features to Harness the Power of ESP in Wokwi
Tags: rust, esp32, esp8266, embedded
Published: 2023-07-06 05:22:00

It's no secret that I am a huge fan of Wokwi. I think it's one of the greatest tools introduced in recent times for embedded enthusiasts and learners. This is mainly because it relieves you of the hardware part. Especially if you have difficulty accessing hardware or don't want to splash out the money as a beginner. Other than the part that it's actually a more sustainable alternative. I can only count the number of dev boards that I bought and are sitting around after projects concluded. Wokwi is also rapidly evolving to include even more helpful features, devices, and languages. For more about Wokwi and other hardware-free resources, there's a [past post](https://apollolabsblog.hashnode.dev/embedded-iot-without-hardware-8-must-know-resources) I wrote discussing the pros and cons.

One of the cool things about Wokwi right now is that it supports Rust, particularly for ESP devices. Behind the beginner-friendly looks, there are sort of what I like to call "hidden features" that are not particularly obvious and are really powerful.

Without further ado, here's a list of those features:

#### If you find this post useful, and if Embedded Rust interests you, stay in the know and skyrocket your learning curve by subscribing to The Embedded Rustacean newsletter:

{% cta  http://www.theembeddedrustacean.com %} Subscribe Now to The Embedded Rustacean{% endcta%} 

## 1) Flash Directly From Browser ⚡️

Have you ever tried to press the F1 key in Wokwi? Well, a world of features behind that list pops up. One of them is the ability to directly download a program image to ESP hardware. Meaning if you have a physical device on hand connected to your PC you can flash your device directly from the browser. No IDEs, toolchains, or anything else.

![flash](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozsiz079hnhxmdhf4h0e.gif)

## 2) Pause for Pin Configuration 📌

Not sure if you configured your ESP device pins correctly? In Wokwi, if you pause a live simulation, a label will appear beside each pin showing what the pin configuration is. This is really also useful at times to make sure you connected the pins to the correct circuitry.

![Pin config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xk0r5it3y71isokddo2a.gif)

## 3) Develop Using VSCode 👨‍💻

Do you prefer using VSCode as your editor? Wokwi actually has an extension allowing you to develop directly from VSCode and simulate there as well. Wokwi for VS Code also works with Zehpyr Project, PlatformIO, ESP-IDF, Pi Pico SDK, NuttX, Rust, and Arduino CLI, among others. You can get started by following the instructions [here](https://docs.wokwi.com/vscode/getting-started).

![VScode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk4k0lzbxhvlx7fmoj8i.gif)

## 4) Code Profiling 🏎️

You can actually profile your ESP code using Wokwi. How? You might have guessed, it's an option behind that F1 menu. If you select the profile program option Wokwi will compile and run the simulation.


![Code Profiling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/unk47598167tx8zanmaq.gif)

When you pause (not stop) the simulation a `profile.json` file will be downloaded. After that, you'll need to go to [https://profiler.wokwi.com/](https://profiler.wokwi.com/) and upload the profile file. You'll get something like this showing you how much time was spent in different parts of your code:

![Profiler](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8cye0pn80zydh0l3r68.png)

## 5) Interactive Debug 👾

Behind that F1 menu resides a **"Start Web GDB Session (debug build)"** option. Though there is something cooler, its the built-in [interactive debugger](https://docs.wokwi.com/guides/debugger). Through the interactive debugger, you can step through your code, view your call stack, inspect variables, and even set breakpoints. You can access the debugger by clicking on the three dots in the simulation window:

![Interactive Debug](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pryovovuppx2kg0gf3nb.png)

Currently, only AVR microcontrollers are supported from the web interface. For ESP devices, there is support by using the integrated debugger in Wokwi for VSCode. Here there is an extra step involved where you need first to configure the Wokwi debugger for VSCode, and second, to start the debugger, its back to the F1 menu selecting **"Wokwi: Start Simulator and Wait for Debugger"**.

## 6) Continuous Integration 🔄

Continuous Integration (CI) is a software development practice that aims to enhance the efficiency and reliability of the development process. It involves the frequent integration of code changes from multiple developers into a shared repository, followed by an automated build and testing process. The fundamental principle of CI is to detect and address integration issues as early as possible, ensuring that the software remains in a consistently functional state.

Building and testing your code requires a server. You can build and test updates locally before pushing code to a repository, or you can use a CI server that checks for new code commits in a repository. For that, you can use GitHub Actions workflows to build code in your repository and run your tests. What is really cool is that you can integrate the Wokwi Embedded Systems Simulator in your GitHub actions CI workflow. This would enable you to verify that your code is not broken with every new commit.

[This](https://github.com/wokwi/wokwi-ci-action) is a link to the GitHub action that you can integrate into your workflow. There is also a Wokwi CI ESP32 example [here](https://github.com/wokwi/esp32-hello-wokwi-ci) that shows how to use GitHub Actions to build and test ESP32 projects.

## 7) Packet Tracing 📝

Did you run an ESP32 project that uses the WiFi in the simulator? You can actually view the packet capture of the simulation. Again, behind that F1 menu choose **"Download WiFi Packet Capture (PCAP) file"**. Your browser will download a file called `wokwi.pcap` which you can open with a tool like Wireshark.

![ESPPkt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3aeik8eyj4c1v0xb661i.png)

## Conclusion

Wokwi is an embedded hardware simulator that has been replacing much of the need for physical hardware. Additionally, Wokwi provides integrations for popular development boards including the ESP and languages like Rust. In the realm of Wokwi, there reside many hidden features that might not seem obvious to many with many new emerging.. This post list 7 powerful features that can help one unlock many more possibilities. Have any questions/comments? Share your thoughts in the comments below 👇.

#### If you found this post useful, and if Embedded Rust interests you, stay in the know and skyrocket your learning curve by subscribing to The Embedded Rustacean newsletter:

{% cta  http://www.theembeddedrustacean.com %} Subscribe Now to The Embedded Rustacean{% endcta%}