Skip to main content

A module intended to abstract away a lot of the complexity of using the GPIO and PiCamera for beginner programmers.

Project description


This project aims to remove a lot of the complexity of dealing with the GPIO and PiCamera for beginner level programmers working with the Raspberry Pi.

This project has been initially developed for use within my own classes that I teach but I hope it might find use for others too.



This assumes you have a Raspberry Pi (and a PiCamera to use that functionality). All code tested on Raspberry Pi model 3, PiCamera model 2, running Raspbian 2018-06-29.


pip install easyaspi


At present, the project supports LEDs, buttons, ultrasonics and the PiCamera. This list of tools is expected to grow as need arises.

Note: This library will set the default GPIO pin layout mode to BCM.


  • Create the LED object
import easyaspi
led = easyaspi.LED( pin_number )
  • Turn an LED on
  • Turn an LED off


  • Create the Button object
import easyaspi
button = easyaspi.Button( pin_number )
  • Retrieve if the button is being pressed
button_state = button.get()
  • Set an event callback for button presses
# Note: The function definition for the callback requires the state parameter even though it should always be set to True to indicate the button is currently pressed.

def was_pressed(state):
   print("Button was pressed!")

  • Remove an event callback
button.remove_on_press()            # Remove any event listener for this button


  • Create the Ultrasonic variable
import easyaspi
ultra = easyaspi.Ultrasonic( trigger_pin_number, echo_pin_number )
  • Retrieve the distance in centimeters
distance = ultra.get_distance()


  • Create the Camera object
import easyaspi
camera = easyaspi.Camera()
  • Take a photo (without a message)"myphoto.png")
  • Take a photo (with a message)"myphoto.png", "my message")
  • Start video recording
camera.record("myvideo.h264", "my message")
  • Check to see if camera is recording video
recording_state = camera.recording      # Returns True or False
  • Stop video recording
  • Close the camera preview window when finished



MIT License (C) 2018 Paul Baumgarten

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyaspi-2018.3.tar.gz (3.6 kB view hashes)

Uploaded source

Built Distribution

easyaspi-2018.3-py3-none-any.whl (4.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page