Hi There,
Need help in getting code for my PH sensor. Managed to work out DHT sensors Dallas 1-wire sensor and UltraSonic Sensor. But struggling to get the DFRobot PH sensor going. Found this code but getting junk result, the values don’t change. Either my sensor is faulty or more likely I’m using the wrong code. Can someone point me in the right direction.
Much Appreciated…
I have made the updates as requested… By the looks of the constructive criticism so far. The code I copied might not be that far off…
So I have also ordered another ph sensor, just in case the one I’m using is faulty. If not at the very least I have a spare…
I thought this request would be a common project. Not asking for someone to re-invent the wheel. Just hoped that their would be someone that has already completed a similar project and help out a well intention noob.
The sample code multiplies the voltage by 3.5 and adds a calibration offset.
pHValue = 3.5*voltage+Offset;
Your code OTOH seems to have a negative slope
- calibrate_linear:
- 0.59 -> 7.0
- 0.71 -> 4.0
ie as voltage rises, the pH falls.
I can’t see where the specs of what voltage maps to what pH, other than the sample code. I am also aware that the ADC voltage range of an arduino is possibly different to an esp32.
Found variety of problems. For those newbies that need some help. My main problem was that the output values of PH Sensor was to high. Needed a resistor 4.7K to pull down the voltage. I basically followed this dude. But removed the POT and replaced with resistor. As I believe over time it would give me problems…
The nodeMCU ADC input is restricted to 1Volt. However the DFrobot output max is Vcc. Use a voltage divider to translate the Vcc to 1 Volt.
Also the pH sensor requires temperature compensation. Keep this in mind for refined calibration.
I have to say that I have found the DF robot pH sensor output to jump around quite a bit. So I have also introduced an averaging window.
The sensor is made for an Arduino. It needs 5v power, the voltage output from the sensor ranges from 0-4.5v. An esp can only read 0-3.2v. You can use 2 resistors as a voltage divider to bring the signal from the sensor down to 0-3.3v range.
A very crude example, green/black is ground, red is 5v, purple/yellow back to the esp. R2 resistor (above) on the left.
I have their water pressure sensor. It’s rated to 232 psi it maxes @150 psi. It’s not even close to it’s rating. I use it in an aeroponics system and only to sense if there is water pressure.
I was going to use it to regulate the pressure in the line but because of the above, I don’t trust it. I’m using a dumb mechanical pressure switch instead.
That said I would use their Ph for maybe a swimming pool but definitely not for my plants. I use an atlas ezo for my ph. There is also a lower cost version, their gravity line.
You’ll need to find the adc pin on your esp depending on what kind it is, see links below. The signal from the probe goes to that pin. The other 2 are power and ground
Hello friends,
I’ve also been “tinkering” with my pool control for a few weeks.
But I also come up against my limits here and keep struggling with the problem that my pH sensor is not working properly. At least that’s my feeling.
I was very happy to find this post and also the reference with the 2K and 1K ohm resistor.
At least that’s how I managed to get my value “right” when I put the sensor in the 4.0 and 7.0 liquid.
4.0 == 0.075
7.0 == 0.73
but when I “test” my pool water, it shows me a value of 8.4pH (but that can’t be the case) and even if I put the sensor in normal tap water, I have a value of at least 8.3 (that can’t be the case either)
I connected the sensor to 3.3V and to 5V
sometimes I try to calibrate with “lambda”, sometimes with “calibrate_linear”
For example, if I connect the sensor to 5V and use the two resistors (2K and 1K) I get a value of 1.05100 when the probe is in 7.0 liquid. but that can’t be…
I would be happy if someone here got their sensor to work properly and could help me with something.
Hi!
I’m in similar situation… I have the PH sensor with a esp32 and apparently everything works, the only problem I have is that the values fluctuate a lot. You can see a picture:
If I use a tester on the sensor output, I see that it always oscillates at 0.4 vols (in a 5v range)
when “translated” to 3.3v it should have a lot more fluctuations
I don’t know if it’s a problem with the sensor or the board or I if doing something wrong.
I calibrated the sensor manually before adding to home assistant. I may add calibration services that can be called from home assistant in the future. For now the custom component is only exposing the ph sensor.
I havent finished my hottub project yet - but went with the calibrate linear option as couldnt work out how to use the code provided by DF with esphome (im not a programmer - more of a tinkerer)… But now this is available - im open to changing it to work this way… and then it can use the temperature compensation etc. too…
On that note… is there a way to change what youve done - to work with an ADS1115 board over i2c? I see in your code your setting the pin - but is it possible to set it to a multiplexer pin on the ADS board?