# How to change signal from 16,7 - 22,1 V to 0 - 3V and clamp for adc

A device that I want to extend and am reverse engineering uses two wires for power, 2-way digital communication and 2-way analog speech (say mainly 50 - 300 Hz). I haven't yet worked out all of the details, but I know that when the speech signal is present there is a DC component of about 19.4V and the range will be roughly between 16,7 - 22,1 V (including a margin). However, at other times there will be 0V - 24V between the two connections (that is the highest I've seen so far, but higher voltages might be possible although not higher than 36V is expected).

I want to record the sound using the ADC of an ESP32. Up to this point I've used a simple voltage divider, and I am already able to see the sound signal but I don't have enough resolution. So I need to create a signal between 0 - 3V. There are two solutions I have thought of:

1. RC high pass filter

This gives a signal between about +/- 2.5V. So I would still need to add an offset to make the entire signal positive, maybe using a voltage divider on 3.3V line of the ESP32?

2. Subtract 19.4V using opamp

I'm new to opamps, but I've found Designing Gain and Offset in Thirty Seconds and that seems to be what I want.

In both cases I need to divide the signal range by about 2 and also clamp the signal to 0 - 3.3V. The lower clamp is easy with a diode, but I don't yet know how to clamp higher voltages and I'm afraid a diode to the ESP32 power rail might damage it (perhaps if I use high value resistors that will be fine?). Perhaps a low-pass filter on the signal lines (~20V) and then a voltage divider to 3.3V and then a diode might work?

I'd prefer a solution that uses fewer and simpler components. It is a hobby project and signal quality is not that important. If there's an IC that does everything that would be best, especially if it can be adjusted digitally. If I need to use opamps are there certain parts that are common? (so I can order a bunch in one go, shipping is probably the biggest cost so better to buy an assortment for future projects). Preferable not too small parts so I can solder wires onto it :)

I understand this is a broad question, but since I am new to these kind of electronics I am mostly looking for a good starting point and some advice from people with practical experience.

• What power supply rails have you got, which you can use for OpAmps? – Nick Alexeev Sep 26 '18 at 20:26
• @NickAlexeev the esp32 board has a 3.3v regulator. Currently I'm powering it from an usb adapter (so 5V), but eventually I'd like to power it by the same line that is carrying the signal. The latter is mostly around ~19v but then I probably also need to convert that to around 5v to use the regulator on the esp32 board. – Herman Sep 26 '18 at 21:42
• 3 resistors and a cap simple enough? – brhans Sep 27 '18 at 1:04
• @brhans please elaborate! Sounds great, I assume that is the rc filter + offset but it would also need clamping to protect the esp32 board, or not? – Herman Sep 27 '18 at 7:16