Beginner
10 min

Experience the perfect climate right at your fingertips, thanks to HTU31D and CEC1302

Breathe easy with our climate wizardry

Temp&Hum 14 Click with UNI Clicker

Published Nov 11, 2023

Click board™

Temp&Hum 14 Click

Dev Board

UNI Clicker

Compiler

NECTO Studio

MCU

CEC1302

Count on our climate solution to provide valuable insights into temperature and humidity, contributing to a smarter and more sustainable future.

A

A

Hardware Overview

How does it work?

Temp&Hum 14 Click is based on the HTU31D, a digital relative humidity sensor with temperature output from TE Connectivity. Both sensors inside the HTU31D are individually calibrated, compensated, and tested. The humidity can be measured within a range of 0 to 100 %RH, while the temperature sensor is designed for a range of -40 to 125 °C. The typical accuracy for humidity is ± 2 %RH in the measuring range of 20 up to 100 %RH at ambient temperature and ±0.2 °C for temperature between 0 - 100 °C with power consumption down to 3.78μW. This Click board™, an I2C configurable environmental sensor, is characterized by high reliability and full interchangeability with no calibration required in standard conditions. It has a quick recovery time after long periods in the saturation phase, low power

consumption, and fast response time. Also, this sensor provides sustained performance even when exposed to extreme temperatures up to 125°C and humidity environments. Temp & Hum 14 Click communicates with MCU using the standard I2C 2-Wire interface with a maximum frequency 10MHz. The HTU31D can answer 2 I2C addresses and allows the choice of the least significant bit (LSB) by positioning SMD jumpers labeled as ADDR SEL to an appropriate position marked as 0 and 1. In addition to this feature, this Click board™ also contains additional functionality routed to the RST pin on the mikroBUS™ socket. The RST pin can generate a sensor reset with a minimum pulse duration of 1 μs required to trigger this function. The HTU31D also offers a diagnostic register that can be used to check whether

the values for humidity and temperature are outside the specified range. The CRC check (Cyclic Redundancy Check) ensures secure data transmission. The humidity and temperature signal response time, as well as the recovery time (after complete condensation), are within a range of a few seconds. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

Temp&Hum 14 Click hardware overview image

Features overview

Development board

UNI Clicker is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It supports a wide range of microcontrollers, such as different ARM, PIC32, dsPIC, PIC, and AVR from various vendors like Microchip, ST, NXP, and TI (regardless of their number of pins), four mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a debugger/programmer connector, and two 26-pin headers for interfacing with external electronics. Thanks to innovative manufacturing technology, it allows you to build

gadgets with unique functionalities and features quickly. Each part of the UNI Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the UNI Clicker programming method, using a third-party programmer or CODEGRIP/mikroProg connected to onboard JTAG/SWD header, the UNI Clicker board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Type-C (USB-C) connector, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or using a Li-Po/Li

Ion battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board (plus USB HOST/DEVICE), including the well-established mikroBUS™ socket, a standardized socket for the MCU card (SiBRAIN standard), and several user-configurable buttons and LED indicators. UNI Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI clicker double image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

144

RAM (Bytes)

131072

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
GP140
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
GP024
SCL
I2C Data
GP025
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Temp&Hum 14 Click Schematic schematic

Step by step

Project assembly

UNI Clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI Clicker as your development board.

UNI Clicker front image hardware assembly
Thermo 28 Click front image hardware assembly
SiBRAIN for STM32F745VG front image hardware assembly
Prog-cut hardware assembly
UNI Clicker MB 1 - upright/with-background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for Temp&Hum 14 Click driver.

Key functions:

  • temphum14_set_conversion - The function set conversion a single temperature and humidity conversion and select data resolution to the HTU31D

  • temphum14_read_t_and_rh - The function read temperature and humidity data of the HTU31D

  • temphum14_get_temp_and_hum - The function get temperature and humidity value of the HTU31D

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief TempHum14 Click example
 *
 * # Description
 * This is an example that demonstrates the use of the Temp-Hum 14 Click board.
 * Temp-Hum 14 Click board can be used to measure temperature
 * and relative humidity.
 * All data logs write on USB uart changes every 3 sec.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization driver enables I2C, and
 * hardware reset the device and read the serial number.
 *
 * ## Application Task
 * Reading temperature and humidity, and loging it on the USB uart. 
 * 
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "temphum14.h"

static temphum14_t temphum14;
static log_t logger;
static temphum14_diagn_t status_data;
static float temperature;
static float humidity;
uint32_t ser_numb;

void display_diagnostic ( void ) {
    log_printf( &logger, "-----------------------------\r\n" );
    log_printf( &logger, "\r\n NVM Error        :" );
    if ( status_data.nvm_error == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Error \r\n" );
    } else {
        log_printf( &logger, " No Error \r\n" );
    }

    log_printf( &logger, "\r\n Humidity U/O     :" );
    if ( status_data.hum_un_over == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Under/Overrun \r\n" );
    } else {
        log_printf( &logger, " No Error \r\n" );
    }

    log_printf( &logger, "\r\n Humidity Error   :" );
    if ( status_data.hum_h_err == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Below -10%% RH \r\n" );
    } else if ( status_data.hum_l_err == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Above 120%% RH \r\n" );
    } else {
        log_printf( &logger, " No Error \r\n" );
    }
    
    log_printf( &logger, "\r\n Temperature U/O  :" );
    if ( status_data.temp_un_over == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Under/Overrun \r\n" );
    } else {
        log_printf( &logger, " No Error \r\n" );
    }

    log_printf( &logger, "\r\n Temperature Error:" );
    if ( status_data.temp_h_err == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Below -50 C \r\n" );
    } else if ( status_data.temp_l_err == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " Above 150 C \r\n" );
    } else {
        log_printf( &logger, " No Error \r\n" );
    }

    log_printf( &logger, "\r\n Heater Status    :" );
    if ( status_data.heater_on == TEMPHUM14_STATUS_ON ) {
        log_printf( &logger, " ON \r\n" );
    } else {
        log_printf( &logger, " OFF \r\n" );
    }

    log_printf( &logger, "-----------------------------\r\n" );
}

void application_init ( void ) {
    log_cfg_t log_cfg;  /**< Logger config object. */
    temphum14_cfg_t temphum14_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_printf( &logger, "-----------------------------\r\n" );
    log_info( &logger, " Application Init " );
    log_printf( &logger, "-----------------------------\r\n" );

    // Click initialization.
    temphum14_cfg_setup( &temphum14_cfg );
    TEMPHUM14_MAP_MIKROBUS( temphum14_cfg, MIKROBUS_1 );
    err_t init_flag = temphum14_init( &temphum14, &temphum14_cfg );
    if ( I2C_MASTER_ERROR == init_flag ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    Delay_ms( 100 );
    log_printf( &logger, "-----------------------------\r\n" );
    log_printf( &logger, " Hardware Reset \r\n" );
    temphum14_hw_reset( &temphum14 );
    Delay_ms( 100 );
    
    ser_numb = temphum14_get_serial_number( &temphum14 );
    log_printf( &logger, "-----------------------------\r\n" );
    log_printf( &logger, " Serial Number : %lu \r\n", ser_numb );
    log_printf( &logger, "-----------------------------\r\n" );
    log_printf( &logger, " Software Reset \r\n" );
    temphum14_soft_reset( &temphum14 );
    Delay_ms( 100 );
    
    temphum14_get_diagnostic( &temphum14, &status_data );
    Delay_ms( 100 );

    display_diagnostic( );
    Delay_ms( 100 );
    
    log_info( &logger, " Application Task " );
    log_printf( &logger, "-----------------------------\r\n" );
}

void application_task ( void ) {
    temphum14_set_conversion( &temphum14, TEMPHUM14_CONVERSION_HUM_OSR_0_020, TEMPHUM14_CONVERSION_TEMP_0_040 );
    Delay_ms( 10 );
    
    temphum14_get_temp_and_hum( &temphum14, &temperature, &humidity );
    Delay_ms( 10 );
    
    log_printf( &logger, "  Temperature : %.2f C \r\n", temperature );
    log_printf( &logger, "  Humidity    : %.2f %% \r\n", humidity );
    log_printf( &logger, "-----------------------------\r\n" );
    Delay_ms( 3000 );
}

void main ( void ) {
    application_init( );

    for ( ; ; ) {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.