![]() |
VOOZH | about |
dotnet add package nanoFramework.Iot.Device.Scd4x --version 1.0.1
NuGet\Install-Package nanoFramework.Iot.Device.Scd4x -Version 1.0.1
<PackageReference Include="nanoFramework.Iot.Device.Scd4x" Version="1.0.1" />
<PackageVersion Include="nanoFramework.Iot.Device.Scd4x" Version="1.0.1" />Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Scd4x" />Project file
paket add nanoFramework.Iot.Device.Scd4x --version 1.0.1
#r "nuget: nanoFramework.Iot.Device.Scd4x, 1.0.1"
#:package nanoFramework.Iot.Device.Scd4x@1.0.1
#addin nuget:?package=nanoFramework.Iot.Device.Scd4x&version=1.0.1Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Scd4x&version=1.0.1Install as a Cake Tool
The SCD4x is Sensirion's next generation miniature CO2 sensor. This sensor builds on the photoacoustic sensing principle and Sensirion's patented PAsens(r) and CMOSens(r) technology to offer high accuracy at an unmatched price and smallest form factor.
Important: make sure you properly setup the I2C pins especially for ESP32 before creating the I2cDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:
//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(23, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
For other devices like STM32, please make sure you're using the preset pins for the I2C bus you want to use.
I2cConnectionSettings settings = new(1, Scd4x.I2cDefaultAddress);
using I2cDevice device = I2cDevice.Create(settings);
using Scd4x sensor = new(device);
sensor.StopPeriodicMeasurement();
var serialNumber = sensor.GetSerialNumber();
Console.WriteLine($"Serial number: {serialNumber}");
var offset = sensor.GetTemperatureOffset();
Console.WriteLine($"Temperature offset: {offset.DegreesCelsius}");
sensor.SetTemperatureOffset(Temperature.FromDegreesCelsius(4));
offset = sensor.GetTemperatureOffset();
Console.WriteLine($"New temperature offset: {offset.DegreesCelsius}");
sensor.StartPeriodicMeasurement();
while (true)
{
if (!sensor.IsDataReady())
{
Thread.Sleep(1000);
continue;
}
var data = sensor.ReadData();
Console.WriteLine($"Temperature: {data.Temperature.DegreesCelsius} \u00B0C");
Console.WriteLine($"Relative humidity: {data.RelativeHumidity.Percent} %RH");
Console.WriteLine($"CO2: {data.CO2} PPM");
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net net is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 289 | 9/10/2024 |