LibDriver ENS160
Loading...
Searching...
No Matches
driver_ens160.c File Reference

driver ens160 source file More...

#include "driver_ens160.h"
#include <math.h>
Include dependency graph for driver_ens160.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "ScioSense ENS160"
 chip register definition
#define MANUFACTURER_NAME   "ScioSense"
#define SUPPLY_VOLTAGE_MIN   1.71f
#define SUPPLY_VOLTAGE_MAX   1.98f
#define MAX_CURRENT   79.0f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define ENS160_REG_PART_ID   0x00
 chip register definition
#define ENS160_REG_OPMODE   0x10
#define ENS160_REG_CONFIG   0x11
#define ENS160_REG_COMMAND   0x12
#define ENS160_REG_TEMP_IN   0x13
#define ENS160_REG_RH_IN   0x15
#define ENS160_REG_DEVICE_STATUS   0x20
#define ENS160_REG_DATA_AQI   0x21
#define ENS160_REG_DATA_TVOC   0x22
#define ENS160_REG_DATA_ECO2   0x24
#define ENS160_REG_DATA_ETOH   0x22
#define ENS160_REG_DATA_T   0x30
#define ENS160_REG_DATA_RH   0x32
#define ENS160_REG_DATA_MISR   0x38
#define ENS160_REG_GPR_WRITE   0x40
#define ENS160_REG_GPR_READ   0x48

Functions

uint8_t ens160_set_interface (ens160_handle_t *handle, ens160_interface_t interface)
 set the chip interface
uint8_t ens160_get_interface (ens160_handle_t *handle, ens160_interface_t *interface)
 get the chip interface
uint8_t ens160_set_addr_pin (ens160_handle_t *handle, ens160_address_t addr_pin)
 set the iic address pin
uint8_t ens160_get_addr_pin (ens160_handle_t *handle, ens160_address_t *addr_pin)
 get the iic address pin
uint8_t ens160_set_mode (ens160_handle_t *handle, ens160_mode_t mode)
 set mode
uint8_t ens160_get_mode (ens160_handle_t *handle, ens160_mode_t *mode)
 get mode
uint8_t ens160_soft_reset (ens160_handle_t *handle)
 soft reset
uint8_t ens160_set_interrupt_pin_polarity (ens160_handle_t *handle, ens160_pin_polarity_t polarity)
 set interrupt pin polarity
uint8_t ens160_get_interrupt_pin_polarity (ens160_handle_t *handle, ens160_pin_polarity_t *polarity)
 get interrupt pin polarity
uint8_t ens160_set_interrupt_pin_drive (ens160_handle_t *handle, ens160_pin_drive_t drive)
 set interrupt pin drive
uint8_t ens160_get_interrupt_pin_drive (ens160_handle_t *handle, ens160_pin_drive_t *drive)
 get interrupt pin drive
uint8_t ens160_set_general_purpose_read_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t enable)
 set general purpose read interrupt pin asserted
uint8_t ens160_get_general_purpose_read_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t *enable)
 get general purpose read interrupt pin asserted
uint8_t ens160_set_data_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t enable)
 set data interrupt pin asserted
uint8_t ens160_get_data_interrupt_pin_asserted (ens160_handle_t *handle, ens160_bool_t *enable)
 get data interrupt pin asserted
uint8_t ens160_set_interrupt (ens160_handle_t *handle, ens160_bool_t enable)
 enable or disable interrupt
uint8_t ens160_get_interrupt (ens160_handle_t *handle, ens160_bool_t *enable)
 get interrupt
uint8_t ens160_nop (ens160_handle_t *handle)
 nop
uint8_t ens160_get_app_version (ens160_handle_t *handle, uint8_t *major, uint8_t *minor, uint8_t *release)
 get app version
uint8_t ens160_clear (ens160_handle_t *handle)
 clear
uint8_t ens160_set_temperature_compensation (ens160_handle_t *handle, uint16_t raw)
 set temperature compensation
uint8_t ens160_get_temperature_compensation (ens160_handle_t *handle, uint16_t *raw)
 get temperature compensation
uint8_t ens160_set_humidity_compensation (ens160_handle_t *handle, uint16_t raw)
 set humidity compensation
uint8_t ens160_get_humidity_compensation (ens160_handle_t *handle, uint16_t *raw)
 get humidity compensation
uint8_t ens160_get_status (ens160_handle_t *handle, uint8_t *status)
 get status
uint8_t ens160_read_aqi (ens160_handle_t *handle, uint8_t *uba)
 read aqi
uint8_t ens160_read_tvoc (ens160_handle_t *handle, uint16_t *tvoc_ppb)
 read tvoc
uint8_t ens160_read_eco2 (ens160_handle_t *handle, uint16_t *eco2_ppm)
 read eco2
uint8_t ens160_read_etoh (ens160_handle_t *handle, uint16_t *etoh_ppb)
 read etoh
uint8_t ens160_get_calculation_temperature (ens160_handle_t *handle, uint16_t *raw)
 get calculation temperature
uint8_t ens160_get_calculation_humidity (ens160_handle_t *handle, uint16_t *raw)
 get calculation humidity
uint8_t ens160_get_checksum (ens160_handle_t *handle, uint8_t *checksum)
 get checksum
uint8_t ens160_set_params (ens160_handle_t *handle, uint8_t params[8])
 set params
uint8_t ens160_get_params (ens160_handle_t *handle, uint8_t params[8])
 get params
uint8_t ens160_get_params_output (ens160_handle_t *handle, uint8_t params[8])
 get params output
uint8_t ens160_temperature_convert_to_register (ens160_handle_t *handle, float celsius_deg, uint16_t *reg)
 convert the temperature to the register raw data
uint8_t ens160_temperature_convert_to_data (ens160_handle_t *handle, uint16_t reg, float *celsius_deg)
 convert the register raw data to the temperature
uint8_t ens160_humidity_convert_to_register (ens160_handle_t *handle, float percentage, uint16_t *reg)
 convert the humidity to the register raw data
uint8_t ens160_humidity_convert_to_data (ens160_handle_t *handle, uint16_t reg, float *percentage)
 convert the register raw data to the humidity
uint8_t ens160_resistance_convert_to_register (ens160_handle_t *handle, float ohm, uint16_t *reg)
 convert the resistance to the register raw data
uint8_t ens160_resistance_convert_to_data (ens160_handle_t *handle, uint16_t reg, float *ohm)
 convert the register raw data to the resistance
uint8_t ens160_resistance_split (ens160_handle_t *handle, uint8_t raw[8], uint16_t *resistance0, uint16_t *resistance1, uint16_t *resistance2, uint16_t *resistance3)
 resistance split
uint8_t ens160_irq_handler (ens160_handle_t *handle)
 irq handler
uint8_t ens160_init (ens160_handle_t *handle)
 initialize the chip
uint8_t ens160_deinit (ens160_handle_t *handle)
 close the chip
uint8_t ens160_set_reg (ens160_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t ens160_get_reg (ens160_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t ens160_info (ens160_info_t *info)
 get chip's information

Detailed Description

driver ens160 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

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.

Version
1.0.0
Author
Shifeng Li
Date
2026-02-23

history

Date Version Author Description
2026/02/23 1.0 Shifeng Li first upload

Definition in file driver_ens160.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "ScioSense ENS160"

chip register definition

chip name

Definition at line 43 of file driver_ens160.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 50 of file driver_ens160.c.

◆ ENS160_REG_COMMAND

#define ENS160_REG_COMMAND   0x12

additional system command register

Definition at line 58 of file driver_ens160.c.

◆ ENS160_REG_CONFIG

#define ENS160_REG_CONFIG   0x11

interrupt pin configuration register

Definition at line 57 of file driver_ens160.c.

◆ ENS160_REG_DATA_AQI

#define ENS160_REG_DATA_AQI   0x21

air quality index register

Definition at line 62 of file driver_ens160.c.

◆ ENS160_REG_DATA_ECO2

#define ENS160_REG_DATA_ECO2   0x24

equivalent co2 concentration register

Definition at line 64 of file driver_ens160.c.

◆ ENS160_REG_DATA_ETOH

#define ENS160_REG_DATA_ETOH   0x22

ethanol concentration register

Definition at line 65 of file driver_ens160.c.

◆ ENS160_REG_DATA_MISR

#define ENS160_REG_DATA_MISR   0x38

data integrity field register

Definition at line 68 of file driver_ens160.c.

◆ ENS160_REG_DATA_RH

#define ENS160_REG_DATA_RH   0x32

relative humidity used in calculations register

Definition at line 67 of file driver_ens160.c.

◆ ENS160_REG_DATA_T

#define ENS160_REG_DATA_T   0x30

temperature used in calculations register

Definition at line 66 of file driver_ens160.c.

◆ ENS160_REG_DATA_TVOC

#define ENS160_REG_DATA_TVOC   0x22

tvoc concentration register

Definition at line 63 of file driver_ens160.c.

◆ ENS160_REG_DEVICE_STATUS

#define ENS160_REG_DEVICE_STATUS   0x20

operating mode register

Definition at line 61 of file driver_ens160.c.

◆ ENS160_REG_GPR_READ

#define ENS160_REG_GPR_READ   0x48

general purpose read register

Definition at line 70 of file driver_ens160.c.

◆ ENS160_REG_GPR_WRITE

#define ENS160_REG_GPR_WRITE   0x40

general purpose write register

Definition at line 69 of file driver_ens160.c.

◆ ENS160_REG_OPMODE

#define ENS160_REG_OPMODE   0x10

operating mode register

Definition at line 56 of file driver_ens160.c.

◆ ENS160_REG_PART_ID

#define ENS160_REG_PART_ID   0x00

chip register definition

device identity register

Definition at line 55 of file driver_ens160.c.

◆ ENS160_REG_RH_IN

#define ENS160_REG_RH_IN   0x15

host relative humidity information register

Definition at line 60 of file driver_ens160.c.

◆ ENS160_REG_TEMP_IN

#define ENS160_REG_TEMP_IN   0x13

host ambient temperature information register

Definition at line 59 of file driver_ens160.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "ScioSense"

manufacturer name

Definition at line 44 of file driver_ens160.c.

◆ MAX_CURRENT

#define MAX_CURRENT   79.0f

chip max current

Definition at line 47 of file driver_ens160.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   1.98f

chip max supply voltage

Definition at line 46 of file driver_ens160.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.71f

chip min supply voltage

Definition at line 45 of file driver_ens160.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 49 of file driver_ens160.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 48 of file driver_ens160.c.