When I listened to The Amp Hour, episode #599,
I was astonished by the project and its creator, Uri. He built a simulator for all kinds of MCUs
and electronic parts. This project is so cutting-edge that I cannot
believe only one young guy was able to create it. And because it is useful and fun, I invite
you to follow me. Grüezi YouTubers. Here is the guy with the Swiss accent. With a new episode and fresh ideas around
sensors and microcontrollers. Remember: If you subscribe, you will always
sit in the first row. We all know the LTspice simulator for electronic
circuits. It is convenient because we can check circuits
without buying all the components and without soldering. And we can iterate fast because changes are
quickly done. Much quicker than with soldering, for sure! And because LTspice has built-in instruments,
we have a full-fledged lab with oscilloscopes and spectrum analyzers without breaking our
account. Very useful! What if I would promise you a similar simulator
for our beloved Arduinos? That would be nice. And if it would include the ATTiny85? That would certainly add some value because
for programming, the ATTiny has to be removed from the target circuit. But still, not really useful for most of us. And if it would be able to simulate the Pi
Pico? Would this be a deal? No, not for me because most of my projects
use Wi-Fi and the internet. When I heard that this simulator also emulates
the ESP32, including Wi-Fi, I was thrilled. How was he able to simulate Wi-Fi? Without any hardware? Is this true? Let’s check it out. But wait: I did not tell you yet what the
project is called. Its name is Wokwi, and it runs in your browser. To check the internet connection, we look
at a ready-made project: A bitcoin price tracker. To get the actual Bitcoin price, we have to
be able to connect to the internet. And to display it, we have to be able to simulate
a display—two crucial facts for our projects. So, let's look at how it works. We open the project and get three areas: The
sketch, the diagram, and the serial console on one screen. The diagram comprises an ESP32 development
board and a standard small OLED display connected with the usual four wires. The code is the same as for a normal ESP32. It connects to Wi-Fi and then to coindesk.com
to get a JSON file with the price. We need the usual libraries like wire, Wi-Fi,
HTTPclient, and ArduinoJson for this task. But what about the network to get to coindesk.com? The SSID is “Wokwi-GUEST” without a password. Not precisely the credentials of my private
Wi-Fi. Anyway, let’s check what happens. Really, the ESP32 connects to Wi-Fi and displays
the actual Bitcoin price. The simulation works without problems. Cool! Let’s check if this simulator can save our
hard-earned money. We all know what happens if we swap VCC and
ground on an OLED display: We kill it immediately. So, let's check it here. The display still works! Interesting. Even if I delete the power cables, the display
still works. Nothing was destroyed, but it is also not
as it should be. Maybe Uri wants to declutter the diagrams
with this feature because all chips have to be connected to VCC and GND. If I swap SCL and SDA, the display does not
work anymore, BTW. You also see that drawing and adjusting a
schematic is easy. Let’s insert a new text into the display. When we hit “start”, it automatically
starts compilation, and we have to wait a few seconds till the changed sketch displays
the new line. As usual, the compilation time depends on
the size of the sketch and libraries. If we are interested in checking the I2C signal
in reality, we would need an oscilloscope or, better, a logic analyzer. Here, we can add a simulated logic analyzer
and connect SCL and SDA. It starts to sample the signals when we start
the sketch. If finished, we can analyze the signals using
Pulseview, a free logic analyzer software. It's not real-time, but it's still much better
than nothing. Let’s search for a little more complex project. Here is “Simon Says”, a game that runs
on an ESP32-S3. Yes, it also simulates the -S3. The game plays sounds, and your score increases
if you repeat them correctly. Let’s play with it. Yes, the buttons and the LEDs work. And the loudspeaker plays the sounds in real
time. Incredible! I suggest listening to his interview if you
are interested in how Uri does that simulation of all the machine code instructions in real-time. Then, you also learn how he “hijacked”
your PC’s Wi-Fi for Wokwi. This project not only needs an ESP32-S3 and
LEDs; it also needs 74HC585 ICs and 7-segment displays. What else can it simulate? If we press the plus sign, we see the list. It is suitable for many projects and for sure
for playing around. What if my preferred sensor is not here? Just include a function in your sketch to
read the sensor as a “prototype” that emulates the behavior of the sensor with a
few statements. You can still simulate the rest and add the
sensor code later in the Arduino IDE. The documentation is good, but it is not needed
a lot because most things are easy for people using the Arduino. If you encounter severe problems, there is
an active Discord channel where you can get help. And there, you find such projects: This guy
put much effort into his diagram and sketch! Do you want to give him a hand by shortening
his setup()? But also, with his long code, everything works
as designed. And we should not forget to try this sketch:
The joke generator. I would not say every joke is good. But what about this one? Or that one? In any case, we see that Wokwi can simulate
bigger screens. Maybe you can help this guy format the text
so it does not randomly hyphenate words? Up till now, everything is free of charge. If we want more, we can join the Wokwi club. You have to join the club if you wish for
private projects and, more importantly, a private Wi-Fi gateway that enables connections
to servers on your private network, not just the internet. If you are in the club, you can also vote
for which functionality should be programmed next. A very customer-driven strategy! So, let’s quickly check out the private
gateway. We have to download an exe file and trust
the programmer. As a simple example, I use the basic sketch
from the PubSub library and connect the project to my private MQTT server. We do not need to enter our Wi-Fi credentials. Wokwi-GUEST also works here because my PC
is already connected to my home network. I use the extremely useful MQTT Explorer to
check the result. Really, the simulator connects to my Mosquitto
server, and the messages come through. If you do not like the Arduino-style user
interface, you can use Visual Studio Code and even debug your sketch there. I did not try it. Maybe you can comment if you use it? If you want to try Micropython or Circuitpython,
you can use it, too. And what about the supported processors? Even the new Risc-V ESP32s are supported. They are still under development, but we see
the direction of the journey. The Pi Pico and some STM32 boards are supported,
too. As I said before, I like the Attinys. But they are not easy to handle because you
must take them out of the circuit for programming. And debugging is a nightmare because Serial.print()
is unavailable. This is why I want to try a blink sketch on
Wokwi and then copy-paste the code into the Arduino IDE to program a real Attiny85. Here is the example. The LED is connected via a resistor to VCC
and to pin PB4—no need to consult the datasheet. Wokwi knows where the pins are. It even shows you the correct color rings
on the resistor. And our Blink sketch works. BTW: Here, we see a big difference between
Wokwi and LTspice: If we change the value of the resistor to 330 Mega Ohms, the LED
still blinks. We all know this is not the case in reality
because the current would be too small. But what about debugging? Did I promise too much? No, we can debug the ATtiny85. Incredible! If we start debugging, we can set breakpoints
and use single step. As usual. That is really cool, particularly if you have
complex programs like this one. Look at the dimming of the LEDs, BTW. According to Uri, this was hard to achieve. I programmed a real Attiny with my simple
program, and it works. Not a real surprise with this short code. But you see the point. This was all for today. As always, you find all the relevant links
in the description. I hope this video was useful or at least interesting
for you. If true, please consider supporting the channel
to secure its future existence. Thank you! Bye