logo elektroda
logo elektroda
X
logo elektroda

Recommended I2C Pinout for BME280 Sensor on CBU Module: SDA/SCL Pin Numbers?

qscented 129 2
ADVERTISEMENT
  • #1 21795551
    qscented
    Level 1  
    @ElektrodaBot
    Which pins are best for connecting an I2C sensor BME280 to the CBU module?
  • ADVERTISEMENT
  • #2 21795562
    ElektrodaBot
    AI OpenAI ChatGPT4
    qscented wrote:
    @ElektrodaBot
    Which pins is best for connecting a i2c sensor BME280 to the CBU module
    Initial assessment of available information
    - “CBU” is a Tuya Wi‑Fi + BLE module based on the BK7231N SoC. The official CBU datasheet lists the GPIOs that are brought out on the module’s castellated pads, but it does not designate any dedicated I²C pins. I²C can be implemented on general‑purpose pins. Notably, TX2/RX2 (P0/P1) are used as a log/boot UART and should be avoided for application wiring. (developer.tuya.com)
    - Tuya’s own “CB series wiring” guide shows the common GPIO groups exposed on CBU (P24/P26, P7/P8, P6/P26, P14/P16, etc.), which are suitable pairings for bit‑banged or software I²C. (developer.tuya.com)
    - The Bosch BME280 supports I²C at 3.3 V logic and has two possible I²C addresses (0x76 or 0x77). Breakout boards often include pull‑ups and, sometimes, a regulator/level‑shifter, but the bare IC is a 1.71–3.6 V device. (bosch-sensortec.com)

    Direct answer to the question
    - Best, low‑risk pin pair on a CBU module for an I²C BME280:
    - SCL → P24
    - SDA → P26
    Reasons: both are regular GPIOs (PWM‑capable, no boot/console role), they are adjacent on the CBU edge making short, tidy wiring near 3V3/GND, and they are widely used for I²C on BK7231N designs. (developer.tuya.com)

    - Good alternatives (if P24/P26 are already used in your device):
    - P7 ↔ P8 (pair)
    - P14 ↔ P16 (pair, originally SPI pins but usable as GPIO)
    - P6 ↔ P26 (mixed pair shown in Tuya wiring guide)
    Avoid using TX2/RX2 (P0/P1) as they are the module’s log/boot UART. (developer.tuya.com)

    Detailed problem analysis
    - Why P24/P26?
    - Electrical neutrality: P24 and P26 are general‑purpose I/O with PWM capability and no special boot‑strapping roles. They are safe for bus signals like I²C. (developer.tuya.com)
    - Layout convenience: On the CBU pin map these sit next to the power pins (GND pad 13 and 3V3 pad 14), which shortens the I²C loop area and makes routing and strain‑relief easier. Shorter runs reduce bus capacitance and improve signal integrity. (developer.tuya.com)
    - Why avoid P0/P1 (TX2/RX2)?
    - The datasheet explicitly labels TX2 as the “print log port,” and these pins are commonly used during boot and debugging. Using them for I²C can conflict with boot messages or flashing workflows. (developer.tuya.com)
    - Using alternative pairs:
    - P7/P8 and P14/P16 are also clean, general GPIOs (P14/P16 are SPI‑capable but can be repurposed). They’re listed as accessible “groups” in Tuya’s CB‑series wiring guide, which is why many community designs pair them for buses. (developer.tuya.com)
    - Electrical interface to BME280:
    - Supply the sensor at 3.3 V when interfacing with CBU (BK7231N I/O is 3.3 V). The BME280 IC itself specifies VDD 1.71–3.6 V and VDDIO 1.2–3.6 V; many breakout boards accept 3–5 V due to onboard regulation, but 3.3 V is the safest common denominator with CBU. (bosch-sensortec.com)
    - I²C pull‑ups: If your BME280 breakout lacks them, add 2.2–4.7 kΩ pull‑ups from SDA/SCL to 3.3 V. Reputable BME280 guides and libraries recommend these values. (github.com)
    - Addressing: default is 0x76 or 0x77 depending on board vendor; SDO tied low selects 0x76, tied high selects 0x77. Confirm with an I²C scan. (learn.adafruit.com)

    Practical guidelines
    - Wiring (recommended pins):
    - CBU 3V3 → BME280 VCC
    - CBU GND → BME280 GND
    - CBU P24 → BME280 SCL
    - CBU P26 → BME280 SDA
    - Keep wires short (≤20–30 cm). If you must run longer, lower the I²C clock (e.g., 100 kHz) and/or use stronger pull‑ups (≈2.2 kΩ). (github.com)
    - Firmware examples:
    - OpenBeken:
    - Assign roles in Web UI: set P24 = I2C_SCL, P26 = I2C_SDA; Save/Reboot.
    - Console: i2c_scan → verify 0x76/0x77 is detected; then startDriver BME280.
    - (OpenBeken exposes an i2c_scan command; typical workflow aligns with OBK docs and practice.) (elektroda.com)
    - TuyaOS (custom app development): use any two GPIOs you control for a software I²C implementation; avoid the UART/log pins. Reference the CBU pin table when selecting and initializing pins. (developer.tuya.com)

    Troubleshooting checklist
    - No device found:
    - Confirm 3.3 V at the BME280 VCC and common ground.
    - Run an I²C scan to see the address; if your driver expects 0x77 but the board is at 0x76, set it explicitly. (learn.adafruit.com)
    - Add/verify pull‑ups on SDA/SCL to 3.3 V (2.2–4.7 kΩ). (github.com)
    - Try a different pin pair (e.g., P7/P8) if the first pair is busy in your device. (developer.tuya.com)
    - Sporadic reads/wire length issues:
    - Reduce speed to 100 kHz and keep leads short; check for solid grounds and clean solder joints. (github.com)

    Brief summary
    - Use P24 (SCL) and P26 (SDA) on CBU for the BME280’s I²C—clean, adjacent, and conflict‑free with boot/console. Alternatives: P7/P8 or P14/P16. Avoid TX2/RX2 (P0/P1). Power at 3.3 V, ensure pull‑ups, and set the correct I²C address (0x76/0x77). (developer.tuya.com)

    Questions for you
    - Which firmware are you running on the CBU (TuyaOS, OpenBeken, LibreTiny/ESPHome)?
    - Is this a bare CBU module on your own PCB, or is it inside a finished Tuya product (some pins may already be used)?
    - If it is inside a product, can you share a photo or tell us which pins are free? I can propose the safest pair accordingly.

    References
    - Tuya CBU module datasheet (GPIO map and function notes, including TX2 as log port). (developer.tuya.com)
    - Tuya CB‑series wiring guidance for CBU GPIO groupings (recommended pin pairs). (developer.tuya.com)
    - Bosch BME280 product page (voltages, interface). (bosch-sensortec.com)
    - Adafruit BME280 pinouts and address selection (0x76/0x77). (learn.adafruit.com)
    - BME280 wiring/pull‑up guidance used by common Arduino library. (github.com)
    You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
  • #3 21796161
    p.kaczmarek2
    Moderator Smart Home
    You can use any GPIO for I2C for BME280 in OBK. It's very flexible.

    See BME280 guide
    How to add BME280 to a smart device and send measurements to Home Assistant? OpenBeken
    This OBK BME280 guide is the quickest and safest solution to get you started. No programming needed. You don't even need to compile firmware yourself, because even for custom sensors, OBK has _sensors variant available in the Releases tab.
    https://github.com/openshwprojects/OpenBK7231T_App/releases/
    Helpful post? Buy me a coffee.
ADVERTISEMENT