nanoFramework.Iot.Device.Max31856 2.0.0-preview.49

Prefix Reserved
This is a prerelease version of nanoFramework.Iot.Device.Max31856.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Max31856 --version 2.0.0-preview.49
                    
NuGet\Install-Package nanoFramework.Iot.Device.Max31856 -Version 2.0.0-preview.49
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Max31856" Version="2.0.0-preview.49" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Max31856" Version="2.0.0-preview.49" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Max31856" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Max31856 --version 2.0.0-preview.49
                    
#r "nuget: nanoFramework.Iot.Device.Max31856, 2.0.0-preview.49"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Max31856@2.0.0-preview.49
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Max31856&version=2.0.0-preview.49&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Max31856&version=2.0.0-preview.49&prerelease
                    
Install as a Cake Tool

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);
}
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0-preview.85 45 6/1/2026
2.0.0-preview.80 48 5/27/2026
2.0.0-preview.73 52 5/20/2026
2.0.0-preview.69 52 5/18/2026
2.0.0-preview.62 52 5/13/2026
2.0.0-preview.49 50 5/4/2026
2.0.0-preview.45 62 4/29/2026
2.0.0-preview.37 56 4/22/2026
2.0.0-preview.32 54 4/20/2026
2.0.0-preview.16 62 3/10/2026
1.2.952 127 3/4/2026
1.2.931 314 11/10/2025
1.2.907 260 10/2/2025
1.2.889 275 7/28/2025
1.2.869 363 4/2/2025
1.2.864 311 4/2/2025
1.2.852 320 3/11/2025
1.2.846 322 3/10/2025
1.2.822 281 2/26/2025
1.2.775 276 2/4/2025
Loading failed