Overview
The PhysisLab oscilloscope is a dual-channel, high-speed data acquisition system built around the ESP32’s ADC (Analog-to-Digital Converter). It provides real-time voltage measurement and streaming capabilities for visualizing electrical signals in educational and experimental contexts.Circuit Design
Component List
- Microcontroller: ESP32 development board (DevKit V1 or similar)
- ADC Channels: 2x built-in 12-bit ADC inputs (GPIO 34, 35)
- Input Protection:
- Voltage dividers (if measuring > 3.3V)
- Schottky diodes for overvoltage protection (optional but recommended)
- Series resistors (1kΩ) for current limiting
- Power Supply: 5V USB or regulated supply
- Connectors: BNC connectors or terminal blocks for inputs
Pin Assignments
| Function | GPIO Pin | ADC Channel | Max Input Voltage |
|---|---|---|---|
| Channel 1 Input | GPIO 34 | ADC1_CH6 | 3.3V (with 11dB attenuation) |
| Channel 2 Input | GPIO 35 | ADC1_CH7 | 3.3V (with 11dB attenuation) |
Circuit Connections
Input Protection Circuit (Recommended)
For measuring signals > 3.3V, use a voltage divider:Electrical Specifications
ADC Specifications
| Parameter | Value | Notes |
|---|---|---|
| Resolution | 12 bits | 0-4095 digital output |
| ADC Channels | 2 (GPIO 34, 35) | Part of ADC1 unit |
| Maximum Sample Rate | 100-200 samples/second per channel | Limited by Serial/WiFi bandwidth |
| Hardware Sample Rate | Up to 200 kHz | Single-shot mode |
| Input Voltage Range (11dB) | 0V - 3.3V | With attenuation |
| Input Voltage Range (6dB) | 0V - 2.2V | Better linearity |
| Input Voltage Range (2.5dB) | 0V - 1.5V | Better linearity |
| Input Voltage Range (0dB) | 0V - 1.0V | Best linearity |
| Input Impedance | ~50 MΩ | Very high impedance |
| ADC Non-linearity | ±2% FSR | Typical for ESP32 |
Power Requirements
- Operating Voltage: 5V USB (regulated to 3.3V internally)
- Current Consumption (Serial mode): ~80-120mA
- Current Consumption (WiFi mode): ~120-240mA (peaks during transmission)
- Recommended Power Supply: 5V @ 500mA minimum
Timing Specifications
| Mode | Sample Rate | Interval | Notes |
|---|---|---|---|
| Serial Streaming | 200 Hz | 5ms | GENERADOR_OSCILOSCOPIO.ino |
| WiFi Streaming | 100 Hz | 10ms | OSC_GEN.ino |
| Maximum Hardware | 200 kHz | 5μs | Single channel, no streaming |
Firmware Implementation
Serial-Based Oscilloscope
This implementation streams ADC data over USB serial at 200 samples/second:WiFi-Based Oscilloscope with Circular Buffer
For wireless operation, the system uses a circular buffer to handle timing variations:ADC Configuration and Sampling
Resolution Configuration
- 12-bit: 0-4095 (default)
- 11-bit: 0-2047
- 10-bit: 0-1023
- 9-bit: 0-511
Attenuation Settings
| Attenuation | Input Range | Best Use Case |
|---|---|---|
| ADC_0db | 0 - 1.0V | Low voltage, best linearity |
| ADC_2_5db | 0 - 1.5V | Mid-range, good linearity |
| ADC_6db | 0 - 2.2V | Higher voltage, acceptable linearity |
| ADC_11db | 0 - 3.3V | Maximum range, reduced linearity |
Sampling Rate Considerations
- Hardware Limit: ESP32 ADC can sample up to ~200 kHz in single-shot mode
- Streaming Limit: USB Serial bandwidth limits practical rate to ~200 Hz for dual channel
- WiFi Limit: Network latency limits practical rate to ~100 Hz for dual channel
- Accuracy Trade-off: Faster sampling reduces settling time, may decrease accuracy
Input Voltage Range and Protection
Safe Operating Range
- Absolute Maximum: 3.6V (above this may damage ESP32)
- Recommended Maximum: 3.3V with 11dB attenuation
- Minimum Voltage: 0V (GND)
Protection Strategies
- Series Resistor (1kΩ): Limits current in case of overvoltage
- Voltage Divider: Scales down higher voltages to safe range
- Schottky Diode Clamp:
- Capacitive Filter: 100nF cap to GND reduces high-frequency noise
Measurement Range Extensions
For measuring AC signals centered around 1.65V (half of 3.3V):Performance Characteristics
Frequency Response
- DC to ~5 kHz: Excellent accuracy with 200 Hz sampling
- 5 kHz to 20 kHz: Aliasing possible, use higher sample rates
- Above 20 kHz: Requires hardware sampling (no real-time streaming)
Accuracy and Calibration
- Typical Error: ±2% FSR (Full Scale Range)
- Non-linearity: ±2% (especially at extremes with 11dB attenuation)
- Noise Floor: ~10-20 mV RMS
- Calibration: Use known reference voltage for offset/gain correction
Applications
- Waveform Visualization: View AC/DC signals in real-time
- Sensor Data Acquisition: Record analog sensor outputs
- Circuit Debugging: Measure voltages in prototype circuits
- Physics Experiments: Capture transient signals
- Signal Analysis: FFT, frequency measurement, etc.
Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| Reading stuck at 4095 | Input voltage too high | Check input protection, reduce voltage |
| Reading stuck at 0 | No signal or bad connection | Verify wiring, check ground |
| Noisy readings | Poor grounding or interference | Add 100nF filter cap, improve ground |
| WiFi not working | Using ADC2 pins | Use only GPIO 34/35 (ADC1) |
| Low sample rate | Baud rate too low | Increase to 115200 or use WiFi |
| Non-linear response | Wrong attenuation | Use lower attenuation for better linearity |
Source Code Location
Complete oscilloscope firmware implementations:source/osciloscopioygeneradordeSeñales/Serial/GENERADOR_OSCILOSCOPIO/GENERADOR_OSCILOSCOPIO.ino(Serial version)source/osciloscopioygeneradordeSeñales/websocket/OSC_GEN/OSC_GEN.ino(WiFi version with circular buffer)