/* * File: scd4x.h * Description: Sensirion SCD4x sensor communication library * Author: David Zaitlik * Date: 2022-06-08 * * * Copyright (c) 2024 Veles Labs s.r.o. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ #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_ */