/* * File: sgp40.h * Description: Sensirion SGP40 sensor communication library * Author: David Zaitlik * Date: 2022-01-09 * * * 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_SGP40_H_ #define INC_SGP40_H_ #include "stdint.h" /* * Defines & macros */ #define SGP40_I2C_ADDRESS 0x59 #define SGP40_MAX_MEAS_DURATION_MS 50 /* * Return values */ #define SGP40_OK 0 #define SGP40_ERROR -1 // generic error #define SGP40_CRC8_ERROR -2 // checksum failed typedef enum { SGP40_MEASURE_RAW_SIGNAL = 0x260F, SGP40_EXECUTE_SELF_TEST = 0x280E, SGP40_TURN_HEATER_OFF = 0x3615, SGP40_GET_SERIAL_NUMBER = 0x3682, SGP40_SOFT_RESET = 0x0006 } sgp40_cmd_t; int8_t sgp40_send_cmd(sgp40_cmd_t cmd); int8_t sgp40_measure_raw_signal (uint16_t * voc_ticks); int8_t sgp40_measure_raw_signal_compensated (uint16_t * voc_ticks, uint16_t relative_humidity, int16_t temperature); int8_t sgp40_execute_self_test ( uint8_t * test_result); int8_t sgp40_get_serial_number ( uint8_t serial[6]); int8_t sgp40_turn_heater_off ( void ); int8_t sgp40_soft_reset ( void ); #endif /* INC_SGP40_H_ */