-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm300d2.h
48 lines (37 loc) · 980 Bytes
/
sm300d2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef _LIB_SM300D2_H_
#define _LIB_SM300D2_H_
#include "stdint.h"
#include "stdbool.h"
#include "freertos/FreeRTOS.h"
#define SM300D2_ADDRESS (0x3c)
#define SM300D2_VERSION (0x02)
typedef struct {
uint8_t address;
uint8_t version;
uint16_t e_co2_be;
uint16_t e_ch2o_be;
uint16_t tvoc_be;
uint16_t pm2_5_be;
uint16_t pm10_be;
int8_t temp_int;
uint8_t temp_frac;
uint8_t humi_int;
uint8_t humi_frac;
uint8_t checksum;
} __attribute__((packed)) sm300d2_packet_t;
typedef struct
{
uint32_t e_co2;
uint32_t e_ch2o;
uint32_t tvoc;
uint32_t pm2_5;
uint32_t pm10;
int32_t temp_centi;
uint32_t humi_centi;
} sm300d2_data_t;
bool sm300d2_check_packet(sm300d2_packet_t* packet);
void sm300d2_parse_data(sm300d2_packet_t* packet, sm300d2_data_t* data);
void sm300d2_init();
void sm300d2_receive_task();
bool sm300d2_read_data(sm300d2_data_t* data, TickType_t xTicksToWait);
#endif /* _LIB_SM300D2_H_ */