ph sensor voltage and ph value is coming 0

Hy guys,
i’m beginner to Arduino i connected Arduino,PH sensor and oled connections properly. But My output of ph sensor is coming ph value is 0 as well as i,m getting voltage also 0 below is my code please help me out

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>

#define SensorPin 0        // the pH meter Analog output is connected with the Arduino’s Analog
unsigned long int avgValue;  //Store the average value of the sensor feedback
float b;
int buf[10],temp;

// OLED display height, in pixels
// Reset pin # (or -1 if sharing reset pin)
#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);

void setup()
 Serial.println("Ready");    //Test the serial monitor

 display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
 // init done
 // Show image buffer on the display hardware.
 // Since the buffer is intialized with an Adafruit splashscreen
 // internally, this will display the splashscreen.

 // Clear the buffer.

display.print("PH Sensor");
void loop()
 for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
 for(int i=0;i<9;i++)        //sort the analog from small to large
   for(int j=i+1;j<10;j++)
 for(int i=2;i<8;i++)                      //take the average value of 6 center sample
 float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
 phValue=3.5*phValue;                      //convert the millivolt into pH value
 Serial.print("    pH:");  
 Serial.println(" ");
 display.println("Ph Value");



 digitalWrite(13, HIGH);       
 digitalWrite(13, LOW); 


What exact pH sensor are you using?

What does your volt meter tell you the voltage of the sensor’s output really is?

#define SensorPin 0

Pin 0 is the TX pin, not an analog input, but one of the Arduino’s IDE confusing design horrors may actually help you out here - and read from the A0 after all…

 for(int i=2;i<8;i++)                      //take the average value of 6 center sample

This takes the last 6 samples, dropping the first two. Not the middle six. Remember computers start counting at 0.
It’s about 59 mV/pH point for regular pH probes, not the 3.5 mV/pH point I see in your code. Also that calculation only works if your Vcc is exactly 5V, and not say 4.3-4.5V as you get when powering over USB.

This takes the last 6 samples, dropping the first two. Not the middle six.

It takes samples numbered 2 to 7, of samples numbered 0 to 9. In other words, the middle six.

i,m getting voltage also 0

The sensor is either not working properly, or not connected to the Arduino properly.