55 lines
1003 B
C
55 lines
1003 B
C
/*
|
|
* sht4x.h
|
|
*
|
|
* Created on: Jun 8, 2021
|
|
* Author: user
|
|
*/
|
|
|
|
#ifndef INC_SCD4X_H_
|
|
#define INC_SCD4X_H_
|
|
|
|
#include "stdint.h"
|
|
|
|
/*
|
|
* Defines & macros
|
|
*/
|
|
|
|
#define SCD4X_I2C_ADDRESS 0x62
|
|
|
|
/*
|
|
* Return values
|
|
*/
|
|
|
|
#define SCD4X_OK 0
|
|
#define SCD4X_ERROR -1 // generic error
|
|
#define SCD4X_CRC8_ERROR -2 // checksum failed
|
|
|
|
/*
|
|
* Data types
|
|
*/
|
|
|
|
typedef enum {
|
|
SCD4X_START_PERIODIC_MEASUREMENT = 0x21B1,
|
|
SCD4X_READ_MEASUREMENT = 0xEC05,
|
|
SCD4X_STOP_PERIODIC_MEASUREMENT = 0x3F86,
|
|
SCD4X_GET_DATA_READY_STATUS = 0xE4B8,
|
|
SCD4X_PERFORM_FACTORY_RESET = 0x3632,
|
|
SCD4X_GET_SERIAL_NUMBER = 0x3682
|
|
} scd4x_cmd_t;
|
|
|
|
/*
|
|
* Function prototypes
|
|
*/
|
|
|
|
int8_t scd4x_send_cmd(scd4x_cmd_t cmd);
|
|
int8_t scd4x_read_data(uint8_t *buffer, int len);
|
|
|
|
int8_t scd4x_start_periodic_measurement( void );
|
|
int8_t scd4x_stop_periodic_measurement( void );
|
|
|
|
int8_t scd4x_perform_factory_reset( void );
|
|
|
|
int8_t scd4x_read_measurement(uint16_t * co2, int16_t *temperature, uint16_t *relative_humidity);
|
|
|
|
#endif /* INC_SCD4X_H_ */
|