A Library for the AMS ENS210 temperature and humidity sensor.
Dependents: AMS_CCS811_gas_sensor AMS_CCS811_gas_sensor
Diff: AMS_ENS210.h
- Revision:
- 3:3b427231e5a7
- Parent:
- 1:94a79c88c105
- Child:
- 5:22b8ef3a65e1
--- a/AMS_ENS210.h Wed Jan 18 08:54:58 2017 +0000 +++ b/AMS_ENS210.h Wed Jan 18 12:04:25 2017 +0000 @@ -14,9 +14,9 @@ /* Library defaults */ -#define CONFIG_TEMP_OP_MODE 1 -#define CONFIG_HUMID_OP_MODE 1 -#define CONFIG_POWER_MODE 1 +#define CONFIG_TEMP_OP_MODE 0 // single shot +#define CONFIG_HUMID_OP_MODE 0 // single shot +#define CONFIG_POWER_MODE 1 // low power /* Library Constants */ #define SLAVE_ADDR_RAW 0x43 @@ -48,19 +48,19 @@ /** Create an AMS_ENS210 instance * * @param i2c The I2C interface to use for communication - * @param temp_single_shot Set tempurature operation mode, true for single shot and false for continuious - * @param humid_single_shot Set humidity operation mode, true for single shot and false for continuious + * @param temp_continuous Set tempurature operation mode, true for continuous and false for single shot + * @param humid_continuous Set humidity operation mode, true for continuous and false for single shot */ - AMS_ENS210(I2C * i2c, bool temp_single_shot, bool humid_single_shot); + AMS_ENS210(I2C * i2c, bool temp_continuous, bool humid_continuous); /** Create an AMS_ENS210 instance * * @param i2c The I2C interface to use for communication - * @param temp_single_shot Set tempurature operation mode, true for single shot and false for continuious - * @param humid_single_shot Set humidity operation mode, true for single shot and false for continuious + * @param temp_continuous Set tempurature operation mode, true for continuous and false for single shot + * @param humid_continuous Set humidity operation mode, true for continuous and false for single shot * @param low_power Set power mode, true for low power/standby and false for active */ - AMS_ENS210(I2C * i2c, bool temp_single_shot, bool humid_single_shot, bool low_power); + AMS_ENS210(I2C * i2c, bool temp_continuous, bool humid_continuous, bool low_power); /** Destroy the AMS_ENS210 instance */ @@ -84,41 +84,47 @@ * * @return Write success */ - bool power_mode(bool low_power); + bool low_power_mode(bool low_power); /** Get the current power mode * * @return The power mode, true for low power, false for active */ - bool power_mode(); + bool low_power_mode(); + + /** Get whether the sensor is in the active state or not + * + * @return The active state, true for active, false for inactive + */ + bool is_active(); /** Set the tempurature operation mode * - * @param single_shot True for single shot and false for continuious + * @param single_shot True for continuous and false for single shot * * @return Write success */ - bool temp_mode(bool single_shot); + bool temp_continuous_mode(bool continuous); /** Get the current tempurature operation mode * - * @return The tempurature operation mode, true for single shot, false for continuious + * @return Write success */ - bool temp_mode(); + bool temp_continuous_mode(); /** Set the humidity operation mode * - * @param single_shot True for single shot and false for continuious + * @param single_shot True for continuous and false for single shot * * @return Write success */ - bool humid_mode(bool single_shot); + bool humid_continuous_mode(bool continuous); /** Get the current humidity operation mode * - * @return The humidity operation mode, true for single shot, false for continuious + * @return Write success */ - bool humid_mode(); + bool humid_continuous_mode(); /** Set the I2C interface * @@ -185,13 +191,14 @@ bool _temp_mode; bool _humid_mode; bool _power_mode; - bool _reset = 0; - uint16_t temp_reading = 0; - uint16_t humid_reading = 0; + bool _reset; + uint16_t temp_reading; + uint16_t humid_reading; bool write_config(bool system = true, bool sensor = true); const char * read_config(bool system = true, bool sensor = true); int i2c_read(char reg_addr, char* output, int len); + int i2c_write(char reg_addr, char* input, int len);