environment3  2.0.0.0
Main Page

Environment 3 click

<PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU>

[click Product page](<CLICK_PRODUCT_PAGE_LINK>)


Click library

  • Author : Stefan Filipovic
  • Date : May 2021.
  • Type : I2C/SPI type

Software Support

We provide a library for the Environment3 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for Environment3 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of Environment 3 click board.

The demo application is composed of two sections :

Application Init

Initializes the driver, sets the default configuration, and enables the gas sensor heater.

void application_init ( void )
{
log_cfg_t log_cfg;
environment3_cfg_t environment3_cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 115200;
log_init( &logger, &log_cfg );
Delay_ms( 100 );
log_info( &logger, " Application Init " );
// Click initialization.
environment3_cfg_setup( &environment3_cfg );
ENVIRONMENT3_MAP_MIKROBUS( environment3_cfg, MIKROBUS_1 );
err_t init_flag = environment3_init( &environment3, &environment3_cfg );
if ( ( init_flag == I2C_MASTER_ERROR ) || ( init_flag == SPI_MASTER_ERROR ) )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
if ( environment3_default_cfg ( &environment3 ) != ENVIRONMENT3_OK )
{
log_error( &logger, " Default Config Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Reads the temperature, humidity, pressure, and gas resistance data from the sensor and displays all values on the USB UART approximately every second.

void application_task ( void )
{
environment3_get_all_data ( &environment3, &temperature, &humidity, &pressure, &gas );
log_printf( &logger, " Temperature : %.2f C\r\n", temperature );
log_printf( &logger, " Humidity : %.2f %%\r\n", humidity );
log_printf( &logger, " Pressure : %.3f mBar\r\n", pressure );
log_printf( &logger, " Gas Resistance : %ld Ohms\r\n", gas );
log_printf( &logger, "--------------------------------\r\n" );
}

Note

The temperature and humidity data don't represent the real environmental data when the heater is enabled.

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Environment3

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ENVIRONMENT3_MAP_MIKROBUS
#define ENVIRONMENT3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: environment3.h:337
environment3_soft_reset
int8_t environment3_soft_reset(environment3_t *ctx)
Environment 3 soft reset function.
environment3_s
Environment 3 Click context object.
Definition: environment3.h:451
environment3_cfg_t
Environment 3 Click configuration object.
Definition: environment3.h:477
application_task
void application_task(void)
Definition: main.c:75
ENVIRONMENT3_OK
@ ENVIRONMENT3_OK
Definition: environment3.h:502
environment3_get_all_data
int8_t environment3_get_all_data(environment3_t *ctx, float *temp, float *hum, float *pres, uint32_t *gas)
Environment 3 get all data function.
environment3_default_cfg
err_t environment3_default_cfg(environment3_t *ctx)
Environment 3 default configuration function.
application_init
void application_init(void)
Definition: main.c:36
ENVIRONMENT3_ENABLE
#define ENVIRONMENT3_ENABLE
Environment 3 enable/disable macros.
Definition: environment3.h:192
environment3_enable_heater
int8_t environment3_enable_heater(environment3_t *ctx, uint8_t state)
Environment 3 enable heater function.
environment3_cfg_setup
void environment3_cfg_setup(environment3_cfg_t *cfg)
Environment 3 configuration object setup function.
environment3_init
err_t environment3_init(environment3_t *ctx, environment3_cfg_t *cfg)
Environment 3 initialization function.