Introduction: Raspberry Pi With Phidgets
This tutorial will show you how to get started with Phidgets on your Raspberry Pi.
Supplies
- Any Phidget (for this project, we will be using a VINT Hub and a Humidity Phidget)
- A Raspberry Pi (Model 2 and above)
Step 1: Raspberry Pi - Models 2 and Above
Open the terminal and enter the following command:
curl -fsSL <a href="https://www.phidgets.com/downloads/setup_linux" rel="nofollow"> https://www.phidgets.com/downloads/setup_linux </a> | sudo -E bash - sudo apt-get install -y libphidget22<br>
The above command will install the Phidgets repository on your Raspberry Pi, and then use that repository to download the latest libraries.
That's all there is to it!
Step 2: Using a Different Raspberry Pi Model?
If you are using a Raspberry Pi Zero, Raspberry Pi 1, or any other Linux machine, the instructions above won't work for you. Instead, follow these:
Install libusb:
apt-get install libusb-1.0-0-dev<strong><br></strong>
Download libphidget22 onto your device. Extract the file using the following command:
tar -xf archive.tar.gz<strong><br></strong>
Enter the following command:
./configure --prefix=/usr && make && sudo make install
Step 3: Write Code - Python
Thonny comes pre-installed on Raspberry Pi OS, you will use it in this section to write some code against your Phidgets!
- Open Thonny by navigating to Programming > Thonny
- By default, Thonny opens in simple mode. Click on Switch to reulgar mode and then restart Thonny.
- Click on Tools > Manage packages
- Search for Phidget22 and press Install
In the step above, you installed the Phidget22 Python libraries. Now you can write some code! Copy the following code into a new script:
#Add Phidgets Library
from Phidget22.Phidget import *
from Phidget22.Devices.TemperatureSensor import *
#Required for sleep statement
import time
#Create
temperatureSensor = TemperatureSensor()
#Open
temperatureSensor.openWaitForAttachment(1000)
#Use your Phidgets
while(True):
print(" Temperature: " + str(temperatureSensor.getTemperature()) + " °C" )
time.sleep(0.15)
Run your program to see the temperature displayed in degrees Celisus.
Step 4: Learn More
Congratulations, your Raspberry Pi is now working with Phidgets.
If you are a teacher or student, visit phidgets.com/education for more projects and up-to-date tutorials.





