February 2022
Intermediate to advanced
182 pages
4h 25m
English
We’re nearly done. All we need to do now is combine the motionsensortest.py code from Chapter 6, Hue Auto Light, with the phototest.py script into a new Python file called photohook.py. Here’s what the final contents of that file should contain:
| | import os |
| | import requests |
| | import smbus |
| | import time |
| | |
| | WEBHOOK_URL = 'WEBHOOK_URL_GOES_HERE' |
| | CAPTURE_FILE = r'/home/pi/projects/photohook/capture.jpg' |
| | |
| | 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 |
| | BMP280_PRESSURE_REG_M = 0x0A ... |
Read now
Unlock full access