Skip to content

Node.js module for the MAX31865 thermocouple amplifier.

Notifications You must be signed in to change notification settings

MariusRumpf/max31865

Repository files navigation

MAX31865

Node.js module for the MAX31865 thermocouple amplifier using spi-device.

GitHub Actions status

Install

$ npm install --save max31865

Usage

const MAX31865 = require('max31865');
const sensor = new MAX31865(0, 0); // For /dev/spidev0.0

async function main() {
  await sensor.init();
  
  const tempC = await sensor.getTemperature();
};

main()
  .catch(console.error);

See examples/index.js for a full usage example.

API

Options

You can configure the used sensor using the following options for the constructor. This example shows the default values.

const sensor = new MAX31865(
  0, // bus - first digit in /dev/spidev0.0
  0, // device - second digit in /dev/spidev0.0
  {
    rtdNominal: 100, // nominal resistance of sensor
    refResistor: 430, // reference resistance on board
    wires: 2, // wires used for sensor (2, 3 or 4)
  }
);

Methods

init()

Has to be called once before all other methods. It initilizes the library and sensor for futher usage.

Returns a promise.

Usage example:

sensor.init()
  .then(() => {
    // Work with sensor
  });

getTemperature()

Reads the resistance of the sensor and returns the temperature in degree celsius.

Returns a promise resolving with the temperature value.

Usage example:

sensor.getTemperature()
  .then((temperature) => {
    console.log(`Temperature: ${temperature} °C`);
  });

getResistance()

Read the resistance value from the RTD in Ω.

Returns a promise resolving with the resistance value.

Usage example:

sensor.getResistance()
  .then((resistance) => {
    console.log(`Resistance: ${resistance} Ω`);
  });

getFaults()

Read out the integrated fault detection.

Returns a promise resolving with an object of faults and if they have been detected.

Usage example:

sensor.getFaults()
  .then((faults) => {
    console.log('Faults', faults);
  });

readRtd()

Reads the raw ADC convertered value from the RTD sensor.

Returns a promise resolving with the raw RTD value.

Usage example:

sensor.readRtd()
  .then((raw) => {
    console.log(`Raw RTD value: ${raw}`);
  });

Resources

About

Node.js module for the MAX31865 thermocouple amplifier.

Resources

Stars

Watchers

Forks

Packages

No packages published