I’m interested in building up an ESPHome device which can monitor two water pressure sensors. I have both sensors and an ADS1115 on the way. The water pressure sensors are just like these from amazon. I’ve been doing research on how to wire the thing up and I’ve seen people say don’t supply 5V to the ADS1115 but I don’t fully understand why.
This is obviously without the ADS1115 (I haven’t received it in the mail yet):
The pressure sensor is 5V so it’s output will range from 0.5V to 4.5V, I’m not sure I want to voltage divide it down because it seems that might cause me to lose some resolution. Is that the best way to do it? I was thinking I could just supply 5V to the ADS1115 and then use the whole 0.5V-4.5V range of the sensor. I’m having a very hard time finding any examples of this kind of thing done with ESPHome…
While the supply to the ADC is rated for 5V you do not want the I2C digital outputs going above 3.3V for compatibility with your ESP digital inputs.
You are required to run the pressure sensor at 5v. So you will either need a voltage divider before the ADC analogue input, ensuring your pressure sensor signal never goes above 3.3v, or digital level shifters between the ADC and ESP I2C pins. The second option is best as you don’t lose any resolution.
Thanks @tom_l, any suggestions between using high and low impedance resistors for the resistor divider? I measured the impedance of the sensor output and it comes in around 380kΩ.
I was thinking that if VS is 5V, I can make R1 1kΩ and R2 2kΩ, then the output voltage will be 3.33V… then I looked at my stock and I have:
330Ω
560Ω
10kΩ
30kΩ
So, right now I could create R1=330Ω, R2=560Ω where VOUT[max]=3.14V. Otherwise, it seems that I’ll have to order new resistors. Doesn’t seem like a good idea to put such a low resistance on the output of this sensor because it’ll pull it down the voltage. Any suggestions on a best approach for the divider?
Maybe I should just bite the bullet and go for the digital level shifter…
I usually go with 10 to 100x the source resistance to prevent loading effects. But you will also have to take into account the max resistance the ADC sees. The higher it goes the longer the settling time.
If you use an ESP32 you should look into the attenuation feature, then you can use an ADC input voltage up to VDD_A (3.9VDC) with an 11dB attenuation setting.
I ended up ordering a bunch more resistors and some digital level shifters too so I can play around with them all and see what I like. I’m guessing I’m going to want to use the level shifter since it enhances the resolution as well.
8bits gives you 255 levels. Which is about 13mV step resolution for a full scale of 3.3V. Easily do-able.
16 bits gives you 65,535 levels. Which is 50uV step resolution for a full scale of 3.3V. Without some very careful circuit design there’s going to be quite a few least significant bits lost in noise.
Hi Spikey, Im Also trying to use a 5v Pressure Transducer with the ESPhome ADC, Do you mind supplying your config for the pressure transducer? Ive been having trouble trying to calibrate the sensor with the 3.3V of the node and the resolution. I had the sensor working with a 5v uno, but converting to esphome yaml and lambdas im struggling with and cant find much info on it. Any help would be great
Hi nickrout. Well im having 2 issues, Firstly with using the 5V sensor im having trouble getting a correct reading i believe. i havent tested the switch under pressure yet. just at atmospheric pressure but my voltage reading seemed quite off. i think it was 0.8v or 0.08v. i will have to confirm but i dont have the sensor with me at this time, but also that may be a circuit issue as i was trying to use a 2k pot before the A0 pin.
So with using a Nodemcu would i need to drop the signal 0.5-4.5V to 0-3.3v? and if the pressure is very low do i need to drop the signal voltage to get a correct reading, or does this only affect if the the signal voltage and node if the pressure voltage exceeds 3.3v
This is the config i have been using to read the sensor, but now struggling to go further with how i take the analog reading for resolution
sensor:
- platform: adc
pin: A0
name: "Water Pressure"
id: 'WaterPressure'
filters:
- offset: 0.5
- lambda: return x * 3.3 / 1024 #not sure if this should be the supply voltage of 5v or 3.3V
update_interval: 1s
Thanks, i appreciate any help or if someone could point me in the right direction, unfortunately there is not much on using pressure sensors with esphome that i can find, and the esphome site i really struggle to understand sometimes
Hey @R3plic8, take a look at this solution: Water filter quality and water softener status there’s a code block in there that contains the calibration values for both sensors. I calculated them against my fixed hardware 175psi pressure gauge. I don’t know if they’re all that accurate but they are ABSOLUTELY precise!
If you’re going to use the sensor(s) with any precision I recommend you calibrated it/them against something else. I performed my calibration (pedantically) by pressurizing them all together and letting out a little water between each measurement. Took data on every 5psi of change and gathered 20-30 measurements from each sensor then averaged those and used a quadratic fit from ESPHome. The results are more precise than I could have hoped for.
One thing you need to bear in mind is that an esp8266 will only read between 0-1v - see from the esphome adc page
This component prints the voltage as seen by the chip pin. On the ESP8266, this is always 0.0V to 1.0V Some development boards like the Wemos D1 mini include external voltage divider circuitry to scale down a 3.3V input signal to the chip-internal 1.0V. If your board has this circuitry, add a multiply filter to get correct values:
Hi spikey. Thanks alot for the info. I did come across your code in another thread as well from you earlier th is month. The sensor is actually in the system and the moment and running from arduino with solenoids and pumps. So I will have to test again later today when I can get the chance. I do also have a pressure Gauge in the system that I would be able to compare pressures with. Thanks again
Hi nick rout. I do understand the esp8266 chip will use 0-1 volt. But with the dev board having a 100 and 220 ohm resistor on a0 pin. Is it not capable of receiving 3.3v? Edit. Apologies I read that wrong. So I would still need to add the multiplier even though it’s supplying 3.3v but only reading 0-1 on the chip