42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
65#define DHT222_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
75#define DHT222_ERROR -1
82#define DHT222_I2C_ADDRESS_WRITE 0xB8
83#define DHT222_I2C_ADDRESS_READ 0xB9
90#define DHT222_REG_HUMIDITY_MSB 0x00
91#define DHT222_REG_HUMIDITY_LSB 0x01
92#define DHT222_REG_TEMPERATURE_MSB 0x02
93#define DHT222_REG_TEMPERATURE_LSB 0x03
94#define DHT222_REG_MODEL_MSB 0x08
95#define DHT222_REG_MODEL_LSB 0x09
96#define DHT222_REG_VERSION 0x0A
97#define DHT222_REG_DEVICE_ID_3 0x0B
98#define DHT222_REG_DEVICE_ID_2 0x0C
99#define DHT222_REG_DEVICE_ID_1 0x0D
100#define DHT222_REG_DEVICE_ID_0 0x0E
101#define DHT222_REG_STATE 0x0F
102#define DHT222_REG_USER_REG_1_MSB 0x10
103#define DHT222_REG_USER_REG_1_LSB 0x11
104#define DHT222_REG_USER_REG_2_MSB 0x12
105#define DHT222_REG_USER_REG_2_LSB 0x13
112#define DHT222_CMD_READ 0x03
113#define DHT222_CMD_WRITE 0x10
120#define DHT222_TIMEOUT 100000ul
void dht222_cfg_setup(dht222_cfg_t *cfg)
Config Object Initialization function.
err_t dht222_init(dht222_t *ctx, dht222_cfg_t *cfg)
Initialization function.
err_t dht222_get_temp_hum(dht222_t *ctx, uint16_t *temperature, uint16_t *humidity)
Reads temperature and humidity from AM2322 sensor.
err_t dht222_get_humidity(dht222_t *ctx, uint16_t *humidity)
Reads humidity from AM2322 sensor.
err_t dht222_write_reg(dht222_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len)
Generic write function.
err_t dht222_read_reg(dht222_t *ctx, uint8_t address, uint8_t *data_out, uint8_t len)
Generic read function.
err_t dht222_get_temperature(dht222_t *ctx, uint16_t *temperature)
Reads temperature from AM2322 sensor.
Click configuration structure definition.
Definition dht222.h:146
pin_name_t scl
Definition dht222.h:147
pin_name_t sda
Definition dht222.h:148
Click ctx object definition.
Definition dht222.h:134
uint8_t i2c_started
Definition dht222.h:138
pin_name_t scl
Definition dht222.h:135
pin_name_t sda
Definition dht222.h:136