GithubHelp home page GithubHelp logo

enjoyneering / max31855 Goto Github PK

View Code? Open in Web Editor NEW
25.0 4.0 9.0 147 KB

Arduino library for 14-bit MAX31855 K-thermocouple to digital converter

C++ 100.00%
thermocouple max31855 arduino-library temperature-sensor

max31855's Introduction

license-badge version stars hit-count github-issues

MAX31855

This is an Arduino library for 14-bit MAX31855 K-thermocouple to digital converter with 12-bit cold junction compensation & maximum sampling rate about 10Hz. Supports all sensor features. Can work with hardware or software emulated 3-wire SPI.

  • Maximum power supply voltage is 3.6v
  • K-type thermocouples have an absolute accuracy of around ±2°C..±6°C.
  • Measurement tempereture range -200°C..+700°C ±2°C or -270°C..+1372°C ±6°C with 0.25°C resolution/increment.
  • Maximun SPI bus speed 5Mhz
  • Cold junction compensation range -40°C..+125° ±3°C with 0.062°C resolution/increment. Optimal performance of cold junction compensation happends when the thermocouple cold junction & the MAX31855 are at the same temperature. Avoid placing heat-generating devices or components near the converter because this may produce an errors.
  • It is STRONGLY recommended to add a 10nF/0.01mF capacitor, placed across the T+ and T- pins, to filter noise/false readings on the thermocouple lines.

**Library returns 2000, if thermocouple open/shorted or a communication error has occurred

Supports:

  • Arduino AVR
  • Arduino ESP8266
  • Arduino ESP32
  • Arduino STM32

Beware of a fake MAX31855 K-Thermocouple Sensor Module

max31855's People

Contributors

enjoyneering avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

max31855's Issues

In the case we read ZERO, IC could be faulty or not connected!

Today i got the case, i burned an max31855 and got an nice 0°C reading. After many trial and error i used my logic-analyzer to check whats going on, and the maxims DO-PIN have bin LOW all the time.
After reading the datasheet again, there is only one very very rare case, when you can read out (all) ZERO, only when Thermocouple-Temp. AND Junction-Temp. is 0°C. My personal point-of-view is, that the MAX31855 is mostly used in cases where thermocouple-temp is going over 100°C and junction-temp not lower then 10°C, the case that both are truly read out 0°C is lower then winning in lottery. So i think we can ignore this case as a good reading. A faulty, not proper connected or fake chip should be a more common case.

So i think, it would be an good idea to handle this case in MAX31855::detectThermocouple

// MAX31855.cpp
uint8_t MAX31855::detectThermocouple(int32_t rawValue)
{
  if (rawValue == MAX31855_FORCE_READ_DATA) rawValue = readRawData();

  if (bitRead(rawValue, 16) == 1)
  {
    if      (bitRead(rawValue, 2) == 1) return MAX31855_THERMOCOUPLE_SHORT_TO_VCC;
    else if (bitRead(rawValue, 1) == 1) return MAX31855_THERMOCOUPLE_SHORT_TO_GND;
    else if (bitRead(rawValue, 0) == 1) return MAX31855_THERMOCOUPLE_NOT_CONNECTED;
    else                                return MAX31855_THERMOCOUPLE_UNKNOWN;
  }
  #ifndef MAX31855_CAN_BE_ZERO
    if (rawValue == 0) return MAX31855_READ_FAIL;
  #endif
  return MAX31855_THERMOCOUPLE_OK;
}
// MAX31855.h
#define MAX31855_THERMOCOUPLE_OK            0
#define MAX31855_THERMOCOUPLE_SHORT_TO_VCC  1
#define MAX31855_THERMOCOUPLE_SHORT_TO_GND  2
#define MAX31855_THERMOCOUPLE_NOT_CONNECTED 3
#define MAX31855_THERMOCOUPLE_UNKNOWN       4
#define MAX31855_READ_FAIL       5

Filter Capacitor

I added a comment that I later realized was not correct. I have withdrawn that.

F("string") at blue pill stm32 boards hangs it

Hi!

First of all -thanks for the code.

Code works on Blue Pill, but only after I remove println(F("string")) structures. Otherwise I do not have hardware USB serial debug(and nothing happens at all).
I recommend reworking those lines.

Best regards,
Fedor.

Missing "virtual" declaration in MAX31855.h

Hi - Great work.

In order to get the Soft SPI version to work the "virtual" declaration of:

int32_t readRawData(void);

In MAX21855.h line 95 must be added to be:

virtual int32_t readRawData(void);

Otherwise the bit bang method of the derived class (MAX31855soft) is not called from the parent class when reading data.

BR

Stego72

Temperature Readings About 2 X Too High

I'm using your unmodified "MAX31855_sw_SPI_Demo" sketch with a MAX31855 and a NodeMCU-32S (ESP32). The only change I have made to the sketch is:

MAX31855soft myMAX31855(5, 19, 23); //for ESP8266 use D3, D4, D7

I'm getting a temperature reading on both "getColdJunctionTemperature()" and "getTemperature()" of nearly 2x what it should be.

I have checked the thermocouple with a dedicated thermocouple measuring meter, and it is correctly showing the TC at room temperature (about 28 degrees C right now). But with the same thermocouple and environment, the internal and external readings from your library are both giving me around 67 degrees C.

I have also swapped the Adafruit MAX31855 library into my sketch, and it also reports around 28 degrees from the same circuit, which is correct.

What could be causing a high-temperature reading of both the internal and external temperatures from your library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.