v1.9.5 - ADC Millivolt Conversion Support (2025-11-28)¶
What Changed?¶
This release adds optional hardware calibration-based ADC to millivolt conversion using ESP32's analogReadMilliVolts() function. Users can now output both raw ADC values (0-4095) and converted millivolt values (0-3300mV) for accurate voltage measurements. The feature is compile-time optional with zero overhead when disabled.
What's New¶
Main Feature: ENABLE_ADCMV Flag for Dual ADC Output¶
What it does:
Adds a compile-time flag (ENABLE_ADCMV) that enables hardware calibration-based ADC to millivolt conversion. When enabled, detection events include both adc_raw (raw 12-bit ADC value) and adc_mv (converted millivolt value using ESP32's built-in calibration table).
How to use it:
Development environment (enabled by default):
task dev:build # ENABLE_ADCMV=1 enabled
Production with dual ADC output:
PLATFORMIO_BUILD_FLAGS="-DENABLE_ADCMV=1" pio run -e esp32dev-release
Production default (single ADC value):
pio run -e esp32dev-release # ENABLE_ADCMV=0 (no overhead)
Code example:
// In config.h - compile-time flag (default: disabled)
#ifndef ENABLE_ADCMV
#define ENABLE_ADCMV 0 // 1=enabled, 0=disabled (default)
#endif
// In sensor_data.h - conditional fields
#if ENABLE_ADCMV
uint16_t adc_raw; // Raw ADC value (0-4095)
uint16_t adc_mv; // Converted millivolts (0-3300)
#endif
// In main.cpp - reading dual values
#if ENABLE_ADCMV
int adc_raw = analogRead(ADC_INPUT_PIN);
int adc_mv = analogReadMilliVolts(ADC_INPUT_PIN);
#endif
Output Examples:
SSV Format (ENABLE_ADCMV=1):
95 87 91 0 1234 1580 25.35 1013.25 45.67
↑ ↑ ↑
adc_raw adc_mv
JSONL Format (ENABLE_ADCMV=1):
{"type":"data","signal1":95,"signal2":87,"signal3":91,"adc":0,"adc_raw":1234,"adc_mv":1580,"tmp_c":25.35}
Installation¶
Quick Start¶
# Get the release
git checkout v1.9.5
# Build with default settings
task build
# Upload
task upload
# Check it works
task monitor
# Or build with dual ADC output enabled
PLATFORMIO_BUILD_FLAGS="-DENABLE_ADCMV=1" task build
What's Different from the Last Version?¶
✅ Added¶
ENABLE_ADCMVcompile-time flag for hardware calibration-based ADC to millivolt conversion (v1.9.5)adc_rawfield: Raw ADC reading (0-4095) when ENABLE_ADCMV=1adc_mvfield: Converted millivolt value (0-3300) when ENABLE_ADCMV=1- Documentation section for ADC fields in stream-format.md
- Build example in CLAUDE.md for ENABLE_ADCMV configuration
🔧 Changed¶
- Updated sensor_formatter.cpp to support optional ADC millivolt fields across all formats (SSV, TSV, CSV, JSONL)
- Extended sensor_data_t structure with conditional ADC fields
- platformio.ini: Enabled ENABLE_ADCMV=1 in development environment
🐛 Fixed¶
- No bug fixes in this release
Is It Safe to Upgrade?¶
Backward Compatible: Yes
- The original
sensorValuefield is preserved for backward compatibility - New
adc_rawandadc_mvfields are only included when ENABLE_ADCMV=1 (default: disabled) - Existing downstream consumers will continue to work unchanged
- Zero runtime overhead when ENABLE_ADCMV=0 (compile-time elimination)
Tests Passed¶
- ✅ Builds without errors (ENABLE_ADCMV=0 default)
- ✅ Builds successfully with ENABLE_ADCMV=1 enabled
- ✅ Memory usage verified: Flash 24.1% (default), Flash 23.3% with ENABLE_ADCMV=1
- ✅ All output formats (SSV, TSV, CSV, JSONL) support new fields
- ✅ Conditional compilation works correctly (zero overhead when disabled)
- ✅ All pre-existing ArduinoJson deprecation warnings remain (pre-v1.9.5)
Release Details¶
- Date: 2025-11-28
- Version: v1.9.5
- Files Changed: 7
- include/config.h
- include/sensor_data.h
- src/main.cpp
- src/sensor_formatter.cpp
- docs/develop/stream-format.md
- CLAUDE.md
- platformio.ini
- Commits:
- 525246b: feat(adc): add ENABLE_ADCMV flag for dual ADC raw and millivolt output
- 31ff37a: docs(progress): add entry for ENABLE_ADCMV feature implementation
Next Steps¶
- Gather user feedback on ADC field ordering and placement
- Consider adding text protocol commands for ADC-specific queries (GET_ADC_RAW, GET_ADC_MV)
- Evaluate potential multi-channel ADC support if hardware upgrades are planned
- Monitor production deployments for voltage measurement accuracy feedback