Files
Smart-granary-code/components/JW01/include/JW01.h

41 lines
644 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <stdbool.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
#define JW01_UART_PORT 0
#define JW01_UART_TX_GPIO 43
#define JW01_UART_RX_GPIO 44
#define JW01_UART_BAUDRATE 9600
typedef struct {
float tvoc;
float hcho;
float co2;
bool tvoc_valid;
bool hcho_valid;
bool co2_valid;
} jw01_data_t;
/**
* @brief 初始化 JW01 UART 传感器UART0, TX=43, RX=44
*/
esp_err_t jw01_init(void);
/**
* @brief 读取一帧 JW01 数据
*
* @param out_data 输出数据
* @param timeout_ms 超时时间(ms)
*/
esp_err_t jw01_read(jw01_data_t *out_data, int timeout_ms);
#ifdef __cplusplus
}
#endif