Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 789
André Schuster Avatar asked Nov 02 '22 10:11

André Schuster


2 Answers

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!

like image 159
Deanie Avatar answered Nov 09 '22 17:11

Deanie


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/

like image 40
pddring Avatar answered Nov 09 '22 15:11

pddring