Sensors & Measurement · Study deck
Protocol Diagnostics and Bus Design
Picture a room sensor that sometimes reports zero after a board restart.
Physics Phoebe is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: The Mistake: Connecting I2C sensors directly to GPIO pins without external pull-up resistors, assuming the microcontroller's internal pull-ups are sufficient, or using incorrect resistor values that cause unreliable communication.
- Explain: The optimal value depends on bus capacitance: R = t_rise / (0.8473 x C_bus), where t_rise is the maximum rise time from the I2C specification (1000 ns standard mode, 300 ns fast mode).
- Explain: The HIGH threshold is 2.31 V, which corresponds to about 11.0 kΩ: leakage below that can hold the bus invalid without being a dead short.
- resolve sensor address conflicts
Major section
Start With the Measurement Story
Zero may be a real reading, a missing reply, the wrong address, or a timing error.
- The receiving code must keep those states separate.
- GPIO means a general-purpose input/output pin used for a direct line.
- I2C is a shared two-wire link for addressed nearby parts.
- This runway does not diagnose every board fault.
Major section
Start With the Measurement Story (continued)
SPI is a clocked link with separate data paths and a select line.
- UART is a simple serial link that sends timed bits between two endpoints.
- Disconnect a wire, change the rate, repeat a read, and restart the controller.
- A bus failure often looks like a bad sensor until the evidence is checked.
Major section
Start With the Measurement Story (continued)
The deeper sections cover pull-ups, addresses, clock modes, framing, logic traces, shared-line design, and the tests that separate wiring from software.
- The useful story follows pull-ups, addresses, clock speed, cable length, signal integrity, and logs until the fault is visible instead of guessed.
- On the chapter's 3.3 V bus with 4.7 kΩ pull-up, a 1.65 V idle reading means $R_f=4.7$ kΩ.
- The HIGH threshold is 2.31 V, which corresponds to about 11.0 kΩ: leakage below that can hold the bus invalid without being a dead short.
Major section
Common Protocol Pitfalls
The Mistake: Connecting I2C sensors directly to GPIO pins without external pull-up resistors, assuming the microcontroller's internal pull-ups are sufficient, or using incorrect resistor values that cause unreliable communication.
- Internal pull-ups on ESP32 are weak (45-65 kohm), only suitable for very short wires (<10 cm) at low speeds.
Major section
Common Protocol Pitfalls (continued)
// WRONG: Default mode may not match sensor SPI.begin(); SPI.transfer(0x00).
- Beginners also confuse I2C (open-drain, requires pull-ups) with SPI (push-pull, no pull-ups needed).
- Common starting values are 4.7 kohm for standard 100 kHz I2C and 2.2 kohm for fast mode 400 kHz.
- The tool identifies collisions and suggests resolution strategies.
Major section
Common Protocol Pitfalls (continued)
The optimal value depends on bus capacitance: R = t_rise / (0.8473 x C_bus), where t_rise is the maximum rise time from the I2C specification (1000 ns standard mode, 300 ns fast mode).
- Symptom of missing pull-ups: I2C scanner finds no devices, or communication works intermittently.
- The MAX31855 thermocouple ADC requires Mode 0, while the ADXL345 accelerometer is typically used in Mode 3 (it also supports Mode 0).
- Mode 0 means clock idle low and sample on the rising edge; Mode 3 means clock idle high and sample on the falling edge.
- Understanding which clock edge is used for sampling helps you debug corrupted sensor readings.
Major section
Multi-Sensor I2C Bus Design
The breakout shares SDA and SCL but also exposes wake, reset, and interrupt signals that affect integration and recovery.
- Too weak (high resistance) causes slow rise times and communication errors.
- Too strong (low resistance) wastes power and may damage devices.

Major section
Summary
One to send, one to receive, one to keep time, and one to pick who is talking.
- I2C, SPI, and UART are the three core sensor communication protocols in IoT.
- Temperature Terry wanted to tell the microcontroller about the temperature, but they did not speak the same language!
- SPI would need a separate wire for each friend!" Now the whole Sensor Squad could chat, whether they needed speed or simplicity!
Deck summary
Key takeaways
Zero may be a real reading, a missing reply, the wrong address, or a timing error.
- SPI is a clocked link with separate data paths and a select line.
- The deeper sections cover pull-ups, addresses, clock modes, framing, logic traces, shared-line design, and the tests that separate wiring from software.
- The Mistake: Connecting I2C sensors directly to GPIO pins without external pull-up resistors, assuming the microcontroller's internal pull-ups are sufficient, or using incorrect resistor values that cause unreliable communication.
- // WRONG: Default mode may not match sensor SPI.begin(); SPI.transfer(0x00).
Retrieval practice
Recall check 1 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q1An ESP32 has three I2C sensors: BMP280 (0x76), BH1750 (0x23), and SHT31 (0x44). After adding a second BMP280 for redundancy, both pressure readings return identical values. What is the most likely cause?
Show answer
Answer: D Both BMP280 sensors default to address 0x76.
Retrieval practice
Recall check 2 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q2You need to read data from an SD card at 2 MB/s and also connect a BME280 environmental sensor. Which protocol combination is most appropriate?
Show answer
Answer: C SPI provides the clock rates needed for multi-megabyte-per-second SD-card traffic.
Retrieval practice
Recall check 3 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q3Place each sensor-interface signal where it lives so you can isolate an I2C, SPI, or voltage-level wiring fault.
Show answer
Answer: A Separate I2C shared-line checks, SPI transfer checks, and voltage-boundary protection so you can diagnose a silent sensor without swapping protocols or pins blindly.
Retrieval practice
Recall check 4 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q4Complete the MicroPython code to read temperature from a BME280 sensor over I2C on an ESP32:
Show answer
Answer: A I2C initialization requires specifying the bus number, SCL/SDA pins, and clock frequency (400kHz for Fast Mode).
Print reference
Answers
Answer key.
- D · Both BMP280 sensors default to address 0x76.
- C · SPI provides the clock rates needed for multi-megabyte-per-second SD-card traffic.
- A · Separate I2C shared-line checks, SPI transfer checks, and voltage-boundary protection so you can diagnose a silent sensor without swapping protocols or pins blindly.
- A · I2C initialization requires specifying the bus number, SCL/SDA pins, and clock frequency (400kHz for Fast Mode).