Snippet Tag: k type thermocouple

K type thermocouple mcp9600 arduino code

#include<Wire.h> #define Addr 0x64 long data1; long data2; long temp; byte stat; void setup() { // Initialise I2C communication Wire.begin(); // Initialise Serial Communication, set baud rate = 9600 Serial.begin(9600); temrmo_set(); device_set(); } ///// this function will read the hot and cold junction temp int read_temp() { Wire.beginTransmission(Addr); Wire.write(0x00); Wire.endTransmission(); Wire.requestFrom(Addr, 2); if (Wire.available() == 2) { data1 = Wire.read(); data2 = Wire.read(); // Serial.println(data1); // Serial.println(data2); if((data1 & 0x80) == 0x80) { data1 = data1 & 0x7F; temp = 1024 – ( data1 * 16 + data2/16); Serial.print("Temperature :"); Serial.print(temp); Serial.println("n"); } else data1 = data1 *16; data2 =

Read More »