Why I built a Raspberry Pi simulator
· Cyber · 1 min read
I'm a backend engineer. I've wanted to go deeper into Raspberry Pi hardware for a long time, but between work and personal life I never had the time, or the budget, to keep buying parts, wiring them up and working out why they didn't behave.
So I built the thing I wanted: a simulator that gets the electrical side right enough that what I learn in it carries over to a real Pi.
What "right enough" means
A lot of simulators treat a pin as on or off. PyRasp solves the circuit instead. Every step runs nodal analysis on a netlist of resistors, sources and diodes, so an LED's brightness comes from the current through it, and a GPIO pin sags when you load it, because it's a source behind about 40 Ω.
That also means you can get things wrong the way you would on a bench. Pull more than 16 mA from a pin and you get a warning; pull more than 50 mA for half a second and the pin is damaged for the rest of the run.
Real Python, real libraries
Your main.py runs in CPython in the browser, with the real gpiozero library. RPi.GPIO, smbus2, spidev and the rest talk to simulated I2C, SPI, UART and 1-Wire buses, so a sensor driver reads registers the way it would on hardware.
What's next
It's a DC solver today: no capacitors or inductors yet. The next big piece is a transient solver, checked against ngspice, so RC timing and the spike a relay coil makes when it switches off can be simulated too.
You can try it without an account. If you've built these circuits on a real Pi and something behaves differently in PyRasp, I'd like to hear about it.