I'm wanting my Thermocoupler temp to show up on my LCD screen and based off the temp (IF/ELSE) a really will turn on or off. The relay is turning off and on fine, the thermocoupler reads perfect... But I can't get the serial monitor to display on my LCD screen for anything... I can get the stuff in the void setup to show up, but the void loop displays a blank LCD screen. I'd like for the temp to display constantly and update every 1 sec or so...
disclaimer.. I've tried about 10 different sample codes trying to fix it so what you see is probably a combination of them all.... :o
Any help is greatly appreciated!
/*-----( Import needed libraries )-----*/
#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
/*-----( Declare Variables )-----*/
//NONE
#include <max6675.h>
// ThermoCouple
int thermo_gnd_pin = 45;
int thermo_vcc_pin = 47;
int thermo_so_pin = 9;
int thermo_cs_pin = 10;
int thermo_sck_pin = 11;
int relayPin = 5; // Pin of Relay Module
MAX6675 thermocouple(thermo_sck_pin, thermo_cs_pin, thermo_so_pin);
void setup() {
Serial.begin(9600);
pinMode(thermo_vcc_pin, OUTPUT);
pinMode(thermo_gnd_pin, OUTPUT);
digitalWrite(thermo_vcc_pin, HIGH);
digitalWrite(thermo_gnd_pin, LOW);
pinMode(relayPin, OUTPUT); // Set Pin connected to Relay as an OUTPUT
digitalWrite(relayPin, LOW); // Set Pin to LOW to turn Relay OFF
lcd.begin(16, 2); // initialize the lcd for 16 chars 2 lines, turn on backlight
Serial.begin(9600);
// ------- Quick 3 blinks of backlight -------------
for (int i = 0; i < 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(0, 0); //Start at character 4 on line 0
lcd.print("Barrel Stoker");
delay(1000);
lcd.setCursor(0, 1);
lcd.print("temperature");
delay(1000);
lcd.clear();
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
}
void loop() {
Serial.print("temperature ");
Serial.println(thermocouple.readFarenheit());
delay(1000);
char TestData;
TestData = Serial.read();
int tempsens = thermocouple.readFahrenheit();
if(tempsens<= 75)
{
digitalWrite(relayPin, LOW); // Turn Relay OFF
lcd.setCursor(0, 1);
lcd.print(TestData);
}
else if( tempsens > 75)
{
digitalWrite(relayPin, HIGH); // Turn Relay ON
lcd.setCursor(0, 1);
lcd.print(TestData);
}
}