I’d like to monitor the pressure in my air compressor lines. The pressure can get up to 175PSI. Does anyone know of an inline (3/4" NPT or bigger) pressure sensor that integrates with HA?
While not a direct answer to your question, this is how I monitor my air compressor via Home Assistant:
The sensors are just 0-200 PSI analog sensors with a 1/8" NPT connection. Use a bushing to get up to 3/4".
Thanks, @AaronCake. That’s a cool setup!
It looks like you are using Arduino for the code, do you know if something like ESPhome can be used? Would I be able to use their basic sensor component?
Can you explain this a little more?
Each sensor connects to an analog pin, with a 0.1uF capacitor bypassing to ground.
It looks like the sensor has 3 wires, so I would just wire it to something like a D1 Mini with one wire to gnd, one wire to 3.3v, and one wire to a GPIO input pin?
Yes, I used an Arduino with built in W5100 Ethernet because of the 5V logic, I prefer the reliability of Ethernet for fixed position devices, and power via PoE. You can use an ESP8266 device and ESPhome keeping the following in mind…
ESP8266s are 3.3V, and I believe the ADC port is something like ~1.8V maximum. So you need to drop the voltage output from this 5V sensor down to either a max of 3.3V or 1.8V, depending on your ESP8266 board (some have built in voltage dividers, some do not). A voltage divider of a 10K “top” and 15K “bottom” resistor will do the job for 3.3V (giving a maximum output of 3V). For 1.8V, 11K and 6.2K. Use 1% resistors. The sensor needs to be powered by 5V.
The ESP8266 has only one analog input, so you need to connect the sensor to +5V and ground. Then the signal wire through your voltage divider to pin A0. The NoteMCU accepts 0-3.2V on the analog pin. Not sure about the Mini. You’re going to want to put a capacitor from the signal connection to ground. Anything around 0.1uF will work. Depending on your noise level, you might need more filtering.
I ordered one of the pressure sensors you linked to so I can tinker with it. I think I’ll use a ESP32 board, according to ESPhome they can read up to 3.9v.
The sensor info says that it will send a 0.5v signal at 0psi, 2.5v at 100 psi, and 4.5v at 200 psi. My compressor doesn’t go over 160psi, which would be about 3.7v sent from the sensor, so the ESP32 board should be able to handle it, correct?
I’m guessing my ESPhome code would be something like this (I’m calculating that a 1.0v increase is equal to 50 PSI and the sensor starts at 0.5v when the PSI is 0)
sensor:
- platform: adc
pin: A0
name: "Air Compressor Pressure"
update_interval: 5s
attenuation: 11db
filters:
- lambda: return (x - 0.5) * 50;
The ESP32 board VIN pin will supposedly output 5v, so I planned on using that to power the sensor. Since the board will accept up to 3.9v on the input pin, and I will never have enough pressure to go over that voltage, can I skip the voltage dividers and resistors that you mention in your second paragraph?
Do I use the capacitor to connect the gnd and the input like this?
Thanks!
In my experience the ESP8266 pins are fairly tolerant to 5V. However it is possible for your sensor to spike up to the max 4.5V output due to vibration, shock to the sensor element, etc. Best to use a voltage divider to bring the maximum voltage down to a level safe for the ESP8266 analog input.
As long as you are powering the ESP8266 board with 5V, then you can use that 5V to run the sensor, no problem. The VIN pin will do this as you suggest.
Yes, your diagram is correct.
Keep the sensor wire lengths as short as possible. Depending on where it is located, you may find it is picking up a lot of noise. If that is the case then a more robust filter might be necessary.
Can’t help much on the ESPHome code as I’ve never used ESPHome.
Thanks for the help!
One more clarification, if you don’t mind. According to this calculator, I would need a 5ohm resistor for R1 and 10ohm for R2 in order to get from a 4.5v input to a 3v input on the ADC pin. If that is the case, would this be my wiring schematic?
@bphillips921, I am wondering what you plan on doing with this ‘shop air’ sensor?
Regarding the schematic… looks good but usually the cap would go between the sensor pin and ground.
Thanks, Truglodite.
I’m building a new house and putting my air compressor in my “under-garage” (use concrete pre-cast to put a garage under the garage). I’m going to run compressed air pipe up to the main garage as well as a few other places (like an irrigation blowout). I’m going to use a electric valve to shut the air supply off at the compressor when not in use, that will prevent the inevitable small leaks in the pipes from draining the tank. I want a pressure sensor on either side of the valve so I can see my tank pressure and my line pressure while I’m in the garage (I’ll have a wall tablet in the garage). I can also monitor the line pressure history when the valve is closed to spot any potential leaks in the pipe. I’m also envisioning an automated irrigation blowout process, I’d need to monitor the pressure being supplied to the irrigation pipes and pause the blowout if the pressure drops below a certain point in order to let the compressor catch up.
I also just like to tinker
Those resistor values are much too low. They will load down the sensor far too much either damaging it or reducing the voltage output. Not entirely sure why that calculator gave those values unless it assumed much more current than the few microamps actually passed. The divider isn’t quite wired right. See the diagram below (please excuse the crudity of this model…I did not have time to paint it or make it to scale).
It sounds like we are doing very similar things. My compressor is located in a creepy hot tub room attached to my shop, within a sound attenuating cabinet. Plumbed into the shop air system. As soon as I have time to dig I’ll be running an air pipe into the house. The plan is to switch the compressor with a large solid state relay and the monitoring was the first step (especially being able to determine whether the compressor is on or off…should never be on if I’m not home). Then obviously, it won’t be necessary to go into the shop to turn the compressor on when I need air in the house (drying dishes, etc.).
Honestly, I think your valve scenario is creating a problem to solve another. If you are concerned about your air pipe leaking, just make sure they don’t leak. I have an air system of copper pipe around the entirety of the interior of the shop and one run to the exterior of the shop. Any leaks are coming from the compressor itself: regulator, purge solenoid, check valve not fully closing, filter drains, etc. Chase those down and the receiver should hold pressure forever…Well, almost forever because then you are chasing diffusion through the connecting hose! Very much helps to put a ball valve at every air outlet in case you leave a tool connected that leaks.
Thanks for the schematic! I’ll see if I can get it to work when I get the sensor.
I’m planning on using this RapidAir 3/4 Maxline for my piping. I’m putting this in during the construction phase so I need to use purpose built material in order to pass inspection. I don’t think copper will fly for compressed air use. I’ll do my best to seal it up good, but the nature of the beast when you have 30+ joints is you will have some slow leaks. If I put a valve right after the compressor then I only need to worry about the compressor leaks. I do like your idea about a small valve on each output in case I have a leaky tool plugged in.
Huge thank you to @AaronCake for the help. I got this to work perfectly! Here’s how I end up doing it, in case any one else wants to do this.
I used this ESP32 board and this pressure sensor (1/8 NPT threads with a 0-200psi range).
I used the wiring diagram from post 11, using the 10K 1% and 15K 1% resistors and a 0.1uF capacitor. I still need to clean my wiring up.
Here is my ESPhome code
esphome:
name: air_compressor_pressure
platform: ESP32
board: nodemcu-32s
wifi:
ssid: "Too Fly For My WiFi"
password: "xxxxxxxxx"
#Static IP
manual_ip:
static_ip: 192.168.1.40
gateway: 192.168.1.1
subnet: 255.255.255.0
#Turn Off Power Save Mode
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Air_Compressor_Pressure"
password: "xxxxxxxxxx"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
- platform: adc
pin: GPIO32
name: "Air Pressure"
attenuation: 11db
update_interval: 5s
unit_of_measurement: "PSI"
accuracy_decimals: 1
filters:
- sliding_window_moving_average:
window_size: 3
send_every: 1
- lambda: return (x - 0.1866) * 71.73;
Pin locations for wires (also see the resistor and capacitor placement on post 11 above):
Red sensor wire (+) -> VIN
Black sensor wire (-) -> GND
Green sensor wire (signal) -> GPIO32
Here is the final result!
Woo hoo! Glad you got it working.
Funny you were able to get the gauge working with PSI as the unit of measurement. When I did that, the gauge card complained it wasn’t numeric so I had to remove “PSI”.