Try   HackMD

Can Raspberry Pi Read Analog Sensors?
No, the standard Raspberry Pi does not have a built-in ADC (Analog-to-Digital Converter), so it cannot directly read analog sensor signals (e.g., from potentiometers, thermistors, or analog temperature sensors like LM35).

Why?
Raspberry Pi’s GPIO pins are digital-only—they can read just HIGH (1) or LOW (0) voltage levels. Analog signals, which vary continuously (e.g., 0–3.3V), need to be converted to digital values using an external ADC.

Raspberry-Pi-Analog-Input

How to Read Analog Sensors on Raspberry Pi
You need an external ADC chip or module connected via SPI or I2C. Popular options:

企业微信截图_20250715170605

Example Setup: MCP3008 + Raspberry Pi

  1. Connect MCP3008 via SPI (MISO, MOSI, CLK, CE).
  2. Connect analog sensor to one of MCP3008’s channels.
  3. Use a Python library like spidev to read values:
python

import spidev

spi = spidev.SpiDev()
spi.open(0, 0)  # Bus 0, Device 0 (CE0)

def read_adc(channel):
    adc = spi.xfer2([1, (8 + channel) << 4, 0])
    value = ((adc[1] & 3) << 8) + adc[2]
    return value

print("Analog value:", read_adc(0))

Summary

企业微信截图_20250715170713