Board

Raspberry Pi simulator for GPIO, in Python with gpiozero

The Raspberry Pi 4 Model B, the Raspberry Pi 5 and the Raspberry Pi Zero 2 W, from their 40-pin header. Your main.py runs in a Python engine in the page, and gpiozero and RPi.GPIO drive the header as they do on a real Pi, on the simulated clock. There is no Linux here, and this page says plainly what that leaves out.

  • 9area periferal dimodelkan
  • 9proyek siap dijalankan
  • Waktu nyatadi mesinmu sendiri
Raspberry Pi 4 Model B: blinklive0.000 s 0.00x
Klik untuk membukanya di editor
The board is running its main.py right now. Click it to open the circuit in the editor.
Raspberry Pi 4 Model B as drawn in the Mokxi simulator
Modelnya

Apa yang dimodelkan

Diambil dari dokumen kontrak board itu sendiri dan ditulis dengan kata-kata sederhana, beserta apa yang belum ada di sampingnya.

Dimodelkan

Header
All 40 pins in their real order, named by BCM number, with BOARD numbering mapped to them
Daya
3V3 on pins 1 and 17, 5V on pins 2 and 4, and the eight grounds
GPIO
GPIO 0 to 27 at 3.3 V logic, as inputs with their 50 k pulls or as outputs, with the SoC’s power-on pulls and the 1.8 k pull-ups on GPIO 2 and 3
gpiozero 2.0.1
LED, PWMLED, RGBLED, Button, Buzzer, Servo, AngularServo, DistanceSensor, MotionSensor, LineSensor and more, on the lgpio pin factory
RPi.GPIO 0.7.1
BCM and BOARD, setup, output, input, PWM, add_event_detect, wait_for_edge and cleanup, with the library’s own warnings and errors
Waktu
time.sleep(1) is one simulated second; edge callbacks run at the time of the edge
The Pi 5
RPi.GPIO fails there with the error a real Pi 5 gives, and gpiozero works
I2C dan SPI
/dev/i2c-1 and /dev/spidev0.0 and 0.1, with smbus, smbus2, spidev and gpiozero’s MCP3008, at the speed of the bus and with the errors a Pi gives
The Serial Monitor
print() and tracebacks, input(), and Ctrl-C as KeyboardInterrupt

Tidak dimodelkan

  • Linux. There is no kernel, no desktop, no terminal, no sudo and no file system beyond the project’s files.
  • pip and apt. Only the modules that come with the board can be imported.
  • Networking: no Wi-Fi, Ethernet or Bluetooth, and no socket or requests.
  • Kamera, layar, HDMI, dan audio.
  • The I2C bus’s speed setting and clock stretching: I2C runs at Raspberry Pi OS’s default 100 kHz.
  • Threads. gpiozero’s callbacks, blink() and PWM run without them.
  • CPython itself: the engine is MicroPython, so a few details of the language differ (isinstance(True, int) is False). Programs that drive the pins run unchanged.
Mulai dari sini

Buka salah satu dan tekan Jalankan

Masing-masing terbuka di editor persis seperti yang digambar di sini.

Belajar

Tutorial yang memakai board ini

Masing-masing berakhir dengan rangkaian yang berjalan, di board yang sama.

Pertanyaan

Apakah gratis?

Ya. Setiap board dan setiap komponen ada di paket gratis, tanpa akun.

Apakah ini emulator Raspberry Pi?

No. There is no Arm core and no Linux. Your Python runs in a Python engine in the page, and its gpiozero and RPi.GPIO drive the header. Everything a circuit can see of a Pi is here; the operating system is not.

Why does RPi.GPIO fail on the Pi 5?

Because it fails on a real Pi 5: the pins are on the RP1 chip, which RPi.GPIO 0.7.1 cannot find, and GPIO.setup raises "Cannot determine SOC peripheral base address". Use gpiozero, which works on all three boards.

Bisakah aku pip install sebuah library?

Tidak. Tambahkan file .py library sebagai tab tersendiri dan impor dari main.py, yang berfungsi untuk library yang ditulis dengan Python murni.

Apakah programku akan jalan di Pi sungguhan?

Ya, dengan gpiozero atau RPi.GPIO karena keduanya sudah ada di Raspberry Pi OS. Timing di Pi sungguhan lebih longgar: software PWM bergoyang di sana, tapi tidak di sini.

Coba dengan Python-mu sendiri

Tulis main.py dengan gpiozero atau RPi.GPIO lalu tekan Jalankan. Tanpa instalasi apa pun dan tanpa perlu akun.