Issue Setting up Analog PH sensor with ReefPI using ASD1115

vinaydhondiyal

New Member
View Badges
Joined
Mar 28, 2022
Messages
3
Reaction score
5
Location
India
Rating - 0%
0   0   0
Hi @Ranjib ,
Hope you are doing well. I am tagging you on this post as i am facing an issue while setting up my Ph sensor with ADS1115 in Reefpi.
Below is my Setup. I am hoping to get this resolved so that this also act as a guide to other users who don't have access to EZO pH circuit board.
Connect ADS1115 to Raspberry Pi:
  • Connect VCC of ADS1115 to 3.3V pin of Raspberry Pi.
  • Connect GND of ADS1115 to GND pin of Raspberry Pi.
  • Connect SDA of ADS1115 to SDA pin of Raspberry Pi.
  • Connect SCL of ADS1115 to SCL pin of Raspberry Pi.
Connect pH Sensor to ADS1115:
  • Connect the analog output of the pH sensor to any of the four analog input channels A0 of the ADS1115.
Connect pH Sensor
  • Connect the GND and 5v power supply
Now my i setup the drives in my config> drivers with 2/3 gain and 72 address

reef-pi>config.png


Post that i reboot the system and created an new Analog Input connector in config>connectors where i selected data PIN to 0 as per A0 on ADS1115

Screenshot 2024-01-28 at 2.19.56 PM.png


Now in the pH tab i added a new device as pH sensor with below settings.

reef-pi>Ph.png


As you can see in the above screenshot i am getting these readings when there is no probe connected to pH sensor. I need to know what is it that i am missing here. Also i When i connected the sensor i am getting following readings

reef-pi>sensor connected.png


Below is the sensor and ph card i am using
SENSOR
PH_SESNOR MODULE 1.0

P.S i am newbie to all this. So require your help :)
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Hi @Ranjib ,
Hope you are doing well. I am tagging you on this post as i am facing an issue while setting up my Ph sensor with ADS1115 in Reefpi.
Below is my Setup. I am hoping to get this resolved so that this also act as a guide to other users who don't have access to EZO pH circuit board.
Connect ADS1115 to Raspberry Pi:
  • Connect VCC of ADS1115 to 3.3V pin of Raspberry Pi.
  • Connect GND of ADS1115 to GND pin of Raspberry Pi.
  • Connect SDA of ADS1115 to SDA pin of Raspberry Pi.
  • Connect SCL of ADS1115 to SCL pin of Raspberry Pi.
Connect pH Sensor to ADS1115:
  • Connect the analog output of the pH sensor to any of the four analog input channels A0 of the ADS1115.
Connect pH Sensor
  • Connect the GND and 5v power supply
Now my i setup the drives in my config> drivers with 2/3 gain and 72 address

reef-pi>config.png


Post that i reboot the system and created an new Analog Input connector in config>connectors where i selected data PIN to 0 as per A0 on ADS1115

Screenshot 2024-01-28 at 2.19.56 PM.png


Now in the pH tab i added a new device as pH sensor with below settings.

reef-pi>Ph.png


As you can see in the above screenshot i am getting these readings when there is no probe connected to pH sensor. I need to know what is it that i am missing here. Also i When i connected the sensor i am getting following readings

reef-pi>sensor connected.png


Below is the sensor and ph card i am using
SENSOR
PH_SESNOR MODULE 1.0

P.S i am newbie to all this. So require your help :)
Well, the ADS1115 is a 16 bit converter, so the results are integer numbers between 0 and 2^16-1, e.g. 0 and 65535.

If you connect your A0 to GND, you will see a value close-ish to 0 (note that down as v_gnd) and if you connect it to 3.3V, you will see a value around 43000 (note that down as v_3V3, if you connect it to 5V (make sure it is in gain 2/3 mode) the value will be close to or exactly 65535 (note that down as v_5V.

You could then in general, use a transform function first (I hope that doesn't interfere with calibration afterwards).
  • If your v_5V value is lower than 65535, enter the following and insert the appropriate values that you have noted down (except for v, that will stay the letter v):
    Code:
    5.0 * (v - v_GND)/(v_5V - v_GND)
  • if your v_5V is exactly 65535, I would rather trust the 3.3V one:
    Code:
    3.3 * (v - v_GND)/(v_3V3 - v_GND)
That should convert your value to a roughly correct voltage. You can use that formula for all channels of the ADS1115

Afterwards you can calibrate with standard pH calibration solutions (mind that you have to calibrate all points (for pH 2 will suffice) after each other. You can make one test calibration run to see the process and then keep all solutions ready at hand for the second real thing. You will then put the pH probe into the reference solution, give ReefPi the pH of that solution and go to the next. Rinse your probe a bit and put it into the second solution, give ReefPi the pH of that solution and you should be done. Then ReefPi should convert your tranformed voltage reading to the pH.

If that doesn't work, you can also enter the transform formula manually. Just put the probe into the reference solution, wait until the voltage reading stabilizes and note the reference pH (pHRef) and your voltage (v_pHRef) down. You should only need 2 measurements at pH 7.0 and something above if you have a ReefTank and something below that for tropic freshwater tanks.
The formula then looks something like this:
Code:
 7.0 + ( 3.3 * (v - v_GND)/(v_3V3 - v_GND) - v_pH7) * (pHRef - 7.0) / (v_pHRef - v_pH7)

Should work for any pH Reference, be it at 4.0, 9.3 or anything else that you can get your hands on.

I hope this can help you ;)
 
Last edited:
OP
OP
vinaydhondiyal

vinaydhondiyal

New Member
View Badges
Joined
Mar 28, 2022
Messages
3
Reaction score
5
Location
India
Rating - 0%
0   0   0
Thanks @Sral sorry for late reply i was busy with an ongoing project so didn't get the time to look into this.

Here is my findings.
============================
The ADS1115 is a 16-bit analog-to-digital converter (ADC),which means it can represent analog input values as integers ranging from 0 to 32767 (2^16 - 1).

This range corresponds to the full scale of the ADC's input voltage.Here's how the integer range maps to voltage range, considering the ADS1115's default configuration:0: Corresponds to the ADC input voltage of the most negative value, typically GND (ground).32767: Corresponds to the ADC input voltage of the most positive value, typically VDD (supply voltage).The ADS1115 can be configured to use different gain settings, which affect the range of input voltages that can be measured. The default gain setting is ±6.144V, meaning the ADC can measure voltages within the range of -6.144V to +6.144V. However, this can be adjusted to lower ranges like ±4.096V, ±2.048V, ±1.024V, ±0.512V, or ±0.256V by changing the PGA (programmable gain amplifier) setting

GAIN setting is set to 1 ±4.096V* now
You can find the gain voltage table HERE

==============================
Here are the readings that i am getting in my ADS1115

When A0 connected to 3.3v
Voltage on A0: 3.294 V
Raw ADC value on A0: 26352

When A0 connected to 5v
Voltage on A0: 4.095875 V
Raw ADC value on A0: 32767

When A0 connected to 0v
Voltage on A0: -0.0005 V
Raw ADC value on A0: -4

below is the py script i created to read these values

Code:
import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn

# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)

# Create the ADC object using the I2C bus
ads = ADS.ADS1115(i2c)

# Create single-ended input on channel 0
channel = AnalogIn(ads, ADS.P0)

while True:
    # Read the raw ADC value
    raw_value = channel.value

    # Convert the raw ADC value to voltage
    voltage = raw_value * 0.000125  # ADS1115 resolution is 16 bits (2^16) and full range is 6.144V

    print("Voltage on A0:", voltage, "V")
    print("Raw ADC value on A0:", raw_value)

    time.sleep(1)

now i have all the values required i am just not clear on below section

what is v denotes here
v_GND = -4
v_5V = 32767
v_3V3 = 26352
v=??

what do we mean by using a transform function is it something in ReefPi
5.0 * (v - v_GND)/(v_5V - v_GND)
3.3 * (v - v_GND)/(v_3V3 - v_GND)

also how do i calibrate these values in ReefPi
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
As I wrote:
(except for v, that will stay the letter v)
That's because "v" in the ReefPi transform formula is the measurement value before transformation. It's like a variable.

In ReefPi you can either calibrate the signal using the calibration function, or enter the transform formula with all values manually.

And yes, "transform formula" is something within ReefPi. Every Signal that you create in the pH tab has a "transform formula" field that you can use.
 
OP
OP
vinaydhondiyal

vinaydhondiyal

New Member
View Badges
Joined
Mar 28, 2022
Messages
3
Reaction score
5
Location
India
Rating - 0%
0   0   0
Just to complete this reference Guide:
As mentioned above the Gain value was set to 1

1711093305032.png


For People who were confused like me where the transform formula needs to go, there is a input field named transform function. Please see the screenshot below:

1711099249635.png


pH calibration solutions of ph value 7 and 10 can be used for further calibrating using your pH probe as mentioned in the above thread.

1711100607768.png


Special Thanks for @Sral for helping me out in preparing this.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Just to complete this reference Guide:
As mentioned above the Gain value was set to 1

1711093305032.png


For People who were confused like me where the transform formula needs to go, there is a input field named transform function. Please see the screenshot below:

1711099249635.png


pH calibration solutions of ph value 7 and 10 can be used for further calibrating using your pH probe as mentioned in the above thread.

1711100607768.png


Special Thanks for @Sral for helping me out in preparing this.
You're very welcome and thank you for preparing the screenshots !
 

Reefing threads: Do you wear gear from reef brands?

  • I wear reef gear everywhere.

    Votes: 20 13.4%
  • I wear reef gear primarily at fish events and my LFS.

    Votes: 10 6.7%
  • I wear reef gear primarily for water changes and tank maintenance.

    Votes: 1 0.7%
  • I wear reef gear primarily to relax where I live.

    Votes: 23 15.4%
  • I don’t wear gear from reef brands.

    Votes: 84 56.4%
  • Other.

    Votes: 11 7.4%

New Posts

Back
Top