Arduino Thermocouple Nokia 5110 LCD

578

8

Connection between them is written in sketch itself.
This setup can be used in motorcycle for engine temperature reading. And we can add more things like relay switch which will shut down engine by shorting ignition system after a particular temperature is achieved.



Step 1: Sketch

Sketch

//so to dp 8 sck to dp 9 cs dp 10
#define CC 10 //cs
#define CLK 9 //sck
#define DBIT 8 // so
#include
#include
#include
#include
Adafruit_PCD8544 display=Adafruit_PCD8544(7,6,5,4,3);
//Connect pins 1-5 of nokia 5110 LCD to pins 3-7 on your arduino
//So RST would be arduino pin 3,CE would go to pin 4 and so on
int v = 0; float Ctemp, Ftemp;
void setup()
{
Serial.begin(9600);
display.begin();
pinMode(CLK, OUTPUT);
pinMode(DBIT, INPUT);
pinMode(CC, OUTPUT);
digitalWrite(CC, HIGH);
digitalWrite(CLK, LOW);
}
void loop()
{
v = spiRead();
if (v == -1)
{
display.setCursor(20,30); display.print(Ftemp);
}
else
{
Ctemp = v * 0.25;
Ftemp = (Ctemp * 9 / 5) + 32; display.clearDisplay(); display.setCursor(10,0); display.println("Engine Temp"); display.setCursor(20,15); display.print(Ctemp);
display.println(" *C"); display.setCursor(20,30); display.print(Ftemp);
display.print(" F");
display.display();
}
delay(500);
}
int spiRead()
{
int value = 0;
digitalWrite(CC,LOW);
delay(2);
digitalWrite(CC,HIGH);
delay(220);
/* Read the chip and return the raw temperature value */ /* Bring CC pin low to allow us to read the data from the conversion process */
digitalWrite(CC,LOW);
/* Cycle the clock for dummy bit 15 */ digitalWrite(CLK,HIGH);
delay(1);
digitalWrite(CLK,LOW);
/* Read bits 14-3 from MAX6675 for the Temp. Loop for each bit reading the value and storing the final value in 'temp' */
for (int i=14; i>=0; i--)
{
digitalWrite(CLK,HIGH);
value += digitalRead(DBIT) << i; digitalWrite(CLK,LOW);
}
// check bit D2 if HIGH no sensor
if ((value & 0x04) == 0x04) return -1;
// shift right three places
return value >> 3;
}

Step 2:

Share

    Recommendations

    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Beauty Tips Contest

      Beauty Tips Contest
    • Pets Challenge

      Pets Challenge

    Discussions