Skip to content

Instantly share code, notes, and snippets.

@IoTeacher
Last active May 4, 2026 03:05
Show Gist options
  • Select an option

  • Save IoTeacher/28812206a0e39e26297e4424830da6be to your computer and use it in GitHub Desktop.

Select an option

Save IoTeacher/28812206a0e39e26297e4424830da6be to your computer and use it in GitHub Desktop.
image GPIO Table

Below is a technical GPIO table for the header shown in the image. The numbering appears to follow Raspberry Pi BCM GPIO numbering, not physical pin numbering.

Label on Board Type BCM GPIO / Signal Electrical Level Main Function Technical Description
5V Power 5V rail 5 V DC Power output/input rail Supplies 5 V from the board power rail. Useful for powering external modules that require 5 V. Do not connect this pin directly to GPIO signal pins.
GND Power Ground 0 V Reference ground Common electrical reference for sensors, modules, and external circuits. Must be connected to the sensor GND for correct signal reference.
GPIO14 Digital I/O / UART BCM 14 / TXD0 3.3 V logic UART TX / GPIO Default UART transmit pin on Raspberry Pi-compatible layouts. Can also be used as general digital output/input if UART is disabled. Not 5 V tolerant.
GPIO15 Digital I/O / UART BCM 15 / RXD0 3.3 V logic UART RX / GPIO Default UART receive pin. Used for serial communication. If used as GPIO, avoid conflict with serial console configuration. Not 5 V tolerant.
GND Power Ground 0 V Reference ground Additional ground pin for signal stability and cleaner wiring. Recommended for sensors using I2C, UART, or PWM.
GPIO24 Digital I/O BCM 24 3.3 V logic General-purpose I/O Configurable as input or output. Commonly used for buttons, LEDs, interrupt lines, chip-select signals, or digital sensors.
GPIO25 Digital I/O BCM 25 3.3 V logic General-purpose I/O Configurable as input or output. Frequently used as an auxiliary control signal, interrupt input, or LED output.
3V3 Power 3.3 V rail 3.3 V DC Sensor power rail Supplies regulated 3.3 V. Preferred power source for I2C sensors such as BME280, BMP280, SHT31, TMP102, etc. Limited current; avoid powering motors or high-current loads.
SDA1 I2C Data BCM 2 / SDA1 3.3 V logic I2C data line Bidirectional serial data line for I2C bus 1. Requires pull-up resistors to 3.3 V; many sensor breakout boards already include them.
SCL1 I2C Clock BCM 3 / SCL1 3.3 V logic I2C clock line Clock signal for I2C bus 1. Used together with SDA1. Typical Raspberry Pi I2C bus is /dev/i2c-1.
GPIO17 Digital I/O BCM 17 3.3 V logic General-purpose I/O Common GPIO for buttons, interrupts, chip-enable lines, or simple digital control. Supports edge detection in software.
GPIO27 Digital I/O BCM 27 3.3 V logic General-purpose I/O General GPIO line often paired with GPIO17 in examples. Suitable for input/output, interrupts, or control lines.
GPIO22 Digital I/O BCM 22 3.3 V logic General-purpose I/O General GPIO line. Can be used for digital sensors, enable pins, relays through transistor drivers, or external interrupt lines.
GPIO12 Digital I/O / PWM BCM 12 / PWM0 3.3 V logic GPIO / hardware PWM Supports hardware PWM on compatible Raspberry Pi systems. Useful for LED dimming, buzzer tones, servo-style signaling through proper driver circuits, or general GPIO.

Important electrical note: the GPIO pins are 3.3 V logic only. Applying 5 V to GPIO14, GPIO15, GPIO24, GPIO25, SDA1, SCL1, GPIO17, GPIO27, GPIO22, or GPIO12 can permanently damage the board.

image

Example: reading a temperature sensor using I2C BME280


he BME280 is easiest to wire over I²C. On the Distiller GPIO header (from your GPIO table), the I²C bus is:

  • Pin 9 = SDA1 (I²C data)
  • Pin 10 = SCL1 (I²C clock)
  • Pin 8 = 3V3
  • Pin 2 or 5 = GND

Wiring (BME280 breakout → Distiller GPIO header)

Use 3.3V power (the GPIOs are 3.3V tolerant only).

BME280 pin Connect to Distiller
VCC / VIN Pin 8 (3V3)
GND Pin 2 (GND) or Pin 5 (GND)
SDA Pin 9 (SDA1)
SCL Pin 10 (SCL1)
CS / CSB (if present) Tie to 3V3 (forces I²C mode on many boards)
SDO / ADDR (if present) GND → address 0x76 (common default) or 3V3 → 0x77

If your BME280 board is a “5V-friendly” module, it may accept 5V on VIN, but do not put 5V on SDA/SCL. Safest is: power it from 3V3 and keep I²C at 3.3V.


Linux preparation:

sudo raspi-config

Enable:

Interface Options → I2C → Enable

Install Python libraries:

sudo apt update
sudo apt install -y python3-pip i2c-tools
pip3 install adafruit-circuitpython-bme280

Verify that the sensor is detected:

i2cdetect -y 1

Typical BME280 addresses are:

0x76
0x77

Python example:

# ============================================================
#  ██████╗ ███╗   ███╗███████╗██████╗  █████╗  ██████╗
#  ██╔══██╗████╗ ████║██╔════╝██╔══██╗██╔══██╗██╔═████╗
#  ██████╔╝██╔████╔██║█████╗  ██████╔╝╚█████╔╝██║██╔██║
#  ██╔══██╗██║╚██╔╝██║██╔══╝  ██╔═══╝ ██╔══██╗████╔╝██║
#  ██████╔╝██║ ╚═╝ ██║███████╗██║     ╚█████╔╝╚██████╔╝
#  ╚═════╝ ╚═╝     ╚═╝╚══════╝╚═╝      ╚════╝  ╚═════╝
#
#  [ SYSTEM SENSOR NODE :: BME280 ENVIRONMENT MONITOR ]
#  ------------------------------------------------------------
#  Programmer : IoTeacher
#  Course     : Systems Engineering / Sensor Programming
#  Device     : BME280 Temperature, Humidity, Pressure Sensor
#  Protocol   : I2C
#  Address    : 0x76
#  Platform   : CircuitPython / Raspberry Pi Compatible
#  Purpose    : Read and display environmental sensor data
#  Status     : ACTIVE
#  ------------------------------------------------------------
#  "Accessing atmosphere data stream..."
# ============================================================

import time
import board
import busio
import adafruit_bme280.advanced as adafruit_bme280

# I2C bus using SDA and SCL
i2c = busio.I2C(board.SCL, board.SDA)

# Try address 0x76 first. Change to 0x77 if needed.
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)

# Optional: set sea-level pressure for altitude calculation
bme280.sea_level_pressure = 1013.25

while True:
    temperature_c = bme280.temperature
    humidity = bme280.relative_humidity
    pressure = bme280.pressure

    print(f"Temperature: {temperature_c:.2f} °C")
    print(f"Humidity: {humidity:.2f} %")
    print(f"Pressure: {pressure:.2f} hPa")
    print("-" * 30)

    time.sleep(2)

Brief explanation:

The BME280 communicates through I2C, so it only needs two signal wires: SDA for data and SCL for clock. The sensor is powered with 3.3 V, and the board reads the temperature digitally through the I2C bus. This is safer and more precise than reading an analog temperature sensor because the Raspberry Pi-style GPIO header does not include native analog inputs.

T

@IoTeacher

IoTeacher commented May 4, 2026

Copy link
Copy Markdown
Author
ChatGPT Image May 3, 2026 at 07_55_22 PM

(Ai generated diagram)

@IoTeacher

Copy link
Copy Markdown
Author
Screenshot 2026-05-03 at 7 57 44 p m

@IoTeacher

IoTeacher commented May 4, 2026

Copy link
Copy Markdown
Author
IMG_5798

Accessing the CM5 Terminal with an FTDI Cable

Yes, you can access the Raspberry Pi Compute Module 5 terminal using an FTDI USB-to-TTL serial cable, as long as the adapter uses 3.3 V TTL logic.

⚠️ Do not use 5 V logic on the UART pins.
A 5 V serial signal can damage the CM5 GPIO/UART pins.


FTDI to CM5 UART Wiring

FTDI Cable Pin CM5 / GPIO Header Pin
GND GND
TXD GPIO15 / RXD0
RXD GPIO14 / TXD0
VCC Not connected

Important rule:

FTDI TXD  → CM5 RXD
FTDI RXD  → CM5 TXD
GND       → GND

Usually, you should not connect the FTDI VCC pin, because the CM5 should be powered from its normal power supply.


Serial Configuration

Setting Value
Baud rate 115200
Data bits 8
Parity None
Stop bits 1
Flow control None

This is commonly written as:

115200 8N1

macOS / Linux Access

First, connect the FTDI cable and identify the serial device.

Linux

ls /dev/ttyUSB*

Then connect:

screen /dev/ttyUSB0 115200

macOS

ls /dev/tty.usbserial*
ls /dev/tty.usbmodem*

Then connect:

screen /dev/tty.usbserial-* 115200

Exit screen

To close the serial session:

Ctrl + A
K
Y

Windows Access

Use one of these tools:

Tool Configuration
PuTTY Serial, COM port, 115200
Tera Term Serial, COM port, 115200
MobaXterm Serial session, COM port, 115200

Use:

Baud: 115200
Data: 8
Parity: None
Stop: 1
Flow control: None

Enable Serial Console on Raspberry Pi OS

If the board boots but you do not see a login prompt, enable UART and serial login.

Run:

sudo raspi-config

Go to:

Interface Options → Serial Port

Select:

Login shell over serial: Yes
Serial hardware: Yes

Manual Configuration

Check this file:

sudo nano /boot/firmware/config.txt

Make sure it contains:

enable_uart=1

Then check:

sudo nano /boot/firmware/cmdline.txt

For serial login, it should include something similar to:

console=serial0,115200

⚠️ Keep cmdline.txt as one single line. Do not split it into multiple lines.


Why This Is Useful

FTDI serial access is very useful when:

Problem FTDI Serial Helps?
SSH is broken Yes
Network is down Yes
Wrong Wi-Fi configuration Yes
Damaged .zshrc or shell config Yes
Need boot logs Yes
Need emergency login Yes

Quick Checklist

Check Required
FTDI adapter supports 3.3 V logic Yes
GND connected to GND Yes
FTDI TX connected to CM5 RX Yes
FTDI RX connected to CM5 TX Yes
FTDI VCC disconnected Recommended
Baud rate set to 115200 Yes
Serial console enabled Required for login prompt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment