User avatar
ptimlin
Posts: 48
Joined: Tue Jan 08, 2019 7:44 pm

Simulating the Pi board GPIO

Tue Jan 08, 2019 8:16 pm

Hello,

Brand new to the Raspberry Pi and have just started to teach myself Python with the intention of using the Pi on a couple home electronic projects.

Is there any sort of software simulator to represent the Pi HW, specifically the GPIO and other pins on that connector, when developing code? I would like to be able to turn on/off inputs and/or see the state of outputs when using the RPi library without having to physically hook up hardware. Perhaps some sort of software module that appears like the real hardware and shows the various pins on the board with SW "led" indicators or SW "switches" in another window.

If not, then I can make up some sort of GPIO module that will allow me to have a bank of switches and LED hooked up to the physical board when testing code, but thought I would check here in case some sort of SW solution already exists. Ideally, this let you develop code and simulate the Pi board when you are in places where it is not practical to have a bunch of hardware hanging off your computer, spread across a table, and plugged into a wall (Starbucks, airplane, etc.)

Thank you,
Patrick

PhatFil
Posts: 915
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Simulating the Pi board GPIO

Tue Jan 08, 2019 9:07 pm

Hi Patrick, most folk will use a breadboard and a few jumper wires with the components necessary for a test bed.

Familiarity with the tools will soon make adding a quick led/resistor circuit with a breadboard to your pi as casual as making a cup of coffee/tea.

fritzing is circuit s/w developed for arduino development but may be useful to you. http://fritzing.org/home/

By all means be vigilant and carefull, use planning before doing, but dont be afraid to get hands on either ;)

User avatar
ptimlin
Posts: 48
Joined: Tue Jan 08, 2019 7:44 pm

Re: Simulating the Pi board GPIO

Tue Jan 08, 2019 10:04 pm

I suppose I should have also mentioned I have an Electrical Engineering degree so I have no issue with physical hardware and how to hook it up. I was just hoping there might be a virtual Raspberry Pi simulator for times when I want to play with code for when I don't have Pi hardware with me or simply not be in the mood to set it all up.

PhatFil
Posts: 915
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Simulating the Pi board GPIO

Wed Jan 09, 2019 12:20 am

ptimlin wrote:
Tue Jan 08, 2019 10:04 pm
I suppose I should have also mentioned I have an Electrical Engineering degree so I have no issue with physical hardware and how to hook it up. I was just hoping there might be a virtual Raspberry Pi simulator for times when I want to play with code for when I don't have Pi hardware with me or simply not be in the mood to set it all up.
for code prototyping and debugging its very common to substitute input for keyboard input and use Print statements to provide output indication.


when it comes to reading or changing the state of a gpio well thats trivial when compared to converting your intention and program design into correctly functioning logic that accepts input and correctly identifies when to change any output states..


Btw Once enabled you can use SSH or VNC to connect to your pi meaning you only need a psu to fire it up and test things either on a desktop or in a terminal session.

User avatar
mikronauts
Posts: 2678
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Simulating the Pi board GPIO

Wed Jan 09, 2019 12:55 am

At the risk of appearing self serving, I tend to use

Image

For my simple Pi breadboard experiments (with various Pi models)

And more complicated variations as well

Image
ptimlin wrote:
Tue Jan 08, 2019 8:16 pm
Hello,

Brand new to the Raspberry Pi and have just started to teach myself Python with the intention of using the Pi on a couple home electronic projects.

Is there any sort of software simulator to represent the Pi HW, specifically the GPIO and other pins on that connector, when developing code? I would like to be able to turn on/off inputs and/or see the state of outputs when using the RPi library without having to physically hook up hardware. Perhaps some sort of software module that appears like the real hardware and shows the various pins on the board with SW "led" indicators or SW "switches" in another window.

If not, then I can make up some sort of GPIO module that will allow me to have a bank of switches and LED hooked up to the physical board when testing code, but thought I would check here in case some sort of SW solution already exists. Ideally, this let you develop code and simulate the Pi board when you are in places where it is not practical to have a bunch of hardware hanging off your computer, spread across a table, and plugged into a wall (Starbucks, airplane, etc.)

Thank you,
Patrick
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

hippy
Posts: 4460
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Simulating the Pi board GPIO

Wed Jan 09, 2019 10:41 am

If you write a wrapper module for GPIO which your software always calls for accessing GPIO, it should be possible to have that wrapper read and write physical GPIO and/or some screen interface simulation.

GPIO Zero, through pigpio, allows one Pi to use a remote Pi's GPIO, so it may be possible to use one or the other to connect to, not another Pi, but something which is simulating that remote Pi's GPIO on screen -

https://gpiozero.readthedocs.io/en/stab ... _gpio.html

User avatar
ptimlin
Posts: 48
Joined: Tue Jan 08, 2019 7:44 pm

Re: Simulating the Pi board GPIO

Wed Jan 09, 2019 8:02 pm

Thank you all for your replies. Looks like I will just do it the old fashioned way and hook up some LEDs and SWs to the Pi.

User avatar
neilgl
Posts: 387
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Simulating the Pi board GPIO

Thu Jan 10, 2019 12:41 am

Maybe have a look at WiringPi ?

Andyroo
Posts: 1525
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Simulating the Pi board GPIO

Thu Jan 10, 2019 1:39 am

Save space and stick one of these on the top of the Pi https://shop.pimoroni.com/products/explorer-hat

Image

Switches, LEDs, buffered inputs and sits in the Pi footprint.

Best £1.50 I spent in the Maplin closing sale :D
Need Pi spray - these things are breeding in my house...

User avatar
ptimlin
Posts: 48
Joined: Tue Jan 08, 2019 7:44 pm

Re: Simulating the Pi board GPIO

Thu Jan 10, 2019 7:02 pm

neilgl wrote:
Thu Jan 10, 2019 12:41 am
Maybe have a look at WiringPi ?
From the website... " is intended for use by experienced C/C++ programmers. It is not a newbie learning tool." so certainly not for me. ;)

Andyroo wrote:
Thu Jan 10, 2019 1:39 am
Save space and stick one of these on the top of the Pi https://shop.pimoroni.com/products/explorer-hat
Looks like that one would cost me about $31+ shipped to the USA. But I have seen other somewhat similar type boards I might look into if they are cheap. But I can throw my own simple board together for free with parts I have around and a bit of my time soldering it up.

Thanks to both suggestions though.

User avatar
neilgl
Posts: 387
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Simulating the Pi board GPIO

Fri Jan 11, 2019 12:40 pm

Yes by wiringPi I meant the python wrapper for it (pip install wiringpi)

Return to “Beginners”