TUTORIALS Sensors
How to make more sensor-ble choices
PI PICO
When not writing terrible puns, Les Pounder delves into the myriad of sensors that you can use with the Raspberry Pi Pico.
OUR EXPERT
Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at http://bigl.es.
We’re going back to basics and looking at a trio of cheap sensors that can be used in a plethora of projects. The goal is to learn how sensors work and how we can integrate them into our Raspberry Pi Pico and Pico W builds. We’re using Thonny to write the project code.
Using a PIR sensor
The passive infrared sensor is the most basic sensor input. The BISS0001 sensor is used in many PIR sensors and has only two states. When idle, the output pin is at 0V, but when movement is detected, the pin pulls to 3.3V. This change of state is our trigger.
In a new file, start by importing the machine and utime modules. Machine is used to interact with the GPIO, while utime is used for precise timing. import machine import utime
Create an object to act as a link between our code and the PIR sensor connected to the GPIO at pin 16. Then set the pin as an input, and pull the GPIO pin down, so that it is at zero volts. This ensures that the pin can be read correctly.
YOU NEED
Pico/Pico W
HC-SR04P or HC-SR04+ ultrasonic sensor
Obstacle sensor/PIR RCWL0516 sensor
Half-size breadboard
4x M2M jumper wires
3x F2M jumper wires
Linux PC Code: https://github.com/lesp/LXF318-Sensors/archive/refs/heads/main.zip