Signals and ADC

Analog vs Digital

PropertyAnalogDigital
ValuesContinuous (infinite range)Discrete (finite steps)
ExamplesTemperature, sound, light intensityBinary data, GPIO logic levels
Noise sensitivityHighLow
ProcessingComplexSimple (binary)

ADC (Analog-to-Digital Conversion)

Process of converting a continuous analog signal to a discrete digital value.

Steps:

  1. Sampling — measure analog value at fixed time intervals
  2. Quantization — map each sample to nearest discrete level
  3. Encoding — represent level as binary number

Sampling Rate

TermFormulaMeaning
Sampling ratefs = 1/T (Hz)How many samples per second
Sampling periodT = 1/fs (seconds)Time between samples

Example: T = 10 msfs = 1/0.010 = 100 Hz

Bit Resolution

Determines number of discrete values the ADC can represent.

BitsValues (2^n)Example
12On/off
416
8256Standard audio
124096Grove Base Hat ADC
1665,536CD audio

More bits = finer granularity = more accurate reading.

Bitrate

Example: 44,100 Hz × 16 bits = 705,600 bits/second (CD audio)

Key Fact: Raspberry Pi Has NO Native ADC

The Raspberry Pi does NOT have a built-in ADC. All GPIO pins are digital only.

To read analog sensors, use the Grove Base Hat:

  • 4 analog channels
  • 12-bit resolution → values 0–4095
  • Connected via 40-pin GPIO header (HAT = Hardware Attached on Top)

Grove Hat Analog Reading (Python)

import time
from grove.adc import ADC
 
adc = ADC()
channel = 0   # A0 connector
 
while True:
    value = adc.read(channel)   # 0–4095
    voltage = adc.read_voltage(channel)  # 0–3.3V
    print(f"ADC: {value}, Voltage: {voltage}V")
    time.sleep(1)

See Also