2×16 I2C LCD and Thermocouple

Been some time since I last posted some arduino code… But here it is!
This time it is to make a Thermocouple with a MAX6675 amplifier work with an I2C LCD display.

//I2C lcd
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); //set the LCD address to 0x27 for a 16 chars and 2 line display

uint8_t degree[8]  = {
  140,146,146,140,128,128,128,128};

//MAX6675 amplifier and Thermocouple
#include "max6675.h"

//Pins used for the thermocouple
int thermoDO = 40;
int thermoCS = 41;
int thermoCLK = 42;
int vccPin = 39;
int gndPin = 38;

//Fire it up!
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

void setup()
{
  //Prepare LCD
  lcd.init();
  lcd.clear();
  lcd.setBacklight(1);
  lcd.blink_off();

  lcd.createChar(0, degree); //Create a custom char for the degree symbol

  //Use Arduino pins to power the MAX6675
  pinMode(vccPin, OUTPUT);
  digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT);
  digitalWrite(gndPin, LOW);

  delay(500); // wait for MAX chip to stabilize
}

void loop()
{
  lcd.setCursor(0,1);
  lcd.print(thermocouple.readCelsius());
  lcd.print(0, BYTE);
  lcd.print("C  ");
  lcd.print(thermocouple.readFarenheit());
  lcd.print(0, BYTE);
  lcd.print('F');

  delay(500);
}

And the result should be something like this

Leave a Reply