Skip to content

About

Learn electronics on a simulated bench: Arduino, ESP32 and Raspberry Pi Pico projects, a circuit designer and a code editor.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Circuit Lab

Try it in the browser: https://circuitlab.dhivalabs.com

Learn and design electronics in one app: guided labs, a library of ready-made projects for the most common boards, a circuit designer, a code editor, and a simulated bench to run it all on. Export the circuit diagram, the build sheet, the parts to order and the code.

Runs on Linux, Windows, the web, Android and iOS from one Flutter codebase.

Boards

Board Simulated Notes
Arduino Uno R3, Nano, Mega 2560 yes 5 V, 10-bit analog, PWM only on the ~ pins
ESP32-S3 DevKitC-1 yes built-in RGB LED, the guided course uses this one
ESP32 DevKit V1 yes input-only pins 34 to 39, boot pins flagged
NodeMCU (ESP8266) yes D0..D8 names, one analog input, active-low LED
Raspberry Pi Pico yes 3 analog pins, PWM everywhere
Raspberry Pi 4 / 5 no design and export only, with a gpiozero Python starter

Each board has its own 3D model you can turn, with a six-stop tour of its parts (lib/ui/board3d.dart), its real header layout, a tappable pin map, and its own rules in the simulator (lib/data/boards.dart, BoardSpec in lib/sim/board.dart).

What is in it

  • Home and course: pick your board and the whole first page follows it: a guided course (ten lessons where the board allows, from "Hello, serial" to a traffic light), the bench picker, and a tour of that board.
  • Projects: 88 ready-made projects in ten groups (basics, lights, input, sound, sensors, home, garden, motion, games, control). Each one is wired onto whichever board you pick, using pins that suit that board (lib/data/library.dart, library_more.dart, library_sensors.dart).
  • Circuit designer: press Customize on any project, or start a blank one. Twenty-one kinds of part: LEDs, buttons, knobs, buzzers, slide switches, relays, servos, DC motors and a laser module; light, temperature, distance, motion (PIR), touch, tilt, door (reed), IR obstacle, soil moisture, water level, gas and sound sensors. Assign pins from a list or by tapping the pin map; get warnings for boot pins, input-only pins, missing PWM or analog, and clashes; move the design to another board; generate a starter sketch from the circuit.
  • Workspace: live pin map, guide or designer, editor, and a breadboard preview where LEDs glow, servos and motors turn, relays click and you work the buttons, switches and sensors, with a timestamped serial monitor.
  • Export (per project): the program (.ino / .py), a circuit diagram (.svg), a build sheet with wiring, parts and code (.md), the parts to order (.csv), and a project file (.json) that Import reads back.
  • Deploy: the Deploy button in the workspace compiles the sketch in the editor for the real chip and uploads it to the board plugged into the computer. See "Deploy to a board" below.
  • Datasheet: every board in plain words, with the rules that save it.
  • Parts: tick what you own, pick what you want to build, download the rest with what to look for, a price range, alternatives and suggestions. It points out when a starter kit or a cheaper board would cost less.
  • Settings: light or dark colours (or follow the device), text size, your board, your currency and exchange rate, and your own price for any part (the pencil on the Parts page). The app does not fetch exchange rates.

All illustrations (part icons, pin maps, 3D board, breadboard) are drawn in code; there are no image assets.

What the simulator is and is not

It interprets a subset of Arduino C++ (lib/sim/): variables, arrays, functions, if/for/while/switch, enums, String, Serial, GPIO, PWM, ADC, tone, pulseIn, Servo, millis/delay. It teaches a few things a real board would punish silently: a missing pinMode, a floating input, an out-of-range array index, a pin that does not exist, analogWrite on a pin without PWM, output on an input-only pin.

It does not emulate the chips. Structs, classes, pointers, Wi-Fi, Bluetooth, I2C/SPI devices and other libraries are not supported, the buzzer is shown, not played, and a Raspberry Pi 4/5 (Linux, Python) is not simulated at all. Deploy (below) compiles the same sketch with the real toolchain and uploads it. The library projects are written against the standard Arduino API but have only been run in this simulator, not compiled for each real board.

Prices in the parts catalogue (lib/data/parts.dart) are rough USD ranges for budgeting, not quotes.

Run and build

flutter run -d linux        # or: -d chrome, -d windows, -d <phone>
flutter test
flutter test --platform chrome test/sim_test.dart   # same rules in JavaScript

flutter build linux --release
flutter build web --release
flutter build apk --release
flutter build windows --release    # on a Windows machine

Windows and iOS builds need their own host OS. .github/workflows/build.yml builds Linux, web, Android and Windows on GitHub runners.

Deploy to a board

Deploy runs arduino-cli. Nobody has to install it by hand: when it is missing, the Deploy dialog offers Install the add-on, which downloads it from Arduino into the app's own folder (~/.local/share/circuit_lab/addons on Linux, %LOCALAPPDATA%\circuit_lab\addons on Windows). The app looks for the tool in this order: CIRCUIT_LAB_ARDUINO_CLI, an addons/ folder beside the app's executable, the downloaded add-on, then the PATH. To ship a package that deploys with no setup at all, put arduino-cli in addons/ inside the bundle.

The first deploy to a new kind of board downloads its compiler (large for the ESP32); libraries a sketch includes (Servo, ESP32Servo) are installed when missing. On Linux your user needs access to the serial port (sudo usermod -aG dialout $USER, then log in again); the dialog says so when it applies. The dialog also carries the steps for connecting each board, and for a Raspberry Pi 4/5 a walkthrough for copying the script over and running it.

  • Linux and Windows app: works as it is.
  • Web build: a page cannot compile or flash by itself. Serve it with dart run tool/serve.dart (instead of tool/serve_web.py) and open the address it prints; the page asks that local server to run arduino-cli. The server listens on 127.0.0.1 only and refuses requests from other sites.
  • Phones, and a web build hosted elsewhere: no deploy; export the program.

A Raspberry Pi 4/5 is not flashed: export the Python script and run it there. A Pico with nothing on it yet has no serial port: hold BOOTSEL while plugging it in and choose "No port".

Layout

lib/
  sim/        lexer + parser, interpreter, virtual board, real-time runner
  data/       boards, labs, project library, design rules, code generator,
              parts catalogue, shopping list, exports
  deploy/     board targets, the arduino-cli driver, and its desktop and
              browser front ends
  ui/         home, projects, workspace (pin map + guide/designer + editor +
              bench), datasheet, parts
  util/       save a file: browser download, desktop dialog or share sheet
tool/         serve.dart: the web build plus deploy on this machine
test/         simulator, every library project on every board, design rules,
              exports, shopping list and screen flows

Look

Two themes share one idea (lib/ui/theme.dart): the dark one is a blueprint (Prussian-blue sheet, white linework, yellow pencil for mark-ups) and the light one is the drawing it was printed from (cool drafting film, blue-black ink, burnt-orange pencil). Colours are read from the current Palette, never written into a screen. The colours of drawn parts and boards are those of the real objects and do not change with the theme.

Licence

Circuit Lab is released under the MIT licence.

It bundles two typefaces under their own licences: Barlow and Barlow Condensed for text and headings (SIL Open Font License 1.1, assets/fonts/Barlow-OFL.txt) and DejaVu Sans Mono for code (Bitstream Vera licence, assets/fonts/DejaVu-LICENSE.txt).

The deploy add-on, arduino-cli, is not part of this repository or of the packages built from it. The app downloads it from Arduino when the user asks, and it is licensed by Arduino under GPL 3.0.

About

Learn electronics on a simulated bench: Arduino, ESP32 and Raspberry Pi Pico projects, a circuit designer and a code editor.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages