February 2022
Intermediate to advanced
182 pages
4h 25m
English
Now that we’re able to detect the ambient room temperature, let’s use the same approach we did in Chapter 4, Water Leak Notifier, and place upper and lower temperature boundaries to report when the temperature exceeds a set threshold condition. We’re also only going to poll the external temperature probe, so be sure it’s connected and working. In this example, set the temperature threshold to 80 degrees Fahrenheit:
| | import smbus |
| | import time |
| | |
| | DEVICE_BUS = 1 |
| | DEVICE_ADDR = 0x17 |
| | |
| | TEMP_REG = 0x01 |
| | LIGHT_REG_L = 0x02 |
| | LIGHT_REG_H = 0x03 |
| | STATUS_REG = 0x04 |
| | ON_BOARD_TEMP_REG = 0x05 |
| | ON_BOARD_HUMIDITY_REG = 0x06 |
| | ON_BOARD_SENSOR_ERROR = 0x07 |
| | BMP280_TEMP_REG = 0x08 |
| | BMP280_PRESSURE_REG_L = 0x09 ... |
Read now
Unlock full access