There is something that’s been seriously bothering me ever since I started to work with embedded devices: trying out new things when you don’t have an actual device at hand is hard!
Over the years, I’ve had the following happen more often than I care to admit:
💡 Hear about an interesting embedded tool or library ;
🧑💻 Check out the provided code samples ;
😔 Realize none work with any combination of the—dozens!—embedded boards and sensors I own ;
🚶♂️ Give up…
With the ongoing global chip shortage, the problem is just so much worse these days. Even if I were to go through the hassle of ordering the required hardware, I would have to face incredibly long lead times—sometimes well over a year!
Luckily, there has been a lot of innovation around making it easier to simulate embedded hardware over the past years, and I have found myself using the following tools on a regular basis.
For each, I will (briefly) explain what they do, what I like about them, and I will include a link to a quick demo for you to realize first-hand how much time they can save you!
Renode
Renode is an open-source framework that allows you to run, debug and test unmodified embedded software right from your PC.
Out of the box, Renode supports a wide variety of embedded boards and peripherals, with more being added regularly. If the board or peripheral you need is not in the list, there is a good chance they can be added with minimal work. Renode has a really elegant and extensible mechanism to describe platforms, as well as to model peripherals.
I am using Renode to drastically simplify and speed up my “inner dev loop” when I build Azure RTOS applications. It can emulate pretty complex peripherals such as LCD touchscreens, which means I can even test my GUIX applications!
I have assembled in the GitHub repository below some examples of Azure RTOS applications running on Renode, including an example showing how to use the testing framework mentioned above.
There is a lot more that can be done with Renode (multi-node simulation, networking, …) so I will probably write some more about it in the future.
Wokwi
It is becoming increasingly common to develop right from a web browser. While it is a significant paradigm shift for long-time embedded developers, it also brings tons of benefits and makes it much easier to setup reproducible (and versioned!) development environments and toolchains. In fact, I already spoke about this a while ago in this video 😊.
Wokwiis a web-based hardware simulation environment that can be used to simulate a wide variety of micro-controllers (Arduino Uno, ESP32, Raspberry Pi Pico, …) , electronic parts, sensors, and actuators.
At first sight, Wokwi feels like a tool that is only targeting “hobbyists”, but it is in fact really powerful and so much more than a toy (for example, it too does come with debugging support)! It comes with an online web IDE that resembles the Arduino IDE, but you can also bring your pre-compiled ELF binary if you want to keep using your usual development environment.
Beyond the fact that Wokwi “just works” and the fact that sharing a project with someone is as simple as giving them the URL to access it (!), I really love the following Wokwi features:
Logic analyzer for capturing/debugging the various signals in your system (ex. I2C or SPI traffic)
Network traffic capture for analyzing Wi-Fi traffic in Wireshark. You can e.g. troubleshoot the connection to your IoT cloud, something that’s pretty cumbersome or even impossible to do when running on “real” hardware.
When you use Wokwi to simulate an ESP32 application, you can actually connect to a Wi-Fi, right from within the simulation. Your application may simply connect to the simulated “Wokwi-GUEST” WLAN to access the Internet. Pretty convenient for simulating your next IoT project, eh?
As a way to show you how much easier things are when you don’t have to worry about the hardware, you may check out this Wokwi project.
Create an Azure IoT Central Application, if need, and provision a new device, as per the sample’s instructions.
Enter your Azure IoT Central and device information into the sample’s iot_configs.h.
Run the simulation! The application will automatically get compiled by Wokwi, and then run within your browser.
As the application starts, the simulated device will attach to the—simulated—wireless network, and will show up shortly thereafter in Azure IoT Central.
You will be able to interact with the LEDs or the LCD display by sending commands from Azure IoT Central, as well as see the telemetry corresponding to the various sensors (you can control what “fake” temperature, acceleration data, etc. the sensors are reporting by clicking on them in the Web interface.
TinkerCAD
I discovered TinkerCAD‘s circuit simulation capabilities only recently. Compared to Renode and Wokwi, TinkerCAD will get you the closest to the “metal”. It helps validate the circuit down to making sure you have the wiring 100% correct, and do not risk frying a component due to a missing resistor!
TinkerCAD lets you simulate Arduino UNO and micro:bit-based circuits, but I must admit that I haven’t spent a lot of time using it for actual projects just yet. The fact that it doesn’t allow to simulate network communications makes it a bit impractical for IoT scenarios anyway. However, there are some great projects in the online gallery that should give you a sense of what the tool is capable of.
I highly recommend you give these amazing (and did I mention free?) tools a try.
You should be able to get all the examples I shared up and running in no time, which I hope is making my point regarding how much of a time-saver they can be.
I would also love to hear about other simulation/emulations tools out there that you may be using to speed up your embedded & IoT development workflow—just let me know in the comments!