Signals and ADC
Analog vs Digital
| Property | Analog | Digital |
|---|---|---|
| Values | Continuous (infinite range) | Discrete (finite steps) |
| Examples | Temperature, sound, light intensity | Binary data, GPIO logic levels |
| Noise sensitivity | High | Low |
| Processing | Complex | Simple (binary) |
ADC (Analog-to-Digital Conversion)
Process of converting a continuous analog signal to a discrete digital value.
Steps:
- Sampling — measure analog value at fixed time intervals
- Quantization — map each sample to nearest discrete level
- Encoding — represent level as binary number
Sampling Rate
| Term | Formula | Meaning |
|---|---|---|
| Sampling rate | fs = 1/T (Hz) | How many samples per second |
| Sampling period | T = 1/fs (seconds) | Time between samples |
Example: T = 10 ms → fs = 1/0.010 = 100 Hz
Bit Resolution
Determines number of discrete values the ADC can represent.
| Bits | Values (2^n) | Example |
|---|---|---|
| 1 | 2 | On/off |
| 4 | 16 | |
| 8 | 256 | Standard audio |
| 12 | 4096 | Grove Base Hat ADC |
| 16 | 65,536 | CD 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
- ADC concept
- GPIO and reTerminal topic
- Electronics and Circuitry topic
- signals-digital-and-analog source