Kurse › Raspberry Pi › Stufe 11
Raspberry Pi · Einsteiger · Stufe 11 / 40
The I2C Bus
Wire, scan and program I2C devices, from ready-made libraries down to raw register access.
Einsteiger freischalten · CHF 9.90 Stufen 1–13, einmalig, kein Abo
10 Lektionen in dieser Stufe
- How I2C Shares Two Wires Among Many Devices
Describe addressing, start and stop conditions and acknowledge bits. · Lab: Decode a printed I2C waveform by hand into address, direction and data bytes. - Enabling I2C and Scanning the Bus with i2cdetect
Turn on the interface and confirm a device answers at its address. · Lab: Enable I2C, wire a BME280 and find it with i2cdetect -y 1. - Reading a BME280 with a Ready-Made Library
Install a driver library in a venv and get calibrated readings. · Lab: Print temperature, humidity and pressure once a second and sanity-check them. - Reading Registers Directly with smbus2 and a Datasheet
Find a register in a datasheet and read it without a driver library. · Lab: Read the BME280 chip-ID register and one raw data register with smbus2. - Bytes, Bits and Two's Complement for Sensor Data
Combine bytes into signed values and apply masks and shifts. · Lab: Convert raw two-byte readings into signed integers and verify against known values. - Several Devices on One Bus and Address Conflicts
Plan addresses and resolve clashes with address pins or a multiplexer. · Lab: Run two identical sensors on one bus through a TCA9548A. - Pull-Ups, Cable Length and Bus Speed
Choose pull-up values and bus speed for a reliable link. · Lab: Extend the bus with a one-metre cable and find the speed at which errors begin. - Motion Data from an MPU6050 Accelerometer and Gyro
Read acceleration and rotation and convert them into physical units. · Lab: Print tilt angle from the accelerometer and detect a tap. - Keeping Time with a DS3231 and the Pi 5 Onboard RTC
Hold correct time without a network on Pi 4 and Pi 5. · Lab: Fit the Pi 5 RTC battery or a DS3231, disconnect the network and verify time after a power cycle. - Diagnosing I2C Faults: NACKs, Stuck Buses and Wrong Voltages
Find the cause when a device does not appear or returns errors. · Lab: Diagnose three prepared faults: swapped wires, missing ground and a 5 V-only module.
Abschlussprojekt
A multi-sensor environmental node that reads climate and motion data over one I2C bus and keeps correct timestamps with no network.
Teile für diese Stufe
- 1 × Raspberry Pi 5 or Pi 4 set from Level 1
- 1 × Breadboard and jumper wire set
- 1 × BME280 temperature, humidity and pressure module (3.3 V)
- 1 × MPU6050 accelerometer and gyro module
- 1 × DS3231 real-time clock module
- 1 × RTC backup battery for the Pi 5
- 1 × TCA9548A I2C multiplexer module
- 1 × Bidirectional logic level converter 4-channel
- 1 × Resistor kit including 4.7 k ohm
In jeder Lektion legst du die passenden Teile direkt in den Warenkorb. Raspberry Pi →
Voraussetzung: Levels 6 to 10: GPIO wiring, Python modules, logging and virtual environments.