Through multiple internet searches, I have come across thermistor based set-ups. Most everything I found were all basically flavors of the same base code. What I need is slightly different, as I wanted 4 probes, as follows:
Pool temperature
Heater inlet (you'd think this wouldn't be different from the pool body, bu it does differ slightly.)
Heater outlet -- for checking the delta t, as my heater is an experimental unit
Pump windings -- basically a motor health check.
Eventually I'd like to add in an electrical draw as well for the pump, along with timer and relay control for it. I've also got the hardware for a chlorine dosing pump I need to add to the mix. The dosing pump will be tied in to the pump run times, to ensure that I don't end up with a "hot spot" of liquid chlorinator. I don't think adding an RTC module should be that hard, there are many examples available for that.
Long term plans include nRF24L01 transceivers for logging purposes, along with LCD readouts in the house.
What I've done so far to get what I need is this:
#include <math.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd (2,3,4,5,6,7); /* 2=rs; 3=enable; 4=D4; 5=D5; 6=D6; 7=D7 */
double Thermistor1(int RawADC) {
double TempA;
TempA = log(10000.0*(1024.0/RawADC-1));
// =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
TempA = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempA * TempA ))* TempA );
TempA = TempA - 273.15; // Convert Kelvin to Celcius
TempA = (TempA * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return TempA;
}
double Thermistor2(int RawADC) {
double TempB;
TempB = log(10000.0*(1024.0/RawADC-1));
// =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
TempB = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempB * TempB ))* TempB );
TempB = TempB - 273.15; // Convert Kelvin to Celcius
TempB = (TempB * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return TempB;
}
double Thermistor3(int RawADC) {
double TempC;
TempC = log(10000.0*(1024.0/RawADC-1));
// =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
TempC = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempC * TempC ))* TempC );
TempC = TempC - 273.15; // Convert Kelvin to Celcius
TempC = (TempC * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return TempC;
}
double Thermistor4(int RawADC) {
double TempD;
TempD = log(10000.0*(1024.0/RawADC-1));
// =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
TempD = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempD * TempD ))* TempD );
TempD = TempD - 273.15; // Convert Kelvin to Celcius
TempD = (TempD * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return TempD;
}
void setup() {
//Serial.begin(115200);
lcd.begin(20,4);
}
void loop() {
lcd.setCursor(0,0);
lcd.print("Pool:");
lcd.setCursor(12,0);
lcd.print(int(Thermistor1(analogRead(0))));
lcd.print(" ");
lcd.print((char)223);
lcd.print("F ");
lcd.setCursor(0,1);
lcd.print("Heater in:");
lcd.setCursor(12,1);
lcd.print(int(Thermistor2(analogRead(1))));
lcd.print(" ");
lcd.print((char)223);
lcd.print("F ");
lcd.setCursor(0,2);
lcd.print("Heater out:");
lcd.setCursor(12,2);
lcd.print(int(Thermistor3(analogRead(2))));
lcd.print(" ");
lcd.print((char)223);
lcd.print("F ");
lcd.setCursor(0,3);
lcd.print("Pump:");
lcd.setCursor(12,3);
lcd.print(int(Thermistor4(analogRead(3))));
lcd.print(" ");
lcd.print((char)223);
lcd.print("F ");
delay(1500);
lcd.clear();
}
Being still very new to arduino and coding in general, I can't help but think this could be improved somewhat. I'm sure that if I were able to code directly in c++, it could be done.
This build so far is working on a pro mini with a 20x4 character LCD. When compiled, results are:
Sketch uses 5,052 bytes (16%) of program storage space. Maximum is 30,720 bytes.
Global variables use 81 bytes (3%) of dynamic memory, leaving 1,967 bytes for local variables. Maximum is 2,048 bytes.
I'm not looking for a handout, just some helpful hints how I could do it better. I'll learn quicker if I can be pointed in the right direction, so I can figure out the wherefores, if not the why's.

