André Schuster
André Schuster

Reputation: 165

Simulate Raspberry Pi GPIO signal

I'm new on Raspberry Pi and I would to know how can we simulate/mock the sensors (or GPIO) so I can test just my python code, mocking the Highs and Lows of the pins?

Thanks in advance!

Upvotes: 6

Views: 7379

Answers (2)

pddring
pddring

Reputation: 181

I've made a RPi GPIO simulator to allow you to quickly test python scripts in a web browser.

Here's an example for flashing an output pin: https://create.withcode.uk/python/A5

Alternatively, there's a library that you could download to simulate the inputs / outputs offline:

https://roderickvella.wordpress.com/2016/06/28/raspberry-pi-gpio-emulator/

Upvotes: 2

Deanie
Deanie

Reputation: 2393

IF you just don't want to trust a software layer, you could try manually setting the pin high:

The GPIO pins on the Raspberry Pi work with a voltage of 3.3VDC.

Pins 1 & 17 on the P1-GPIO header outputs 3.3VDC.

You could CAREFULLY try to connect a jumper from Pin 1 or 17 to the GPIO input pin you want to test. Connect it to test high, disconnect to test for low.

MAKE SURE YOU DON"T USE THE 5VDC GPIO PINS, YOU COULD/WILL DAMAGE/KILL YOUR PI!

Upvotes: 1

Related Questions