As jremington says, you need to isolate the problem by getting the pH sensor working properly in a simpler program.
Did you do this prior to putting together your current code?
Edit: I just spotted your problem. You’ve just tacked the pH sensor code onto the end of the ‘read_dht_dat()’ function, after the ‘return’, so the pH sensor never actually gets read.
Note the ‘return result;’ line below. (I marked it.):-
//Collect 8 bits from datastream, return them interpreted
//as a byte. I.e. if 0000.0101 is sent, return decimal 5.
//Code expects the system to have recently entered the
//dataline low condition at the start of every data bit's
//transmission BEFORE this function is called.
byte i = 0;
byte result = 0;
for (i = 0; i < 8; i++)
//We enter this during the first start bit (low for 50uS) of the byte
//Next: wait until pin goes high
while (digitalRead(dht_dpin) == LOW); //Was: while(!(PINC & _BV(dht_PIN)));
//signalling end of start of bit's transmission.
//Dataline will now stay high for 27 or 70 uS, depending on
//whether a 0 or a 1 is being sent, respectively.
delayMicroseconds(30);//AFTER pin is high, wait further period, to be
//into the part of the timing diagram where a 0 or a 1 denotes
//the datum being send. The "further period" was 30uS in the software
//that this has been created from. I believe that a higher number
//(45?) would be more appropriate.
//Next: Wait while pin still high
if (digitalRead(dht_dpin) == HIGH) //Was: if(PINC & _BV(dht_PIN))
result |= (1 << (7 - i)); // "add" (not just addition) the 1
//to the growing byte
//Next wait until pin goes low again, which signals the START
//of the NEXT bit's transmission.
while (digitalRead(dht_dpin) == HIGH); //Was: while((PINC & _BV(dht_PIN)));
}//end of "for.."
return result; // <<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue, voltage;
if (millis() - samplingTime > samplingInterval)
pHArray[pHArrayIndex++] = analogRead(SensorPin);
if (pHArrayIndex == ArrayLenth)pHArrayIndex = 0;
voltage = avergearray(pHArray, ArrayLenth) * 5.0 / 1024;
pHValue = 3.5 * voltage + Offset;
samplingTime = millis();
if (millis() - printTime > printInterval) //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
Serial.print(" pH value: ");
digitalWrite(LED, digitalRead(LED) ^ 1);
printTime = millis();