In the attached simple circuit, AD2 and AD3 don't work and I can't figure out what's going on.
I would appreciate your comments. Thanks.
// GENERAL VARIABLES
float temp_outdoor;
float temp_supply;
float temp_control;
float temp_return;
// INSTALLED NTCs
boolean NTC0_Instl = true;
boolean NTC1_Instl = true;
boolean NTC2_Instl = true;
boolean NTC3_Instl = true;
int NTC0pin = A0;
int NTC1pin = A1;
int NTC2pin = A2;
int NTC3pin = A3;
float NTC0_NOM = 2000, NTC0_TEMP_NOM = 25, NTC0_SERIES_RES = 2000, Bcoeff0 = 3322.84;
float NTC1_NOM = 2000, NTC1_TEMP_NOM = 25, NTC1_SERIES_RES = 2000, Bcoeff1 = 3435.80;
float NTC2_NOM = 2000, NTC2_TEMP_NOM = 25, NTC2_SERIES_RES = 2000, Bcoeff2 = 3451.53;
float NTC3_NOM = 2000, NTC3_TEMP_NOM = 25, NTC3_SERIES_RES = 2000, Bcoeff3 = 3417.01;
int sample[5];
int i;
float average;
float steinhart;
void sample_NTC0() {
sample[i] = analogRead(NTC0pin);
// take N samples in a row, with a slight delay
for (i = 0; i < 5; i++) {
sample[i] = analogRead(NTC0pin);
delay(10);
}
// average all the samples out
steinhart = 0;
average = 0;
for (i = 0; i < 5; i++) {
average += sample[i];
}
average /= 5;
// convert the value to resistance
average = 1023 / average - 1;
average = NTC0_SERIES_RES / average;
steinhart = average / NTC0_NOM; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= Bcoeff0; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NTC0_TEMP_NOM + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
temp_outdoor = steinhart;
Serial.print("temp_outdoor : "); Serial.println(temp_outdoor);
}
void sample_NTC1() {
sample[i] = analogRead(NTC1pin);
// take N samples in a row, with a slight delay
for (i = 0; i < 5; i++) {
sample[i] = analogRead(NTC1pin);
delay(10);
}
// average all the samples out
steinhart = 0;
average = 0;
for (i = 0; i < 5; i++) {
average += sample[i];
}
average /= 5;
// convert the value to resistance
average = 1023 / average - 1;
average = NTC1_SERIES_RES / average;
steinhart = average / NTC1_NOM; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= Bcoeff1; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NTC1_TEMP_NOM + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
temp_supply = steinhart;
Serial.print("temp_supply : "); Serial.println(temp_supply);
}
void sample_NTC2() {
sample[i] = analogRead(NTC2pin);
// take N samples in a row, with a slight delay
for (i = 0; i < 5; i++) {
sample[i] = analogRead(A2); //analogRead(NTC2pin);
delay(10);
}
// average all the samples out
steinhart = 0;
average = 0;
for (i = 0; i < 5; i++) {
average += sample[i];
}
average /= 5;
// convert the value to resistance
average = 1023 / average - 1;
average = NTC2_SERIES_RES / average;
steinhart = average / NTC2_NOM; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= Bcoeff2; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NTC2_TEMP_NOM + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
temp_outdoor = steinhart;
Serial.print("temp_control : "); Serial.println(temp_control);
}
void sample_NTC3() {
//sample[i] = analogRead(NTC3pin);
// take N samples in a row, with a slight delay
for (i = 0; i < 5; i++) {
sample[i] = analogRead(NTC3pin);
delay(10);
}
// average all the samples out
steinhart = 0;
average = 0;
for (i = 0; i < 5; i++) {
average += sample[i];
}
average /= 5;
// convert the value to resistance
average = 1023 / average - 1;
average = NTC3_SERIES_RES / average;
steinhart = average / NTC3_NOM; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= Bcoeff3; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NTC3_TEMP_NOM + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
temp_supply = steinhart;
Serial.print("temp_return : "); Serial.println(temp_return);
}
void Get_NTCsTemps() {
sample_NTC0();delay(100);
sample_NTC1();delay(100);
sample_NTC2();delay(100);
sample_NTC3();delay(100);
}
void setup() {
Serial.begin(115200); // ESP01 Serial
delay(100);
}
void loop() {
Serial.println("START Get_NTCs ...");
Get_NTCsTemps();
Serial.println("END Get_NTCs");
delay(5000);
}