A Python Library providing enhanced features and utilities for gpiozero.
This library is a Python wrapper designed to simplify the setup and control of components using the gpiozero library. It provides a convenient interface for managing various hardware components when working with Raspberry Pi, making it easier to interact with GPIO pins. It is a versatile tool for anyone looking to streamline the control of hardware components in Python applications.
This library relies on the following dependencies:
-
gpiozero: A Python library for controlling GPIO pins on Raspberry Pi and other supported platforms.
-
pigpio: A library for interfacing with the GPIO pins on the Raspberry Pi. It is required for certain functionality in this library.
You can install the gpiozero plus library using pip
. If you haven't already, make sure you have Python and pip installed on your system.
-
Clone the Repository: Clone the gpiozero plus repository to your local machine.
git clone https://github.com/jrendon102/gpiozero_plus.git
-
Navigate to the Project Directory: Go to the directory where you cloned the repository.
cd gpiozero_plus
-
Install the Package: Use
pip
to install the package after building it using the provided setup script.First, build the package:
python3 setup.py sdist
Next, use
pip
to install the package from the generated distribution:pip install .
Finally, verify that the package was installed successfully.
pip list | grep gpiozero_plus
To install pigpio library follow these steps:
-
Navigate to
opt/
directorycd /opt
-
Download the lastes version of pigpio:
sudo wget https://github.com/joan2937/pigpio/archive/master.zip
-
Unzip the downloaded archive and remove it
sudo unzip master.zip && sudo rm master.zip
-
Change to the pigpio-master direcotry:
cd pigpio-master
-
Build and install pigpio:
sudo make sudo make install
After completing these steps, you should have pigpio installed and ready for use.
You can uninstall the gpiozero_plus using the following command:
pip uninstall gpiozero_plus
Here's an example of how to use the gpiozero_plus
library in your Python project:
-
Start the pigpio daemon by running the following command:
sudo pigpiod
-
Create a script called
my_fan.py
with the following code:#!/usr/bin/env python3 import time from gpiozero_plus import Fan # Initialize and use the various components from the library fan = Fan(fan_pin=2) try: # Turn fan on for 5 seconds print("Turning fan on for 5 seconds") fan.control_fan(fan_enable=True) time.sleep(5) # Turn fan on off 5 seconds print("Turning fan off for 5 seconds") fan.control_fan(fan_enable=False) time.sleep(5) # Catch Keyboard interrupt to prevent motor from continuing to # operate if 5 seconds have not elapsed. except KeyboardInterrupt: print("Keyboard interrupt received.") # Make sure to release the GPIO pin(s) fan.disconnect()
-
Finally run the command
python3 my_fan.py
to see the fan in action.
For more information about pigpio, you can visit the official website.
Information about the pigpio Daemon can be found in the official website.
This project is licensed under the MIT License - see the LICENSE file for details.
Julian Rendon
Email: julianrendon514@gmail.com