Learn

Simulate an ESP32 and an Arduino Uno talking over serial

Intermediate

Or see every lesson.

  • 261parts on the bench
  • 31boards running now
  • 1.00xreal time, on every board
An ESP32 sends a knob to an Unolive0.000 s 0.00x
Click to open it in the editor
Turn the knob on the ESP32 side and watch the Uno’s LED follow it. The serial monitor shows what was sent and what arrived.

An ESP32 beside an Arduino Uno is a common pairing. The ESP32 brings a fast processor, a 12-bit ADC and a radio; the Uno brings 5 V pins, a huge number of tutorials and shields, and the code a project already has. Joining them with a serial wire lets each do what it is good at. This project runs both boards at once, in one browser tab, each with its own sketch.

On the left is an ESP32 DevKit with a potentiometer on GPIO 34. Its sketch reads the knob with analogRead, which counts from 0 to 4095 on the ESP32, and sends the reading as a line of text, "knob 2048", four times a second on GPIO 4. On the right is an Uno listening on pin 2. Its sketch reads each line, maps 0 to 4095 onto 0 to 255, and writes that to an LED on PWM pin 9. Turn the knob and the LED dims and brightens.

Both sketches use SoftwareSerial at 9600 baud. The two boards share a ground, which is what lets a voltage on one mean the same thing on the other.

The link only goes one way, and that is on purpose. The ESP32 drives its pins to 3.3 V, which the Uno reads as HIGH, since its threshold sits well under that. The Uno drives 5 V, and a real ESP32 pin is not rated for 5 V. A link back from the Uno would need a resistor divider or a level shifter on that wire, and on a real bench forgetting that is how ESP32 pins die. The simulation will not burn a pin for you, so this page says it instead.

Each board compiles in your own browser: the Uno with clang for AVR and the ESP32 with clang for Xtensa, the ESP32’s core. There is no build server and no queue. The first build in a fresh browser downloads the compiler once; after that a change to either sketch builds in seconds.

Things to try: print the reading on the ESP32 side as volts, send a second value on the same line and split it on the Uno, or add a divider and send an answer back the safe way.

Questions

Can I simulate an ESP32 and an Arduino in the same circuit?

Yes. Put both boards on the canvas, give each its own sketch, and wire their pins together. The simulation runs both at once, each at its own clock, and the serial monitor labels every line with the board it came from.

Is it safe to connect an Uno pin straight to an ESP32 pin?

From the ESP32 to the Uno, yes: 3.3 V reads as HIGH on a 5 V Uno. From the Uno to the ESP32, no: a real ESP32 pin is not rated for 5 V, so that direction needs a divider or a level shifter.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.