February 2022
Intermediate to advanced
182 pages
4h 25m
English
Before we flesh out a full-blown Python script to handle our email notification workflow, let’s first test the water sensor to be certain that it is working as expected.
We’ll be calling upon a custom Raspberry Pi library called RPi.GPIO to interrogate the status of the GPIO pins. Like many other Pi-centric/Pi-optimized software, the RPi.GPIO Python library is already pre-installed in Raspberry Pi OS. So there’s no need to use Pip to install it.
Create an empty Python file called watersensortest.py. Open the file using your preferred text editor and enter the following Python code:
| ① | import RPi.GPIO as GPIO |
| | import time |
| | |
| ② | GPIO.setmode(GPIO.BCM) |
| | GPIO.setup(21, GPIO.IN, pull_up_down ... |
Read now
Unlock full access