Sensors and I/O

I2C simple read/write

Humidity, IMU, display bridges — most sensors live here.

Sensors and I/O I2C sensor ESP32 family

Official path: examples/peripherals/i2c/i2c_simple

01 Overview

Master read/write of slave registers.

  • Use when: standard I2C sensors.
  • Skip when: high-rate imaging (SPI).

02 Hardware

  • Pull-ups on SDA/SCL (often 4.7k). Same voltage domain.
  • Two identical sensors need different ADDR pins.
  • Keep the bus short.

03 Software flow

1. Port and speed.

2. Write register, read bytes.

3. Scan the bus to confirm addresses.

4. Handle NACK and timeout — never spin forever.

04 Core points

  • No pull-ups, no I2C.
  • Custom work: sensor choice, schematic, sample task.

中文

传感器与外设

I2C 简单读写

温湿度、加速度计、屏幕桥,大多数传感器走这里。

传感器与外设 I2C 传感器 ESP32 family

官方路径: examples/peripherals/i2c/i2c_simple

01 项目概述

主机模式读写从机寄存器。

  • 适用: 标准 I2C 传感器。
  • 不适用: 高速图像(看 SPI)。

02 项目硬件描述

  • SDA/SCL 上拉(常见 4.7k)。电压域必须一致。
  • 地址冲突要查原理图,两个同样传感器要改 ADDR 脚。
  • 线不要又长又快。

03 项目软件流程描述

1. 配端口和速率。

2. 写寄存器、读数据。

3. 扫描总线确认地址。

4. 产品要处理 NACK 和超时,不要死等。

04 项目核心点

  • 没上拉就没 I2C。
  • 可定制: 传感器选型、原理图、采集任务。