From the course: Raspberry Pi: GPIO

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Control the BME280 and PCA9685

Control the BME280 and PCA9685

From the course: Raspberry Pi: GPIO

Control the BME280 and PCA9685

- [Instructor] When you've checked all the parts, we're going to run code that connects the BME280 to the servos. Open up exercise files chapter seven 07_05_servos_bme_280_pca9685. If you double-click on that, it will open up in Thonny. There are three parts to this program, i2c initialization, device initialization, and data gathering and interpretation. Lines nine through 33 confirm the presence of i2c and the address of the BME280. In an earlier video, you did this by hand with i2cdetect. This code demonstrates how to find it with Python. Lines 41 through 44 then set up the PCA9685 with the servo library. This assumes the servos are connected to the first pin set and the last pin set. Notice that the first pin set is referred to as zero rather than one. In line 41, you can see that the first pin set is referred to as zero, and in line 43, you can see that the last pin set is referred to as 15. It's also…

Contents