Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+1 −1
Q&A Measuring the peak voltage of a 1 kHz PWM/square wave using ESP32 ADC without peak detector

I need to measure the positive peak of a 1 kHz PWM/square wave using an ESP32 ADC. The waveform has variable duty cycle; the minimum positive pulse width is about 100 µs. After scaling, the ADC in...

1 answer  ·  posted 2mo ago by newbie‭  ·  last activity 2mo ago by Olin Lathrop‭

Question ADC
#1: Initial revision by user avatar newbie‭ · 2026-07-08T17:23:48Z (2 months ago)
Measuring the peak voltage of a 1 kHz PWM/square wave using ESP32 ADC without peak detector
I need to measure the positive peak of a 1 kHz PWM/square wave using an ESP32 ADC. The waveform has variable duty cycle; the minimum positive pulse width is about 100 µs.

After scaling, the ADC input positive levels are approximately 2.2 V, 1.65 V, 0.68 V, and 0.30 V.

I only need to classify these levels, not measure with high precision. Can I sample the ADC at 20–50 kHz and take the maximum value over several PWM cycles, or should I convert the waveform to DC using a peak detector/sample-hold before the ADC?

I want to avoid unnecessary analog peak-detection hardware if firmware-based sampling is reliable enough.
ADC