nanoFramework.Iot.Device.Max31856 1.0.258

Install-Package nanoFramework.Iot.Device.Max31856 -Version 1.0.258
dotnet add package nanoFramework.Iot.Device.Max31856 --version 1.0.258
<PackageReference Include="nanoFramework.Iot.Device.Max31856" Version="1.0.258" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.Iot.Device.Max31856 --version 1.0.258
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: nanoFramework.Iot.Device.Max31856, 1.0.258"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install nanoFramework.Iot.Device.Max31856 as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Max31856&version=1.0.258

// Install nanoFramework.Iot.Device.Max31856 as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Max31856&version=1.0.258
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Max31856 - cold-junction compensated thermocouple to digital converter

The Max31856 device is a SPI interface cold-junction compensated thermocouple to digital converter.

Illustration of wiring from an ESP32 device

Note: ThermocoupleType.K is configured for a K type thermocouple if you want to use a B,E,J,K,N,R,S, or T simply change the K to the thermocouple type of your choosing.

Documentation

Usage

Important: make sure you properly setup the SPI pins especially for ESP32 before creating the SpiDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the SPI GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(22, DeviceFunction.SPI1_MISO);
Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK);
// Make sure as well you are using the right chip select

For other devices like STM32, please make sure you're using the preset pins for the SPI bus you want to use. The chip select can as well be pre setup.

The Max31856.samples file contains a sample usage of the device. Note that this reads two temperatures. One is a connected thermocouple reading which can be read using the TryGetTemperature command and the other is the temperature of the device itself which can be read using the GetColdJunctionTemperature command. The Cold Junction Temperature is used internally to increase the accuracy of the thermocouple but can also be read if you find a use for it.

Create a new SpiConnectionSettings Class if using a MCU do not change these settings.

SpiConnectionSettings settings = new(1, 42)
{
    ClockFrequency = Max31856.SpiClockFrequency,
    Mode = Max31856.SpiMode,
    DataFlow = 0
};

Create a new SpiDevice with the settings from above. Then create a new Max31856 device with the SpiDevice as well as the correct ThermocoupleType (see note below)

using SpiDevice device = SpiDevice.Create(settings);
using Max31856 sensor = new(device, ThermocoupleType.K);

Now read the temperature from the device. Using the UnitsNet nuget you can see the units of your choosing. In this example you chan changeDegreesFahrenheit to DegreesCelsius or any other unit by changing .GetTemperature().DegreesFahrenheit to another unit of your choice.

while (true)
{
    Temperature tempColdJunction = sensor.GetColdJunctionTemperature();
    Debug.WriteLine($"Temperature: {tempColdJunction.DegreesCelcius} ℃");
    Thread.Sleep(2000);
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.258 0 12/7/2021
1.0.221 38 10/19/2021
1.0.219 57 10/19/2021
1.0.218 80 10/18/2021
1.0.157 48 9/4/2021
1.0.155 44 8/31/2021
1.0.153 39 8/14/2021
1.0.151 52 8/6/2021
1.0.146 43 7/22/2021
1.0.136 116 7/17/2021
1.0.135 43 7/16/2021
1.0.134 54 7/15/2021
1.0.133 40 7/14/2021
1.0.131 54 7/8/2021
1.0.129 49 7/6/2021
1.0.127 58 7/5/2021
1.0.125 79 7/5/2021
1.0.122 69 6/30/2021
1.0.121 60 6/29/2021
1.0.119 92 6/28/2021
1.0.111 63 6/14/2021
1.0.105 54 5/29/2021
1.0.104 123 5/29/2021
1.0.97 58 5/28/2021
1.0.42 78 5/24/2021