Getting data to senseor PH communication UART


hi, this my ph kit. i use arduino UNO. this ph kit use communication UART send character 'P' then get data of ph sensor. This is code of ph kit, but it does not work. Please fix code help me

#include <SoftwareSerial.h>
SoftwareSerial myserial( 4,2); // rx tx pin   
char x[7];
void setup()
{
  Serial.begin(9600);
  myserial.begin(9600);
  Serial.println("start ");
 
}

void loop()
{
   int i=0;
   int PH_Value=0;
   if(myserial.available()){
       while(myserial.available()>0)  {
          x[i]=myserial.read();
          i++;
          if(x[0]=='P' && x[1]=='H')
            { 
               PH_Value=(x[3]-'0')*1000+(x[4]-'0')*100+(x[6]-'0')*10+(x[7]-'0');    
               Serial.println(PH_Value);
              
            }     
       }
   }else{
    Serial.println(" dont't signal");                                               
   }
   delay(1000);
}

You have WAY too much code for someone who thinks that the pH sensor is not working.

ALL that the sketch is doing should be to send a 'P' and wait (you are NOT waiting) for a response.

You need to post a schematic showing how the device is connected. For all we know, you simply rubber-banded it to the Arduino.

You should NOT be connecting it to the only hardware serial port you have. That one should be being used to debug the code. You should have it connected to two other pins and be using SoftwareSerial to talk to the device.

i will fix code use softwareserial but it don't work. please fix help me

#include <SoftwareSerial.h>
SoftwareSerial myserial( 4,2); // rx tx pin   
char x[7];
void setup()
{
  Serial.begin(9600);
  myserial.begin(9600);
  Serial.println("start ");
 
}

void loop()
{
   int i=0;
   int PH_Value=0;
   if(myserial.available()){
       while(myserial.available()>0)  {
          x[i]=myserial.read();
          i++;
          if(x[0]=='P' && x[1]=='H')
            { 
               PH_Value=(x[3]-'0')*1000+(x[4]-'0')*100+(x[6]-'0')*10+(x[7]-'0');    
               Serial.println(PH_Value);
              
            }     
       }
   }else{
    Serial.println(" dont't signal");                                               
   }
   delay(1000);
}

You forgot to send "P" first; you simply started reading.

And please (for future) be aware that "it don't work" does not mean anything. Please provide the details of what you expect and what really happens.

   if(myserial.available()){
       while(myserial.available()>0)  {
          x[i]=myserial.read();
          i++;
          if(x[0]=='P' && x[1]=='H')
            {
               PH_Value=(x[3]-'0')*1000+(x[4]-'0')*100+(x[6]-'0')*10+(x[7]-'0');   
               Serial.println(PH_Value);

So, when you have read one byte, and i is 1, go ahead and use all 8 of the one bytes in the array. Hmmm. I wonder why that doesn't work.