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!
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!
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With