Source: https://mokxi.com/raspberry-pi-simulator

Simulator

# Free online Raspberry Pi simulator for Python and GPIO

Mokxi is a free Raspberry Pi simulator that runs in your browser, with nothing to install and no account needed. Your main.py runs in a Python engine in this tab, and RPi.GPIO, gpiozero, smbus, smbus2 and spidev drive the 40-pin header of a Raspberry Pi 4, a Pi 5 or a Zero 2 W. It is not an emulator: there is no Linux and no Cortex-A core, only the board’s Python and the circuit it drives.

Written by the Mokxi team

Start building free or see the full Raspberry Pi board page

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The Pi is running its main.py right now, in the Python engine. Click it to open the circuit in the editor.

What is modeled

## The numbers, not the marketing

Taken from the board's own contract document and put in plain words.

What runs | MicroPython v1.29.0 built for WebAssembly, a Python 3 interpreter, with RPi.GPIO 0.7.1 and gpiozero 2.0.1 written for it. Not CPython, not Linux, not an Arm core.

The boards | The Raspberry Pi 4 Model B, the Raspberry Pi 5 and the Raspberry Pi Zero 2 W: all 40 header pins in order, GPIO 0 to 27 at 3.3 V logic, BCM and BOARD numbering.

I2C and SPI | smbus and smbus2 on /dev/i2c-1 at 100 kHz, spidev on /dev/spidev0.0 and 0.1, and gpiozero’s MCP3008 on SPI0, or bit-banged on any other pins.

Time | A simulated clock: time.sleep(1) is one simulated second, and an edge callback runs at the simulated instant of the edge.

Go further

## The full board page

Every peripheral area, every example and the wiring notes, in one place.

Raspberry Pi simulator Every example, the whole header and what is not simulated.

Examples

## Examples that already run

Each one is wired and coded. Open it, press Run, then change the code.

Blink an LED with gpiozero An LED on GPIO17 blinks once a second on a Pi 4. A button toggles an LED gpiozero’s Button with bounce_time, and when_pressed. Servo sweep with RPi.GPIO RPi.GPIO’s 50 Hz software PWM sweeps a servo on GPIO18. HC-SR04 on a Pi 5 gpiozero’s DistanceSensor, with a divider on the echo line. BCM and BOARD numbering RPi.GPIO with header pin numbers, 11 and 13. Blink on a Zero 2 W RPi.GPIO blinks an LED on a Raspberry Pi Zero 2 W. SSD1306 OLED with smbus2 Text drawn on an OLED over I2C bus 1. BME280 with smbus2 Temperature, pressure and humidity on a Zero 2 W. A knob through an MCP3008 gpiozero reads the ADC on SPI0 and dims an LED. PIR motion sensor gpiozero’s MotionSensor lights an LED while something moves. Traffic lights and a button gpiozero’s TrafficLights run a pedestrian crossing. MQ-2 gas sensor An MQ-2 through a divider and an MCP3008, with an alarm LED.

Guides

## Step-by-step guides for the Raspberry Pi

Each one has the parts, the wiring and the code, and ends in a circuit you can run.

- Raspberry Pi GPIO in Python: gpiozero, RPi.GPIO, I2C and SPI

## Questions

Is this a Raspberry Pi emulator?

No. There is no Linux, no Cortex-A core and no SD card image. Your main.py runs in a Python engine in the page, and its libraries drive the header. Everything a circuit can see of a Pi is here; the operating system is not.

Which libraries can I import?

RPi.GPIO, gpiozero, smbus, smbus2 and spidev, and the standard modules a GPIO program reaches for, such as time, math, random and json. picamera2, pigpio, serial, threading and the networking modules are not installed, and importing one raises ImportError.

Does RPi.GPIO work on the Pi 5?

It fails there as it does on a real Pi 5, with "Cannot determine SOC peripheral base address", because the pins are on the RP1 chip. gpiozero works on all three boards.

Can I read an analog sensor?

The Pi has no ADC, so, as on a desk, add an MCP3008 on SPI0 and read it with gpiozero’s MCP3008 class or with spidev. There is a built-in example of exactly that.

Can I use I2C displays and sensors?

Yes, with smbus or smbus2 on bus 1, GPIO 2 and 3. An SSD1306 OLED and a BME280 have built-in examples, and an address nobody answers raises [Errno 121] Remote I/O error, as on a Pi.

Can I pip install a library?

No. Add a library’s .py file as a tab of its own and import it from main.py, which works for libraries written in plain Python.

Will my program run on a real Pi?

Yes, with gpiozero or RPi.GPIO as they ship with Raspberry Pi OS. Timing on a real Pi is looser: software PWM jitters there and does not here.

Is it free?

Yes. Every board and every part is on the free plan, with no account needed. The first Run downloads the Python engine, about 150 KB, and the browser keeps it.

## Simulators for one kind of circuit

A servo, a display, a motor driver or a rectifier, each already running.

Online circuit simulator Breadboard simulator ESP32 simulator Op-amp simulator Logic gate simulator LED circuit simulator Servo simulator LCD simulator OLED simulator NeoPixel simulator 7 segment display simulator LED matrix simulator Stepper motor simulator Motor driver simulator Ultrasonic sensor simulator Rectifier simulator Digital circuit simulator Potentiometer simulator PWM simulator Relay simulator Shift register simulator DHT11 simulator RFID simulator Accelerometer simulator RGB LED simulator Buzzer simulator MOSFET simulator Circuit simulator for kids Flip-flop simulator Multiplexer simulator Full adder simulator I2C simulator UART simulator Thermistor simulator PIR sensor simulator Oscilloscope simulator Multimeter simulator DC motor simulator Traffic light simulator Diode simulator Capacitor simulator Series and parallel circuit simulator Wheatstone bridge simulator Voltage regulator simulator Soil moisture sensor simulator Zener diode simulator Solar panel simulator AC circuit simulator Thevenin simulator Decoder simulator Encoder simulator PID simulator Robot arm simulator Load cell simulator IR sensor simulator LM35 simulator HC-05 Bluetooth simulator nRF24L01 simulator

## Try it with your own Python

Write main.py with gpiozero or RPi.GPIO and press Run. Nothing to install and no account needed.

Start building free Open the editor
