nanoFramework.Iot.Device.Scd4x
1.0.1
Prefix Reserved
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" />
paket add nanoFramework.Iot.Device.Scd4x --version 1.0.1
#r "nuget: nanoFramework.Iot.Device.Scd4x, 1.0.1"
// Install nanoFramework.Iot.Device.Scd4x as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Scd4x&version=1.0.1 // Install nanoFramework.Iot.Device.Scd4x as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Scd4x&version=1.0.1
SCD4x - Temperature & Humidity & CO2 Sensor
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.
Documentation
- SCD4X datasheet
Usage
Hardware Required
- SCD4X
- Male/Female Jumper Wires
Circuit
- SCL - SCL
- SDA - SDA
- VCC - 3.3V
- GND - GND
Code
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 is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Buffers.Binary.BinaryPrimitives (>= 1.2.628)
- nanoFramework.System.Device.I2c (>= 1.1.16)
- UnitsNet.nanoFramework.RelativeHumidity (>= 5.56.0)
- UnitsNet.nanoFramework.Temperature (>= 5.56.0)
- UnitsNet.nanoFramework.VolumeConcentration (>= 5.56.0)
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.1 | 92 | 9/10/2024 |