I wanted to make a simple 4 sensor temp readout and alarm for my 3d printers stepper motors. (i just burned one up ) I am a beginner. For sure.... I took a sample temp readout code and modded it. Have not tested it. I'm wondering if anyone has any input on why this would not work and how to make this code better.... Thank you
/*
3d Printer Stepper Temps...... In *F on a 16x2 i2c LCD.
Standard Thermister setups. Use voltage dividers(10K). Pin 0,1,2,3 go to respective thermisters.
Displays
X87.98F Z67.98F (examples number)
Y67.34F E34.56F
Added An Alarm..... Have Not Tested It.
Pin 4 goes to neg side of active peizo
*/
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
float TooHigh = 100.00; //temp of alarm //arlarm stuff
int ThermistorPinX = 0;
int ThermistorPinY = 1;
int ThermistorPinZ = 2;
int ThermistorPinE = 3;
int Vox;
int Voy;
int Voz;
int Voe;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
//XXX
float R1x = 10000;
float logR2x, R2x, Tx;
//YYY
float R1y = 10000;
float logR2y, R2y, Ty;
//ZZZ
float R1z = 10000;
float logR2z, R2z, Tz;
//EEE
float R1e = 10000;
float logR2e, R2e, Te;
void setup() {
Serial.begin(9600);
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
}
void loop() {
// XXXXX
Vox = analogRead(ThermistorPinX);
R2x = R1x * (1023.0 / (float)Vox - 1.0);
logR2x = log(R2x);
Tx = (1.0 / (c1 + c2*logR2x + c3*logR2x*logR2x*logR2x));
Tx = Tx - 273.15;
Tx = (Tx * 9.0)/ 5.0 + 32.0;
lcd.setCursor(0,0);
lcd.print("X");
lcd.print(Tx);
lcd.print("F");
if (Tx > TooHigh) { //arlarm stuff
digitalWrite (4, HIGH); //arlarm stuff
}
// YYYY
Voy = analogRead(ThermistorPinY);
R2y = R1y * (1023.0 / (float)Voy - 1.0);
logR2y = log(R2y);
Ty = (1.0 / (c1 + c2*logR2y + c3*logR2y*logR2y*logR2y));
Ty = Ty - 273.15;
Ty = (Ty * 9.0)/ 5.0 + 32.0;
lcd.setCursor(0,1);
lcd.print("Y");
lcd.print(Ty);
lcd.print("F");
if (Ty > TooHigh) { //arlarm stuff
digitalWrite (4, HIGH); //arlarm stuff
}
// ZZZZ
Voz = analogRead(ThermistorPinZ);
R2z = R1z * (1023.0 / (float)Voz - 1.0);
logR2z = log(R2z);
Tz = (1.0 / (c1 + c2*logR2z + c3*logR2z*logR2z*logR2z));
Tz = Tz - 273.15;
Tz = (Tz * 9.0)/ 5.0 + 32.0;
lcd.setCursor(9,0);
lcd.print("Z");
lcd.print(Tz);
lcd.print("F");
if (Tz > TooHigh) { //arlarm stuff
digitalWrite (4, HIGH); //arlarm stuff
}
// EEEE
Voe = analogRead(ThermistorPinE);
R2e = R1e * (1023.0 / (float)Voe - 1.0);
logR2e = log(R2e);
Te = (1.0 / (c1 + c2*logR2e + c3*logR2e*logR2e*logR2e));
Te = Te - 273.15;
Te = (Te * 9.0)/ 5.0 + 32.0;
lcd.setCursor(9,1);
lcd.print("E");
lcd.print(Te);
lcd.print("F");
if (Te > TooHigh) { //arlarm stuff
digitalWrite (4, HIGH); //arlarm stuff
}
delay(1500); //Updates the LCD every 1.5s...
lcd.clear();
}