Invaluable solution for applications where environmental conditions directly influence functionality, product quality, or user comfort
A
A
Hardware Overview
How does it work?
SHT1x Click is based on the SHT11, a humidity and temperature sensor from Sensirion. The SHT11 is a robust and reliable sensor, and even when exposed to conditions outside its normal range, it can recalibrate itself once conditions stabilize. The sensor performs best when operated within a recommended normal temperature range of -20°C up to 100°C. Long-term exposure to conditions outside the normal range may temporarily offset the RH signal. After returning to the normal temperature range, the sensor will slowly return to a calibration state by itself. Also, note that prolonged exposure to extreme conditions may accelerate aging. Although the typical relative humidity resolution is 12-bit and 14-bit for the
temperature readings, both sensors on the SHT11 are seamlessly coupled to a 14-bit ADC. The relative humidity sensor uses a unique capacitive sensor element, while a band-gap sensor measures the temperature. The SHT11 is individually calibrated in a precision humidity chamber, and the calibration coefficients are stored in an onboard OTP memory. The SHT1x Click communicates with the host MCU using an I2C interface over the mikroBUS™ socket, with communication speeds of up to 1MHz. The SHT1x Click does not have a reset pin; if the communication with the sensor is lost, you can reset the sensor via the signal sequence. While the SHT1x Click cannot measure the dew point directly, it is possible to calculate the
dew point using humidity and temperature readings. This is possible because the same monolithic chip measures humidity and temperature. However, it is important to note that the sensor is not sensitive to light, and prolonged exposure to intense UV radiation can cause the housing to deteriorate over time. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the PWR 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.
Features overview
Development board
Flip&Click PIC32MZ 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 comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,
it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication
methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows 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.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for SHT1x Click driver.
Key functions:
sht1x_output_sda
- Set pin on output.sht1x_input_sda
- Set pin on input.sht1x_sda_high
- Set SDA high function.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief SHT1x Click example
*
* # Description
* This click measures temperature and humidity.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization driver enables GPIO.
*
* ## Application Task
* This example demonstrates the use of SHT1x Click board by measuring
temperature and humidity, and displays the results on USART terminal.
*
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "sht1x.h"
// ------------------------------------------------------------------ VARIABLES
static sht1x_t sht1x;
static log_t logger;
static sht1x_cfg_t cfg;
static uint8_t i;
static uint8_t data_val;
static uint8_t err;
static uint8_t msb;
static uint8_t lsb;
static uint8_t checksum;
static uint16_t t;
static uint16_t h;
static float value;
static uint8_t uc_sens_err;
static int16_t int_temp;
static int16_t int_humi;
static float humidity;
static float temperature;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void sht1x_trans_start ( )
{
sht1x_output_sda ( &sht1x, &cfg );
sht1x_sda_high( &sht1x );
sht1x_input_sda ( &sht1x, &cfg );
sht1x_scl_low( &sht1x );
Delay_us( 1 );
sht1x_scl_high( &sht1x );
Delay_us( 1 );
sht1x_output_sda ( &sht1x, &cfg );
sht1x_sda_low( &sht1x );
Delay_us( 1 );
sht1x_scl_low( &sht1x );
Delay_us( 3 );
sht1x_scl_high( &sht1x );
Delay_us( 1 );
sht1x_input_sda ( &sht1x, &cfg );
Delay_us( 1 );
sht1x_scl_low( &sht1x );
}
uint8_t sht1x_read_byte( uint8_t ack )
{
i = 0x80;
data_val = 0;
sht1x_output_sda ( &sht1x, &cfg );
sht1x_sda_high( &sht1x );
sht1x_input_sda ( &sht1x, &cfg );
sht1x_scl_low( &sht1x );
while( i )
{
sht1x_scl_high( &sht1x );
Delay_us( 1 );
if ( sht1x_get_sda( &sht1x ) == 1 )
{
data_val = ( data_val | i );
}
sht1x_scl_low( &sht1x );
Delay_us( 1 );
i = ( i >> 1 );
}
sht1x_output_sda ( &sht1x, &cfg );
if( ack )
{
sht1x_sda_low( &sht1x );
}
else
{
sht1x_sda_high( &sht1x );
}
sht1x_scl_high( &sht1x );
Delay_us( 3 );
sht1x_scl_low( &sht1x );
Delay_us( 1 );
sht1x_sda_high( &sht1x );
sht1x_input_sda ( &sht1x, &cfg );
return data_val;
}
uint8_t sht1x_write_byte( uint8_t value )
{
i = 0x80;
err = 0;
sht1x_output_sda ( &sht1x, &cfg );
while( i )
{
if ( i & value )
{
sht1x_sda_high( &sht1x );
}
else
{
sht1x_sda_low( &sht1x );
}
sht1x_scl_high( &sht1x );
Delay_us( 3 );
sht1x_scl_low( &sht1x );
Delay_us( 3 );
i = ( i >> 1 );
}
sht1x_sda_high( &sht1x );
sht1x_input_sda ( &sht1x, &cfg );
sht1x_scl_high( &sht1x );
Delay_us( 3 );
if ( sht1x_get_sda( &sht1x ) == 1 )
{
err = 1;
}
Delay_us( 1 );
sht1x_scl_low( &sht1x );
return err;
}
uint8_t sht1x_measure( uint16_t *p_val, uint8_t mode )
{
i = 0;
*p_val = 0;
sht1x_trans_start( );
if( mode )
{
mode = SHT1X_MEAS_HUMI;
}
else
{
mode = SHT1X_MEAS_TEMP;
}
if( sht1x_write_byte( mode ) )
{
return( 1 );
}
sht1x_input_sda ( &sht1x, &cfg );
while( i < 240 )
{
Delay_ms( 3 );
if ( sht1x_get_sda( &sht1x ) == 0 )
{
i = 0;
break;
}
i++;
}
if( i )
{
return( 2 );
}
msb = sht1x_read_byte( SHT1X_ACK );
lsb = sht1x_read_byte( SHT1X_ACK );
checksum = sht1x_read_byte( SHT1X_NACK );
*p_val = ( msb << 8 ) | lsb ;
return( 0 );
}
void sht1x_read_results ( float *f_t, float *f_rh )
{
uc_sens_err = 0;
uc_sens_err = sht1x_measure( &t, 0 );
int_temp = ( int16_t )( sht1x_calc_temp( &sht1x, t ) * 10 );
uc_sens_err = sht1x_measure(&h, 1);
int_humi = ( int16_t )( sht1x_calc_humi( &sht1x, h, t ) * 10 );
value = ( float )int_temp;
*f_t = value / 10;
value = ( float )int_humi;
*f_rh = value / 10;
}
uint8_t sht1x_rd_stat_reg ( uint8_t *p_val )
{
checksum = 0;
sht1x_trans_start( );
if( sht1x_write_byte( SHT1X_STAT_REG_R ) )
{
return 1;
}
*p_val = sht1x_read_byte( SHT1X_ACK );
checksum = sht1x_read_byte( SHT1X_NACK );
return 0;
}
uint8_t sht1x_wr_stat_reg ( uint8_t value )
{
sht1x_trans_start();
if( sht1x_write_byte( SHT1X_STAT_REG_W ) )
{
return 1;
}
if( sht1x_write_byte( value ) )
{
return 1;
}
return 0;
}
void sht1x_connection_reset ( )
{
sht1x_output_sda ( &sht1x, &cfg );
sht1x_sda_high( &sht1x );
sht1x_input_sda ( &sht1x, &cfg );
sht1x_scl_low( &sht1x );
for( i = 0; i < 9; i++ )
{
sht1x_scl_high( &sht1x );
Delay_us( 3 );
sht1x_scl_low( &sht1x );
Delay_us( 3 );
}
sht1x_trans_start( );
}
uint8_t sht1x_soft_reset ( )
{
sht1x_connection_reset( );
return ( sht1x_write_byte( SHT1X_SOFT_RESET ) );
}
void application_init ( void )
{
log_cfg_t log_cfg;
/**
* 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_info(&logger, "---- Application Init ----");
// Click initialization.
sht1x_cfg_setup( &cfg );
SHT1X_MAP_MIKROBUS( cfg, MIKROBUS_1 );
sht1x_init( &sht1x, &cfg );
}
void application_task ( void )
{
sht1x_read_results( &temperature, &humidity );
log_printf( &logger, " Temperature: %.2f ", temperature );
log_printf( &logger, " C \r\n" );
log_printf( &logger, " Humidity: %.2f ", humidity );
log_printf( &logger, " \r\n" );
Delay_ms( 1000 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END