Page 1 of 1

PH Sensor temp adjustment

Posted: 05 Aug 2021, 15:12
by zierbeek
Hi all,

thank you for this project!

I have recently bought this ph sensor with the included bnc board : https://nl.aliexpress.com/item/10050016 ... 4c4duSIvfn

Also an ads1115 to connect it to my esp8266 without any issues. It should read fine.

I have read that it should be calibrated with the buffer solutions, so i bought these along. Some questions:

- The board has screws for calibration. Should i do this in espeasy or should i do it with the 2 screws (please a bit of explenation on the 2 screws.)
- The temperature has influence on the ph readings. Should i wire the ds18b20 directly on the bnc board to provide calibration?

Re: PH Sensor temp adjustment

Posted: 05 Aug 2021, 17:52
by ThomasB
The board has screws for calibration. Should i do this in espeasy or should i do it with the 2 screws (please a bit of explenation on the 2 screws.)
Calibration information for the two pots: https://www.botshop.co.za/how-to-use-a- ... nd-sensor/

- Thomas

Re: PH Sensor temp adjustment

Posted: 05 Aug 2021, 21:49
by zierbeek
ThomasB wrote: 05 Aug 2021, 17:52
The board has screws for calibration. Should i do this in espeasy or should i do it with the 2 screws (please a bit of explenation on the 2 screws.)
Calibration information for the two pots: https://www.botshop.co.za/how-to-use-a- ... nd-sensor/

- Thomas
Thanks man, great guide!

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 16:04
by zierbeek
should this diagram be considered to be working or would i need a level converter? Image

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 16:12
by TD-er
What is the analog output level of the sensor?
Also make sure to check if the 5V pin actually has 5V if you power it like you want to power it.

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 17:31
by zierbeek
The PH sensor would output 5V. some said that it doesn't matter for the digital pins sice the ads1115 will convert it to a digital signal.

Would need to check if it's 5v indeed. according to documentation, it should... I will power it with a 5v1a adapter .

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 17:53
by TD-er
The ADC chip might be capable to capture higher voltages, but better check in the datasheet.
On the other hand, converting an analog voltage into a lower voltage is very easy using 2 resistors.

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 18:03
by zierbeek
indeed true, with a voltage divider. But the ads1115 should be doing fine since it accepts 5V. question is if a I2C level converter is recommended/needed.

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 18:06
by TD-er
I don't think so, as you power the ADC with 3v3, so the SDA and SCL will probably be pulled up to that level.

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 18:12
by zierbeek
Thanks! Wiring seems fine ?

some other forums recommended it since it would improve accuracy, but i don't see where this would be improved tho.

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 20:54
by TD-er
Well, personally I would have chosen to only use a single GND line.
Having multiple wires/traces with the same net may cause other issues.
Better to think of the GND and Vcc as a star than a loop.

Also it is good practice to add a small capacitor over the V+ and GND on each chip, as close as possible to the chip itself.
Typical value for this is 100 nF.
Especially for chips handling analog signals.

And you may want to add 2 pull-up resistors over the SDA and SCL lines to 3v3.
Typical values for the I2C pull-up resistors are 10k or 4k7. Doesn't really matter though.

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 22:49
by zierbeek
Thank you!
All of this is still a work in progress so all can change :)

So wire the gnd together so it only used 1 pin on the ESP?

And the two pull up resistors could be exchanged by a level converter ? Have some lying around

Re: PH Sensor temp adjustment

Posted: 09 Aug 2021, 22:59
by TD-er
The pull-up resistor is not a level converter.
It is to literally pull up the I2C signal levels, so all I2C devices pull the signal low when needed.

Just one example:
Image

Re: PH Sensor temp adjustment

Posted: 12 Aug 2021, 16:13
by Oetsch
Hi
had constructive discussions on how to use this pH sensors in another forum.

Why are you using level shifters?

the pcb of the ph Sensor has everthing onboard. You have two trimmer for calibration. One is used to shift the voltage in the positive area with a miminum of 0V.

By default this ph sensor boards uses negative and positive voltage level. ph value of 7 is normally 0V. 414mV is for pH value of 0 and -414mV is for pH value of 14. To make it measurable for the ESP analog input or better the ADS1115 you have to shift this linear function into the positive area by increasing the offset by one of the trimmer.

The other trimmer is used to define the maximum voltage output level. When you are powering the ADS1115 with 3,3V the maximum input voltage is 3,6V.

After this the ADS1115 can be used in single-end mode and the gain before the AD-converter is to be set for FS=4V.
You have a 16 Bit chip. this means a fix resolution of 65535 Bits.
Using FS=4V means 32767 Bits for the positive voltage area from 0V to 4V with an LSB=125uV
So for calculation to Volts you can use: value x 125uv = Analog Input Value in Volt

Because of this very low voltage input levels I would say this measurement includes to much noise etc. that has nothing to do with the voltage from the pH sensor.

So decreasing the sensitivity will have an positive effect for your results. Doing this by selecting FS=6V means an LSB=185uV and decreases sensitivity by 50%
For calculation this means: value x 185uV = Analog Input value in Volt

Of course, a direct conversion to pH valvues is also possible by using the formula. But please think about the usablity auf decimals. Out of my current understanding only one decimal might be usable. Even by using FS=6V you are still acting in mV areas and i do not believe that gives really usable results by looking to results based on 10mV resultion because the whole quality of measuremt do not have this possibility.

Best regards.

Re: PH Sensor temp adjustment

Posted: 18 Aug 2021, 12:13
by zierbeek
Oetsch wrote: 12 Aug 2021, 16:13 Hi
had constructive discussions on how to use this pH sensors in another forum.

Why are you using level shifters?

the pcb of the ph Sensor has everthing onboard. You have two trimmer for calibration. One is used to shift the voltage in the positive area with a miminum of 0V.

By default this ph sensor boards uses negative and positive voltage level. ph value of 7 is normally 0V. 414mV is for pH value of 0 and -414mV is for pH value of 14. To make it measurable for the ESP analog input or better the ADS1115 you have to shift this linear function into the positive area by increasing the offset by one of the trimmer.

The other trimmer is used to define the maximum voltage output level. When you are powering the ADS1115 with 3,3V the maximum input voltage is 3,6V.

After this the ADS1115 can be used in single-end mode and the gain before the AD-converter is to be set for FS=4V.
You have a 16 Bit chip. this means a fix resolution of 65535 Bits.
Using FS=4V means 32767 Bits for the positive voltage area from 0V to 4V with an LSB=125uV
So for calculation to Volts you can use: value x 125uv = Analog Input Value in Volt

Because of this very low voltage input levels I would say this measurement includes to much noise etc. that has nothing to do with the voltage from the pH sensor.

So decreasing the sensitivity will have an positive effect for your results. Doing this by selecting FS=6V means an LSB=185uV and decreases sensitivity by 50%
For calculation this means: value x 185uV = Analog Input value in Volt

Of course, a direct conversion to pH valvues is also possible by using the formula. But please think about the usablity auf decimals. Out of my current understanding only one decimal might be usable. Even by using FS=6V you are still acting in mV areas and i do not believe that gives really usable results by looking to results based on 10mV resultion because the whole quality of measuremt do not have this possibility.

Best regards.
Hi i've sent you a pm but still in my outbox! ;)

Re: PH Sensor temp adjustment

Posted: 18 Aug 2021, 12:27
by TD-er
Hmm I've not seen any
If you can't send it via DM, you can also try email?

Re: PH Sensor temp adjustment

Posted: 18 Aug 2021, 14:32
by zierbeek
it's to Oetsch :)

Re: PH Sensor temp adjustment

Posted: 18 Aug 2021, 18:27
by TD-er
zierbeek wrote: 18 Aug 2021, 14:32 it's to Oetsch :)
Ah that explains why I did not see any ;)

Re: PH Sensor temp adjustment

Posted: 19 Aug 2021, 14:57
by zierbeek
:lol: :lol:

Re: PH Sensor temp adjustment

Posted: 20 Aug 2021, 01:01
by Oetsch
Oh sorry and I normally only log in in case I want to write sth. so have not seen your messages.
But now hope you got an answer from me :)

Re: PH Sensor temp adjustment

Posted: 21 Aug 2021, 11:00
by zierbeek
No worries! Responded ;)

Re: PH Sensor temp adjustment

Posted: 29 Apr 2022, 17:28
by zierbeek
Hi all!

at the end, the sensor board seemed to be broken, so I ordered a new one, which is working in esphome with readable ph outputs. How can I convert this to es-easy? I tried it with the ads plugin, set to gain of 6 but only gave me negative values.

esphome:
name: pool
platform: ESP32
board: nodemcu-32s

i2c:
sda: 22
scl: 21
scan: true
id: bus_a

ads1115:
- address: 0x48
sensor:
- platform: ads1115
multiplexer: 'A0_GND'
gain: 6.144
name: "Po A0"
unit_of_measurement: "V"
state_class: "measurement"
update_interval: 1s
- platform: ads1115
multiplexer: 'A0_GND'
gain: 6.144
name: "pH measurement"
unit_of_measurement: "pH"
state_class: "measurement"
update_interval: 1s
filters:
- calibrate_linear:
- 0.00 -> 0.0
- 2.50 -> 7.0
- 5.00 -> 14.0
- platform: ads1115
multiplexer: 'A1_GND'
gain: 4.096
id: do_measurement
name: "Do A1"
state_class: "measurement"
unit_of_measurement: "V"
update_interval: 1s
- platform: ads1115
multiplexer: 'A2_GND'
gain: 6.144
name: "To A2"
state_class: "measurement"
update_interval: 1s

binary_sensor:
- platform: analog_threshold
name: "Above set pH"
sensor_id: do_measurement
threshold: 2.41

Re: PH Sensor temp adjustment

Posted: 29 Apr 2022, 19:13
by TD-er
Just based on this line: "multiplexer: 'A0_GND' "

To me it looks like ESPHome is then scaling it as an absolute value ranging from 0 ... (X-1)
If I'm not mistaken, ESPEasy configures the chip to have a range from -Y ... (Y-1) where Y is typically half of X.

So what you can do, is to add Y to the measured values before applying your calibration.
Have to check what Y is for this sensor, but I think it is 32768. (half the range of a 16-bit ADC)

So in your formula you can do something like this:

Code: Select all

(%value% + 32768) * N
With N being the factor you need to get the right scale.
Not sure if you also need something else to get the right usable value?