✅ 목표 (Goal)

앞서 배운 sht85_t는 온,습도 값을 돌려주는 함수 인데,

MCU와 센서간 통신에 문제가 생긴다면, 에러를 돌려준다.

이때 온습도 값은 의미가 없는 값이다.

✅ sht85 에러 코드

▼ RobTillaart/SHT85

https://github.com/RobTillaart/SHT85

#define SHT_OK					0x00 // no error
#define SHT_ERR_WRITECMD		0x81 // I2C write failed
#define SHT_ERR_READBYTES		0x82 // I2C read failed
#define SHT_ERR_HEATER_OFF		0x83 // Could not switch off heater
#define SHT_ERR_NOT_CONNECT		0x84 // Could not connect
#define SHT_ERR_CRC_TEMP		0x85 // CRC error in temperature
#define SHT_ERR_CRC_HUM			0x86 // CRC error in humidity
#define SHT_ERR_CRC_STATUS		0x87 // CRC error in status field
#define SHT_ERR_HEATER_COOLDOWN 0x88 // Heater need to cool down
#define SHT_ERR_HEATER_ON 		0x89 // Could not switch on heater
#define SHT_ERR_SERIAL			0x8A // Could not read serial number
typedef enum _sht85_err_t {
	SHT_OK=					0x00, // no error
	SHT_ERR_WRITECMD=   	0x81, // I2C write failed
	SHT_ERR_READBYTES=  	0x82, // I2C read failed
	SHT_ERR_HEATER_OFF= 	0x83, // Could not switch off heater
	SHT_ERR_NOT_CONNECT=	0x84, // Could not connect
	SHT_ERR_CRC_TEMP=		0x85, // CRC error in temperature
	SHT_ERR_CRC_HUM=		0x86, // CRC error in humidity
	SHT_ERR_CRC_STATUS= 	0x87, // CRC error in status field
	SHT_ERR_HEATER_COOLDOWN=0x88, // Heater need to cool down
	SHT_ERR_HEATER_ON=		0x89, // Could not switch on heater
	SHT_ERR_SERIAL=			0x8A, // Could not read serial number
} sht85_err_t

이렇게?

typedef struct _sht85_t {
	float temp;
	float humi;
	err_t err;
} sht85_t;

void sht85_read(sht85_t* sht85);