Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* this is an extension of several sketches I found online, some parts from
- arduino.cc playground, and some from a northeastern university project.
- Yes, I'm lacking a lot of comments within the code, maybe I'll flesh it out
- later, as I add a few other things to it.
- runs quite nicely on a pro mini.
- Things to add:
- RTC for pump timer relay
- control to shut down the pump when the heater return cools below a set temperature
- There are a couple more things I'll add later*/
- #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 Return:");
- lcd.setCursor(14,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(14,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(14,2);
- lcd.print(int(Thermistor3(analogRead(2))));
- lcd.print(" ");
- lcd.print((char)223);
- lcd.print("F ");
- lcd.setCursor(0,3);
- lcd.print("Air:");
- lcd.setCursor(14,3);
- lcd.print(int(Thermistor4(analogRead(3))));
- lcd.print(" ");
- lcd.print((char)223);
- lcd.print("F ");
- delay(1000);
- lcd.clear();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement