Ph Sensor on ADS1115

Hello

I would like to realize an aquarium control with Cayenne.
I also want to measure the pH of the water.
I have a PH probe with a transducer but the analog signal on.
I connected this with the ADS1115 module.
That works quite well.
Now my question.
How can I generate the trade fair area or a conversion?
If I indicate Volt, the volts are also output.
But I want to get the PH value displayed.
Another question.
Does Cayenn also support WS2812b LED Stripes?
I want to simulate sunrises, sunsets and moon phases.
Is that possible ?

greetings
André

Begin with this i think you can find your happiness for mV to pH translation:

#define Offset 0.00            //deviation compensate
unsigned long int avgValue;     //Store the average value of the sensor feedback
void setup()
{
  pinMode(13,OUTPUT); 
  Serial.begin(9600); 
  Serial.println("Ready");    //Test the serial monitor
} //END setup
void loop()
{
  int buf[10];                //buffer for read analog
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    buf[i]=analogRead(SensorPin);
    delay(10);
  }
  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        int temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
    avgValue+=buf[i];
  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue+Offset;                      //convert the millivolt into pH value
  Serial.print("    pH:"); 
  Serial.print(phValue,2);
  Serial.println(" ");
  digitalWrite(13, HIGH);      
  delay(800);
  digitalWrite(13, LOW);
} // END loop
1 Like

Hello

Thank you for your prompt reply.
I had forgotten that I use a Raspberry pi.
Unfortunately, I noticed that the extensions remove themselves.
The same thing happens with buttons.
Weird behaviour.
When I reset the Raspi everything will work again for a while.
Which device do you use as a basis?
I might pan to NodeMCU if that’s possible. the synonymous has an analog input.

greetings
André

I’m a beginner with RPI i think it’s possible in coding with this : GitHub - adafruit/Adafruit_Python_ADS1x15: Python code to use the ADS1015 and ADS1115 analog to digital converters with a Raspberry Pi or BeagleBone black.

I’m more familiar with ARDUINO.
NodeMCU got twice : i2c and analog input . and library GitHub - adafruit/Adafruit_ADS1X15: Driver for TI's ADS1015: 12-bit Differential or Single-Ended ADC with PGA and Comparator
you could transmit pH after calculation to Cayenne.

An important precision : a pH sensor mesure mV between -200 to +200mV .
Does ADS1115 mesure négative Voltage ? I don’t think : it goes from GNd to Vcc !
So you must use electronic adaptor like this :