Monitoring the physical health of the RPZ hardware
We took a look earlier on in the look at some of the measurements. In this recipe, we will dive a little bit deeper and use our new knowledge of outputs to regulate and alert on changes in the Raspberry Pi's health.
Getting ready
For this recipe, we will need the buzzer from the previous recipe, an RGB 4-lead LED, and three 330-Ohm resistors. If you don't have an RGB LED, you can alternatively make the same circuit using individual LEDs.
How to do it...
Configure the following circuit:
The following Python code will monitor the Raspberry Pi's health and change the values if there is a problem. Create a file named
rpz_alert.py
and enter the following code:#!/bin/env python # Chapter 7 Hardware Control # RPZ Health Monitoring and Alerting import time import os import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) redpin=18 greenpin=17 bluepin=27 buzzerpin=22 GPIO.setup(redpin, GPIO.OUT) ...