Currently I use the ADC of the ESP32 (with a 150ohm resistor instead of 250), but it's not giving me the accuracy I need. Therefore I got some ADS1115 modules that I will use to get more accuracy.
The 4-20mA loop has been working for almost 2 years now without issue but would it hurt to add some overvoltage protection to the circuit? Is it worth it? I was thinking of protecting the ADC module analog input with Schottky diodes so that Ain can't be greater than VCC + 0.3. If somehow the ADS1115 is fried because it's exposed to the 24 VDC, what can I expect on the I2C lines connected to the microcontroller? Should I also protect these lines?
Example of how I can protect the analog input lines of the ADC:
I will take a SWAG and would simply add a 10K or maybe a bit less in series with the analog input. The protection diodes will protect you for a lot of fault voltage. For 20 mA out you will be inputting 200V and dissipating about 4 watts on that resistor.
Sense resistor (of appropriate value) to sense the current.
Then indeed an additional resistor between the sense point (A/D Converter in your drawing) and the ADC, and if you want to be really sure the BAT54S like in the second schematic. That 100-1000Ω as suggested there is on the low end, though. Go for 10k. Even if exposed to 24V (sense resistor disconnected) you'd get just 2.4 mA, which the protection diodes of the ADS1115 can probably handle just fine.
You may go for a larger value resistor but do check the input impedance of the ADS1115, you want to be at least 100x smaller (1% of the value) with your series resistor. This chip's input impedance is low, for input standards. Also if it is too high, the ADS1115 may not be able to read the voltage well.
Accuracy. The resolution I need is quite low actually. 4-20mA is linear to 0-25 inWC. A 12bit ADC gives a resolution of 0.8mV which corresponds to a resolution of 0.005mA. Of course the resistor adds uncertainty to the accuracy but that's not a big issue if one uses 1% tolerance resistors and measuring them. 0.005mA resolution would give aprox 0.0078 inWC resolution. My application requires to use the values in multiples of 1/4 inWC so even an 8bit ADC would be adequate.
The reason for using the ADS1115 is because the ADC from the ESP sucks, it's very susceptible to noise and even though there are ways to kind of get it work nice, I prefer to save up the GPIOs and use an external ADC.
Attached is a graph of the pressure values, I know they don't fluctuate 1/4" of an inch every half a minute when using an analog meter, so the ADC inaccuracy is at fault.
I didn't quite get where to place the additional resistor? A/D converter in the drawing is the ADC input. If I add the 10k resistor in series before the sense point, the impedance of the current loop would be quite high (inputting about 200V and 4 watts on that resistor as gilshultz said).
Between the top of your 150 ohm resistor and your analog input. Placed thusly, when the 150 ohm is removed, the input is fed from 20+ volts, but the current into the pin is limited. As was described.
Not needed to add external Schottky diodes.
The ADS1115 already has 10mA clamping diodes built-in.
A 100 ohm shunt, and PGA_2 (2.048volt) is commonly used to measure 4-20mA sensors.
A protection resistor between shunt and analogue input is recommended, and maybe a 100n cap between ADS input and ground. Minimum resistor value (for 10mA) is 2k2. I would use 4k7.
Leo..