PH Sensor temp adjustment

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

PH Sensor temp adjustment

#1 Post by zierbeek » 05 Aug 2021, 15:12

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?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: PH Sensor temp adjustment

#2 Post by ThomasB » 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

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#3 Post by zierbeek » 05 Aug 2021, 21:49

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!

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#4 Post by zierbeek » 09 Aug 2021, 16:04

should this diagram be considered to be working or would i need a level converter? Image

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#5 Post by TD-er » 09 Aug 2021, 16:12

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#6 Post by zierbeek » 09 Aug 2021, 17:31

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 .

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#7 Post by TD-er » 09 Aug 2021, 17:53

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#8 Post by zierbeek » 09 Aug 2021, 18:03

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#9 Post by TD-er » 09 Aug 2021, 18:06

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#10 Post by zierbeek » 09 Aug 2021, 18:12

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#11 Post by TD-er » 09 Aug 2021, 20:54

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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#12 Post by zierbeek » 09 Aug 2021, 22:49

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#13 Post by TD-er » 09 Aug 2021, 22:59

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

Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Re: PH Sensor temp adjustment

#14 Post by Oetsch » 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.

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#15 Post by zierbeek » 18 Aug 2021, 12:13

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! ;)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#16 Post by TD-er » 18 Aug 2021, 12:27

Hmm I've not seen any
If you can't send it via DM, you can also try email?

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#17 Post by zierbeek » 18 Aug 2021, 14:32

it's to Oetsch :)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#18 Post by TD-er » 18 Aug 2021, 18:27

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

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#19 Post by zierbeek » 19 Aug 2021, 14:57

:lol: :lol:

Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Re: PH Sensor temp adjustment

#20 Post by Oetsch » 20 Aug 2021, 01:01

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 :)

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#21 Post by zierbeek » 21 Aug 2021, 11:00

No worries! Responded ;)

zierbeek
Normal user
Posts: 21
Joined: 03 Aug 2021, 14:25

Re: PH Sensor temp adjustment

#22 Post by zierbeek » 29 Apr 2022, 17:28

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PH Sensor temp adjustment

#23 Post by TD-er » 29 Apr 2022, 19:13

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests