Raspberry Pi GPIO Emulator

This Raspberry Pi emulator simulates some of the functions used in the RPi.GPIO library (using python). The intention of this library is educational.



The easiest way is to download the zip file and extract the files in the same working environment of your script. To use the emulator just type the following at the beginning of your script.

from EmulatorGUI import GPIO


This library simulates the following functions which are used in the RPi.GPIO library.

  • GPIO.setmode()
  • GPIO.setwarnings()
  • GPIO.setup()
  • GPIO.input()
  • GPIO.output()

Test Example

from EmulatorGUI import GPIO
#import RPi.GPIO as GPIO
import time
import traceback

def Main():


        GPIO.setup(4, GPIO.OUT)
        GPIO.setup(17, GPIO.OUT, initial = GPIO.LOW)
        GPIO.setup(18, GPIO.OUT, initial = GPIO.LOW)
        GPIO.setup(21, GPIO.OUT, initial = GPIO.LOW)
        GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_UP)
        GPIO.setup(15, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
        GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
        GPIO.setup(26, GPIO.IN)

            if (GPIO.input(23) == False):

            if (GPIO.input(15) == True):

            if (GPIO.input(24) == True):

            if (GPIO.input(26) == True):

    except Exception as ex:
        GPIO.cleanup() #this ensures a clean exit



Click here to download

28 thoughts on “Raspberry Pi GPIO Emulator

  1. This is extremely helpful and works with beautiful ease! No more than 30 seconds to get set up, clear indication of the state of the GPIOs (laid out to reflect the physical pins) and simple click-control of the input pins. Really nicely done, thank you!

    Liked by 1 person

  2. Wonderful! but I am a beginner. still I could not run the emulator. Are there any requirements are needed. I tried to run it windows as well as in raspberry itself. My python version is 2.7. looking for your assist.


    • It is implemented but it does nothing so it’s not going to give you any exceptions. Normally GPIO.Cleanup is used at the end of the script so for the emulator you simply restart your script and cleanup is done automatically.


      • But if I wish to run tests which repeatedly set up the pins and then check that the outputs are changing as expected I get exceptions as the pins are already assigned. I have altered the code to allow me to do this, but I am trying to see if there is a way of closing the window from the code. Is there an easy way to do this? Thanks!


  3. It is highly recommended to setup your pins at the start of the script and keep them set the same through the whole script. Why do you want your script to close the simulator window?


  4. Hi,

    Nice code indeed, very useful, I’m using it to debug a multi on/off sensor setup. I wonder if you could make buttons stick to “pressed” or “released” just with 1 click, instead of having to keep it down (which only lets you make 1 change at a time).

    Good work 🙂


  5. Thanks. I found it to be pretty handy for getting started writing the code on my laptop instead of having to do it on the Rpi. I need to make event-driven code now, instead of polling, and I realized that you’ve only emulated a small subset of the GPIO functions. Do you have any intentions of adding GPIO.add_event_detect() and similar?


  6. Hi,
    I work with Windows 7 and Python 3.1.2 .
    When I try the file “tester2.py”, I have :
    Traceback (most recent call last):
    File “C:\Users\François\Desktop\GPIOEmulator\tester2.py”, line 1, in
    File “C:\Users\François\Desktop\GPIOEmulator\EmulatorGUI.py”, line 4, in
    from TypeChecker import typeassert
    File “C:\Users\François\Desktop\GPIOEmulator\TypeChecker.py”, line 1, in
    from inspect import signature
    ImportError: cannot import name signature

    Have you a solution ?
    Thank you


  7. Pingback: Emulating Raspberry Pi – Lamp of Socrates

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s