Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. /* this is an extension of several sketches I found online, some parts from
  2. arduino.cc playground, and some from a northeastern university project.
  3. Yes, I'm lacking a lot of comments within the code, maybe I'll flesh it out
  4. later, as I add a few other things to it.
  5. runs quite nicely on a pro mini.
  6.  
  7. Things to add:
  8.  
  9. RTC for pump timer relay
  10. control to shut down the pump when the heater return cools below a set temperature
  11.  
  12. There are a couple more things I'll add later*/
  13.  
  14.  
  15. #include <math.h>
  16. #include <LiquidCrystal.h>
  17.  
  18. LiquidCrystal lcd (2,3,4,5,6,7); /* 2=rs; 3=enable; 4=D4; 5=D5; 6=D6; 7=D7 */
  19.  
  20. double Thermistor1(int RawADC) {
  21. double TempA;
  22. TempA = log(10000.0*(1024.0/RawADC-1));
  23. // =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
  24. TempA = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempA * TempA ))* TempA );
  25. TempA = TempA - 273.15; // Convert Kelvin to Celcius
  26. TempA = (TempA * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  27. return TempA;
  28. }
  29.  
  30. double Thermistor2(int RawADC) {
  31. double TempB;
  32. TempB = log(10000.0*(1024.0/RawADC-1));
  33. // =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
  34. TempB = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempB * TempB ))* TempB );
  35. TempB = TempB - 273.15; // Convert Kelvin to Celcius
  36. TempB = (TempB * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  37. return TempB;
  38. }
  39.  
  40. double Thermistor3(int RawADC) {
  41. double TempC;
  42. TempC = log(10000.0*(1024.0/RawADC-1));
  43. // =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
  44. TempC = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempC * TempC ))* TempC );
  45. TempC = TempC - 273.15; // Convert Kelvin to Celcius
  46. TempC = (TempC * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  47. return TempC;
  48. }
  49.  
  50. double Thermistor4(int RawADC) {
  51. double TempD;
  52. TempD = log(10000.0*(1024.0/RawADC-1));
  53. // =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
  54. TempD = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempD * TempD ))* TempD );
  55. TempD = TempD - 273.15; // Convert Kelvin to Celcius
  56. TempD = (TempD * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  57. return TempD;
  58. }
  59.  
  60. void setup() {
  61. //Serial.begin(115200);
  62. lcd.begin(20,4);
  63. }
  64.  
  65. void loop() {
  66.  
  67. lcd.setCursor(0,0);
  68. lcd.print("Pool Return:");
  69. lcd.setCursor(14,0);
  70. lcd.print(int(Thermistor1(analogRead(0))));
  71. lcd.print(" ");
  72. lcd.print((char)223);
  73. lcd.print("F ");
  74.  
  75. lcd.setCursor(0,1);
  76. lcd.print("Heater in:");
  77. lcd.setCursor(14,1);
  78. lcd.print(int(Thermistor2(analogRead(1))));
  79. lcd.print(" ");
  80. lcd.print((char)223);
  81. lcd.print("F ");
  82.  
  83. lcd.setCursor(0,2);
  84. lcd.print("Heater out:");
  85. lcd.setCursor(14,2);
  86. lcd.print(int(Thermistor3(analogRead(2))));
  87. lcd.print(" ");
  88. lcd.print((char)223);
  89. lcd.print("F ");
  90.  
  91. lcd.setCursor(0,3);
  92. lcd.print("Air:");
  93. lcd.setCursor(14,3);
  94. lcd.print(int(Thermistor4(analogRead(3))));
  95. lcd.print(" ");
  96. lcd.print((char)223);
  97. lcd.print("F ");
  98.  
  99. delay(1000);
  100.  
  101. lcd.clear();
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement