#define THERMISTORPIN1 34
#define THERMISTORPIN2 32
#define THERMISTORPIN3 35
#define THERMISTORPIN4 33
const double VCC = 3.3; // NodeMCU on board 3.3v vcc
const double R2 = 10000; // 10k ohm series resistor
const double adc_resolution = 4096; // 12-bit adc
const double A = 0.001129148; // thermistor equation parameters
const double B = 0.000234125;
const double C = 0.0000000876741;
void setup() {
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
double Vout, Rth1, Rth2, Rth3, Rth4, temperature1, temperature2, temperature3, temperature4, adc_value1, adc_value2, adc_value3, adc_value4;
adc_value1 = adc_resolution - analogRead(THERMISTORPIN1) + 0.5; // switch direction
adc_value2 = adc_resolution - analogRead(THERMISTORPIN2) + 0.5;
adc_value3 = adc_resolution - analogRead(THERMISTORPIN3) + 0.5;
adc_value4 = adc_resolution - analogRead(THERMISTORPIN4) + 0.5;
Vout = (adc_value1 * VCC) / adc_resolution;
Rth1 = (VCC * R2 / Vout) - R2;
Vout = (adc_value2 * VCC) / adc_resolution;
Rth2 = (VCC * R2 / Vout) - R2;
Vout = (adc_value3 * VCC) / adc_resolution;
Rth3 = (VCC * R2 / Vout) - R2;
Vout = (adc_value4 * VCC) / adc_resolution;
Rth4 = (VCC * R2 / Vout) - R2;
temperature1 = (1 / (A + (B * log(Rth1)) + (C * pow((log(Rth1)), 3))));
temperature2 = (1 / (A + (B * log(Rth2)) + (C * pow((log(Rth2)), 3))));
temperature3 = (1 / (A + (B * log(Rth3)) + (C * pow((log(Rth3)), 3))));
temperature4 = (1 / (A + (B * log(Rth4)) + (C * pow((log(Rth4)), 3))));
temperature1 = temperature1 - 273.15; // Temperature in degree celsius
temperature2 = temperature2 - 273.15;
temperature3 = temperature3 - 273.15;
temperature4 = temperature4 - 273.15;
Serial.print("Rth1:");
Serial.print(Rth1);
Serial.print(" Temperature1 = ");
Serial.print(temperature1);
Serial.println(" degree celsius");
Serial.print("Rth2:");
Serial.print(Rth2);
Serial.print(" Temperature2 = ");
Serial.print(temperature2);
Serial.println(" degree celsius");
Serial.print("Rth3:");
Serial.print(Rth3);
Serial.print(" Temperature3 = ");
Serial.print(temperature3);
Serial.println(" degree celsius");
Serial.print("Rth4:");
Serial.print(Rth4);
Serial.print(" Temperature4 = ");
Serial.print(temperature4);
Serial.println(" degree celsius");
delay(5000);
}