Pressure transducer in BruControl (ESP32 ADC)
New to BC and cannot understand how to integrate a pressure transducer into BruControl given device settings and after reading manual. Understanding the following will help me integrate future analog (ADC) sensors...
1. Do I select analog or digital input if the transducer is running through ESP32 analog to digital converter pin (ADC)?
2. What is the best approach to performing the pressure / voltage calculation in BruControl? I have this calibrated in a sketch on the arduino for testing but not sure how to integrate into Brucontrol given its calculation. Is this a case to create a script in BruControl in order to perform the calculation (see below)?
Some additional context:
- Transducer is a 5v sensor; however, the ADC can only read 0-3.3V. I setup a voltage divider which enables 5v input into the transducer and 3.3v output into the ADC pin at max PSI. (e.g. 100PSI = 3.3v). Also calculated respective min/max voltage proportions @ 3.3v values (given the transducer documentation provided min/max values for 0-5v ADC pins)
- Based on the input voltage, the following calculation needs to occur:
pressureValue = ((pressureValue1-pressureZero)*pressuretransducermaxPSI)/(pressureMax-pressureZero); //conversion equation to convert analog reading to psi
Variables for equation above:
const int pressureZero = 360; //analog reading of pressure transducer at 0psi -- this is 360/4096 counts; therefore, ~0.09V at 0PSI
const int pressureMax = 4096; //analog reading of pressure transducer at 100psi -- therefore 4096/4096 = 3.3v and 100PSI
const int pressuretransducermaxPSI = 100; //psi value of transducer being used - 0-100PSI
float pressureValue1 = 0; // used for Arduino analogRead
Sorry... this post somehow got caught in the SPAM folder. Did you solve the above?
@sensei247 I'm curious to see how this works out. I just bought a 30PSI sensor for my fermenter, and yeah, it's a 5v output for a 3.3V ADC on my ESP32, so I need to do some research on volt dividers. Looks like a 2k2 resistor and a 1k1 resistor are in order. I have the math aspect figured out for BC, but it won't mean much until I can get the voltage right...
I was all excited to have it all functioning until I saw that ~20psi in my keg was equaling more than the PSI sensor should register, and then it clicked...
Any insight on this @pbruno3?
Ah, I see the schematic for the MEGA analog sensor setup. Will dig into that more
Alright, I think I've settled on a 10ohm/20ohm resistor voltage divider. This should keep the wattage low (.625) and let me scale the voltage proportionally. I'm already making the tweaks on the pressure sensor spreadsheet and finding the scaling is good to a hundredths, so I can work with this...maybe...
If I get something working and the numbers seemin good(ish), I can send an analog gas pressure sensor spreadsheet for sharing if interested (maybeI can just make a tab on the current analog pressure sensor spreadsheet?).
Since the ESP32 ADC is 12bit, do I need to change the Initial Interface formula in the spreadsheet to be divided by 4095? Or is 1023 still gonna be the value based on the BC ESP32 firmware? I note that when I had the sensor connected before (yeah...with 4.5v running into the 3.3v...), 102 was the 0PSI initial, which matches the 1023 divisor in the spreadsheet.
I think 10 and 20, summing 30 are too low and may overload the sensor output. 1/2k or 2.2/3.3k make more sense to limit the current out of the sensor.
When the output of the sensor is maxed, you will see a raw value in BC (prior to calibration) of 1023. Therefore, this will become your divisor to get to the calibration you want.
Ah, yes, reading more on the level of ohms now. Thanks!
And perfect. Thank you for the input and support. Playing with BC and its capabilities makes me regret taking Radio Shack for granted. I am learning a lot through this!
Thank you for your help, @pbruno3! I got the resistors, connected the 1k/2k accordingly, and played with the numbers until I got the sensor to give me what my CO2 tank regulator showed as the keg's pressure (thank goodness for 1.75gal kegs so I don't have to load a 5gal with 30psi several times!).
I am adding this here in case anyone is using a pressure sensor and is looking at how to find the numbers for BruControl.
Realizing that a cheapo sensor + cheapo resistors is not reliable for precision, as well as realizing the analog pressure sensor spreadsheet would not get me to what I wanted as-is (especially since the math can't give me 0psi with a depressurized keg), I decided to do the following to find the right multiplier and offset:
1) I connected the wired system to a depressurized keg then looked the interface initial; 52 was my stable minimum.
2) I took out my voltage meter, touched the black to GND, then touched the red to the post-resistor signal line. This said my post-resistor signal was 0.308v, which tells me that is my minimum voltage with the resistors. I was expecting .3v, so this was pretty good
3) I pressurized the keg to 30psi based on my CO2 tank (released and added gas to make sure the regulator stabilized consistently with 30psi). My stable interface initial averaged at 830.
4) I measured the voltage at this point, giving me 2.95v (I expected 3v) and telling me this was my ideal max (@30psi, which _should_ be the psi limit of the sensor, buuuuuut...cheapo sensor).
5) I put my numbers into a spreadsheet, with columns for min/max voltages, min/max interface readings, min/max ideal psi readings (0 and 30psi), and min/max BruControl psi readings (based on the multiplier I made: [difference between ideal psi readings]/[difference between interface initials]). My multiplier was 0.03856.
6) I measured again at 30psi, noting BruControl's PSI readings based purely on the multiplier (31.7). I found that an offset of -1.7 worked well enough to show what the psi readings _should_ be. At what should be 0psi, it is off. But when I added 4psi, 14psi, and 30psi, BruControl's readings (post offset) was pretty accurate (some variance in the decimal, but I doubt I'll be able to get around that).
If something seems off with this methodology, or if there is a better way to make this happen, please let know. Otherwise, this works in a "controlled" condition for me. Once I get my pressure fermenters ready to go, I'll play with the numbers again with liquid at stable temperatures.
As an update to this, I added a capacitor after the 2nd resistor to help with the constant scattering of initial values (typically within a range of +/- 3 from a mid value). I linked the signal and the neutral/ground. I tried with 0.1uF, 0.22uF, and 0.33uF. I started with 0.1uF based on another site's advice on reducing signal noise. From watching the values jump in the device's settings in BC, it seems like .33uF keeps the values fairly consistent, with a +/- 2 from a mid value with only occasional jumps to +/-3; far less jumps than without a capacitor and less jumps with the 0.1uF and 0.22uF capacitors.
If anyone thinks that a higher uF capacitor will help more, I welcome feedback; otherwise, if you are going my route, this is what I have found success with so far.
Higher values would probably help... like a 10uF. That said, multiple values in parallel might help even more, depending on the noise frequency.
@pbruno3 Thanks! Turns out my 300-piece set has a 10uF, so I will try that. I saw 22uF on your schematic, but that was for a 5v Arduino setup, without resistors so wasn't sure what effect the voltage divider would have with this, so I followed that other site. I'll report back on the effect 10uF has in my value jumps.
Having this pressure sensor on my current cold-crashed and carbonating saison is wonderful. I can watch for sudden drops to indicate leaks or for steady declines and flattening curves to indicate proper carbonation of the beer! I highly recommend this project with BC.
This setup is currently connected to a Fermzilla All-Rounder 35L. My engineer friend wants to come help with the soldering so I can finally have it ready for regular use 🙂
Update on this build: I have the fermenter PSI sensor proplerly connected to a length of wire thanks to my engineer neighbor. The resistors and capacitor are properly connected at my XLR male and female connections and protected from my stupidity.
Now, I am fighting leaks, but yellow Teflon seems to be helping that now. That said, I am watching the data explorer closely to find signs of leaks and I note that about every 9.5-10.5 hours, I have a sudden signal drop (between .4 to .7 PSI) that then climbs back up to the measured PSI over 10 seconds. The sensor is powered through a 110V --> 12V converter --> 5V USB converter, so only the signal line is connected to one of my ESP32's ADC interfaces. Any idea what may cause this? It's not an issue since my solenoid will release pressure if a PSI level is reached, but now me and my neighbor are curious what the cause would be.
Separately, data explorer makes hunting for leaks so nice. The graphs are good, but the data explorer is really nice for zooming in and gauging where the leak problem may lie (slow declines have been thanks to bad teflon work that aren't easily revealed via a soapy water bubbles test, and big leaks have been due to bad o rings or disconnect connection).