GY-63_MS5611/libraries/ACD10/ACD10.h

95 lines
2.0 KiB
C
Raw Normal View History

2023-10-05 07:57:37 -04:00
#pragma once
//
// FILE: ACD10.h
// AUTHOR: Rob Tillaart
// DATE: 2023-09-25
2024-06-06 11:40:49 -04:00
// VERSION: 0.2.0
2024-01-01 14:25:27 -05:00
// PURPOSE: Arduino library for for I2C ACD10 CO2 sensor
2023-10-05 07:57:37 -04:00
// URL: https://github.com/RobTillaart/ACD10
// http://www.aosong.com/en/products-77.html
#include "Arduino.h"
#include "Wire.h"
2024-06-06 11:40:49 -04:00
#define ACD10_LIB_VERSION (F("0.2.0"))
2023-10-05 07:57:37 -04:00
#define ACD10_DEFAULT_ADDRESS 0x2A
// ERROR CODES
// values <> 0 are errors.
#define ACD10_OK 0x00
#define ACD10_CRC_ERROR 0x01
#define ACD10_NOT_READY 0x10
#define ACD10_REQUEST_ERROR 0x11
class ACD10
{
public:
ACD10(TwoWire *wire = &Wire);
bool begin();
bool isConnected();
uint8_t getAddress();
2023-11-24 05:36:55 -05:00
// READ
2023-10-05 07:57:37 -04:00
bool preHeatDone();
uint32_t preHeatMillisLeft();
int requestSensor();
bool requestReady();
int readSensor();
uint32_t getCO2Concentration();
uint16_t getTemperature();
uint32_t lastRead();
void setRequestTime(uint8_t milliseconds = 80);
uint8_t getRequestTime();
2023-11-24 05:36:55 -05:00
// CALIBRATION (! read datasheet)
2023-10-05 07:57:37 -04:00
// 0 = manual 1 = auto
bool setCalibrationMode(uint8_t mode);
uint8_t readCallibrationMode();
bool setManualCalibration(uint16_t value);
uint16_t readManualCalibration();
2023-11-24 05:36:55 -05:00
// MISCELLANEOUS
2023-10-05 07:57:37 -04:00
void factoryReset();
bool readFactorySet();
2023-11-24 05:36:55 -05:00
void readFirmwareVersion(char * arr); // length(arr) > 11
void readSensorCode(char * arr); // length(arr) > 11
2023-10-05 07:57:37 -04:00
2023-11-24 05:36:55 -05:00
// DEBUG
int getLastError();
2023-10-05 07:57:37 -04:00
2023-10-11 10:18:21 -04:00
2023-10-05 07:57:37 -04:00
private:
2023-11-24 05:36:55 -05:00
uint8_t _address = 0x2A; // fixed
2023-10-05 07:57:37 -04:00
TwoWire* _wire;
int _command(uint8_t * arr, uint8_t size);
int _request(uint8_t * arr, uint8_t size);
uint8_t _crc8(uint8_t * arr, uint8_t size);
2024-01-01 14:25:27 -05:00
uint32_t _preHeatStart;
uint32_t _lastRead;
uint32_t _concentration; // why datasheet states 32 bit as 400-5000 fit in 16 bit??
uint16_t _temperature;
uint8_t _requestTime;
uint32_t _requestStart;
2023-10-05 07:57:37 -04:00
uint8_t _error;
};
// -- END OF FILE --