Skip to content

MAX31855开发板使用

MAX31855

The MAX31855 is a sophisticated thermocouple-to-digital converter with a built-in 14-bit analog-to-digital converter \(ADC\). The device also contains cold-junction compensation sensing and correction, a digital controller, an SPIcompatible interface, and associated control logic.

Drive CS low to output the first bit on the SO pin. A complete serial-interface read of the cold-junction compensated thermocouple temperature requires 14 clock cycles. Thirty-two clock cycles are required to read both the thermocouple and reference junction temperatures \(Table 2 and Table 3.\) The first bit, D31, is the thermocouple temperature sign bit, and is presented to the SO pin within tDV of the falling edge of CS. Bits D[30:18] contain the converted temperature in the order of MSB to LSB, and are presented to the SO pin within tD0 of the falling edge of SCK. Bit D16 is normally low and goes high when the thermocouple input is open or shorted to GND or VCC. The reference junction temperature data begins with D15. CS can be taken high at any point while clocking out conversion data. If T+ and T- are unconnected, the thermocouple temperature sign bit \(D31\) is 0, and the remainder of the thermocouple temperature value \(D\[30:18\]\) is 1.From above graphic, it can be seen MAX31855 SPI mode 0.

D13~D18 is thermal coupler hot point temperature.

MAX31855 Arduino Function
Vin 5V 5V
GND GND GND
DO 12 MISO
CS 10 or other SS
CLK 13 SCK

代码

代码修改自此链接

打开下面的实例文件,上传到开发板。

#include <SPI.h>

//Additionally, connect the MAX6675 as follows:
//MISO  Arduino pin 12          //master in slave out
//SCK   Arduino pin 13          //serial clock
const int CS = 10;

void setup() {
  Serial.begin(9600);
  pinMode(CS, OUTPUT);
  digitalWrite(CS, HIGH);  
  SPI.begin();                            //initialize SPI
  delay(500);
}

void loop() {
   unsigned int tcData;
   float temp, avgTemp;
   uint32_t d = 0;
   digitalWrite(CS, LOW);
   SPI.beginTransaction(SPISettings(4300000, MSBFIRST, SPI_MODE1));
   tcData = SPI.transfer(0x00) << 8;
   tcData |= SPI.transfer(0x00);  
   digitalWrite(CS, HIGH);
   if (tcData & 0x0004) {                  //open thermocouple circuit
        Serial.println("Thermal Coupler Open."); 
    }
    else {
   temp = (tcData >> 3) / 4.0;
   Serial.print("C = "); 
   Serial.println(temp); 
    }
   delay(1000);
}

MQTT

服务器 Mosquitto
MQTT messaging for Raspberry Pi \(or Python\), Paho Python Client

Arduino Client, PubSubClient