# SCD4X
**Repository Path**: libdriver/scd4x
## Basic Information
- **Project Name**: SCD4X
- **Description**: 适用于通用MCU和Linux系统的SCD4X(SCD40, SCD41)全功能驱动
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-01-07
- **Last Updated**: 2025-05-05
## Categories & Tags
**Categories**: Uncategorized
**Tags**: IIC, 二氧化碳
## README
[English](/README.md) | [ 简体中文](/README_zh-Hans.md) | [繁體中文](/README_zh-Hant.md) | [日本語](/README_ja.md) | [Deutsch](/README_de.md) | [한국어](/README_ko.md)
## LibDriver SCD4X
[](/misra/README.md) [](https://www.libdriver.com/docs/scd4x/index.html) [](/LICENSE)
SCD4x是Sensionon的下一代微型二氧化碳传感器。该传感器基于光声NDIR传感原理和Sensionon的专利PASens®和CMOSens®技术,提供无与伦比的价格和最小封装的高精度解决方案。SMD组件允许传感器的成本和空间有效集成,并具有最大的设计自由度。芯片上的信号补偿是通过内置SHT4x湿度和温度传感器实现的。二氧化碳是室内空气质量(IAQ)的一个关键指标,因为高水平的二氧化碳会损害人类的认知能力和幸福感。SCD4x使智能通风系统能够以最节能、最人性化的方式调节通风。此外,基于SCD4x的室内空气质量监测器和其他连接设备有助于保持低二氧化碳浓度,营造健康、高效的环境。
LibDriver SCD4X是LibDriver推出的SCD4X全功能驱动,该驱动提供CO2读取、温度读取、湿度读取等功能并且它符合MISRA标准。
### 目录
- [说明](#说明)
- [安装](#安装)
- [使用](#使用)
- [example basic](#example-basic)
- [example shot](#example-shot)
- [文档](#文档)
- [贡献](#贡献)
- [版权](#版权)
- [联系我们](#联系我们)
### 说明
/src目录包含了LibDriver SCD4X的源文件。
/interface目录包含了LibDriver SCD4X与平台无关的IIC总线模板。
/test目录包含了LibDriver SCD4X驱动测试程序,该程序可以简单的测试芯片必要功能。
/example目录包含了LibDriver SCD4X编程范例。
/doc目录包含了LibDriver SCD4X离线文档。
/datasheet目录包含了SCD4X数据手册。
/project目录包含了常用Linux与单片机开发板的工程样例。所有工程均采用shell脚本作为调试方法,详细内容可参考每个工程里面的README.md。
/misra目录包含了LibDriver MISRA代码扫描结果。
### 安装
参考/interface目录下与平台无关的IIC总线模板,完成指定平台的IIC总线驱动。
将/src目录,您使用平台的接口驱动和您开发的驱动加入工程,如果您想要使用默认的范例驱动,可以将/example目录加入您的工程。
### 使用
您可以参考/example目录下的编程范例完成适合您的驱动,如果您想要使用默认的编程范例,以下是它们的使用方法。
#### example basic
```C
#include "driver_scd4x_basic.h"
uint8_t res;
uint32_t i;
uint32_t times = 3;
uint16_t co2_ppm;
float temperature;
float humidity;
/* basic init */
res = scd4x_basic_init(SCD41);
if (res != 0)
{
return 1;
}
...
/* loop */
for (i = 0; i < times; i++)
{
/* delay 5000ms */
scd4x_interface_delay_ms(5000);
/* read data */
res = scd4x_basic_read((uint16_t *)&co2_ppm, (float *)&temperature, (float *)&humidity);
if (res != 0)
{
(void)scd4x_basic_deinit();
return 1;
}
/* output */
scd4x_interface_debug_print("scd4x: %d/%d.\n", (uint32_t)(i + 1), (uint32_t)times);
scd4x_interface_debug_print("scd4x: co2 is %02dppm.\n", co2_ppm);
scd4x_interface_debug_print("scd4x: temperature is %0.2fC.\n", temperature);
scd4x_interface_debug_print("scd4x: humidity is %0.2f%%.\n", humidity);
...
}
...
/* basic deinit */
(void)scd4x_basic_deinit();
return 0;
```
#### example shot
```C
#include "driver_scd4x_shot.h"
uint8_t res;
uint32_t i;
uint32_t times = 3;
uint16_t co2_ppm;
float temperature;
float humidity;
/* shot init */
res = scd4x_shot_init(SCD41);
if (res != 0)
{
return 1;
}
...
/* loop */
for (i = 0; i < times; i++)
{
/* delay 5000ms */
scd4x_interface_delay_ms(5000);
/* read data */
res = scd4x_shot_read((uint16_t *)&co2_ppm, (float *)&temperature, (float *)&humidity);
if (res != 0)
{
(void)scd4x_shot_deinit();
return 1;
}
/* output */
scd4x_interface_debug_print("scd4x: %d/%d.\n", (uint32_t)(i + 1), (uint32_t)times);
scd4x_interface_debug_print("scd4x: co2 is %02dppm.\n", co2_ppm);
scd4x_interface_debug_print("scd4x: temperature is %0.2fC.\n", temperature);
scd4x_interface_debug_print("scd4x: humidity is %0.2f%%.\n", humidity);
...
}
...
/* shot deinit */
(void)scd4x_shot_deinit();
return 0;
```
### 文档
在线文档: [https://www.libdriver.com/docs/scd4x/index.html](https://www.libdriver.com/docs/scd4x/index.html)。
离线文档: /doc/html/index.html。
### 贡献
请参考CONTRIBUTING.md。
### 版权
版权 (c) 2015 - 现在 LibDriver 版权所有
MIT 许可证(MIT)
特此免费授予任何获得本软件副本和相关文档文件(下称“软件”)的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、转授许可和/或出售该软件副本,以及再授权被配发了本软件的人如上的权利,须在下列条件下:
上述版权声明和本许可声明应包含在该软件的所有副本或实质成分中。
本软件是“如此”提供的,没有任何形式的明示或暗示的保证,包括但不限于对适销性、特定用途的适用性和不侵权的保证。在任何情况下,作者或版权持有人都不对任何索赔、损害或其他责任负责,无论这些追责来自合同、侵权或其它行为中,还是产生于、源于或有关于本软件以及本软件的使用或其它处置。
### 联系我们
请联系lishifenging@outlook.com。