You may have noticed that it takes a really long time for our page to refresh. This is due to the 30-second refresh time, of course, as well as the long time it takes for the DHT11 to read a value.
Let's change our code to make it quicker, and give it a buzzer to scare away an intruders.
Replace the DHT11 with a buzzer connected to GPIO pin 17 (we shouldn't need a Fritzing diagram for this simple change).
We will start by creating the SecurityDataQuick data class:
- Open up Thonny from Application Menu | Programming | Thonny Python IDE
- Click on New to create a new file
- Type the following into the file:
from gpiozero import MotionSensorfrom gpiozero import Buttonfrom datetime import datetimefrom ...