max31865

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i max31865

Weekly Downloads

12

Version

1.0.3

License

MIT

Unpacked Size

13.6 kB

Total Files

8

Last publish

Collaborators

  • mariusrumpf