DEV Community

CitronBrick
CitronBrick

Posted on

Run Arduino locally

Wokwi is a platform that helps you design and run Ardunio in the cloud (free for Open Source projects).

To run it locally, the following steps can be used :

  1. Install VSCode
  2. Ctrl Shift X
  3. Install the Wokwi Simulator extension
  4. Ctrl Shift P
  5. Wokwi: Request a New License
  6. Install the Wokwi license (free for trial period)
  7. Install the Arduino CLI
  8. Install the Arduino model (Arduino UNO in my case): arduino-cli.exe core install arduino:avr
  9. If needed, rename the .ino file (eg: sketch.ino ) to foldername.ino
  10. Install additional needed libraries. Eg for Servo : arduino-cli.exe lib install servo
  11. Compile the local project : arduino-cli.exe compile -e --fqbn arduino:avr:uno
  12. Compiling generates a build folder containing.
    • arduino.avr.uno
      • .ino.eep
      • .ino.elf
      • .ino.hex
      • .ino.with_bootloader.bin
      • .ino.with_bootloader.hex
  13. Create wokwi.toml file with the following content

    [wokwi]
    version=1
    firmware='build/arduino.avr.uno/<projectname>.ino.hex'
    
  14. firmware must have the local path to the .ino.hex file. Use forward slashes even for Windows.

  15. Open the local project in VSCode as a folder, if you haven't already

  16. Ctrl Shift P

  17. Wokwi: Start Simulator

  18. After each change to the .ino (C++ code), it's enough to recomplile.

  19. The simulator will reflect the changes, without being restarted.

Top comments (1)

Collapse
 
raknaos profile image
Raknaos

Two things that bit me after following a walkthrough exactly like this one. The filename rule β€” the .ino has to match its parent folder β€” is the one everyone hits, because VSCode is happy and the compile is not, and the error never points at the folder name. And forward slashes in wokwi.toml even on Windows: backslashes parse and then resolve to nothing.

What I would add for the next reader: build to a fixed output directory instead of whatever arduino-cli prints under build/. My first setup pointed firmware at a path that still existed from the previous run, so the simulator kept running the old hex and every recompile looked like it had no effect. The recompile-and-reload loop is otherwise genuinely the part that makes this worth setting up locally.