Beginner
10 min

Arm yourself with intelligent climate insights using SHT31-ARP-B and PIC18F57Q43

Your comfort, our commitment - Always!

SHT AN Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

SHT AN Click

Dev. board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

We're not just measuring temperature and humidity; we're crafting the art of perfect climate control to provide you with an environment that harmonizes with your every need and desire.

A

A

Hardware Overview

How does it work?

SHT AN Click is based on the SHT31-ARP-B, a temperature and humidity sensor from Sensirion, built on a completely new and optimized CMOSens® chip, which allows for increased reliability and improved accuracy specifications. Sensor can be ordered with filter membrane which is a PTFE film that protects sensor from opening from water and dust. Since the SHT31-ARP-B is a temperature and humidity (T and RH) sensor with two analog outputs for each measurement, and on the mikroBUS socket we have only one analog output we multiplexed sensor output by suing 74LVC1G3157GV, 2

channel analog multiplexer/demultiplexer. Switching between temperature and humidity measurements is performed by asserting the selection input (SEL) which is connected to the multiplexer and by that way selecting desired data output. Measured data is supplied as radiometric voltage output, after reading the temperature or humidity analog signal user will have to do conversion to a physical value. The physical values as measured by the sensor are mapped to a radiometric voltage output (VT, VRH as 10 to 90% of VDD). Prior to conversion into a voltage signal, the physical values are linearized and

compensated for temperature and supply voltage effects by the sensor. Additionally, the voltage output is calibrated for each sensor. The nRST pin is active low and may be used to generate a reset of the sensor. A minimum pulse duration of 1 µs is required to reliably trigger a reset. The nRST signal is routed to the mikroBUS™ RST pin. This Click board™ can be supplied and interfaced with both 3.3V and 5V without the need for any external components. The onboard SMD jumper labeled as VCC SEL allows voltage selection for interfacing with both 3.3V and 5V microcontrollers.

SHT AN hardware overview image

Features overview

Development board

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

Used MCU Pins

mikroBUS™ mapper

Analog Output
PA0
AN
Reset
PA7
RST
Measurement Channel Selection
PD4
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
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

SHT AN Click Schematic schematic

Step by step

Project assembly

Curiosity Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Board mapper by product8 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
PIC18F57Q43 Curiosity MCU Step 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

Software Support

Library Description

This library contains API for SHT AN Click driver.

Key functions:

  • shtan_set_mode - Function sets signal output ADC mode

  • shtan_reset - Reset 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 ShtAn Click example
 * 
 * # Description
 * This app demonstrates the use of SHT AN Click to measure temperature and humidity.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init
 * Initialization driver enables - GPIO, sw reset,
 * initializes ADC, set ADC channel and sets ADC read mode.
 * 
 * ## Application Task
 * This is a example which demonstrates the use of SHT AN Click board.
 * Measured temperature and humidity ADC data and calculate temperature data to degrees
 * Celsius/Fahrenheit and relative humidity data to percentage.
 * Results are being sent to the Usart Terminal where you can track their changes.
 * All data logs on usb uart for aproximetly every 1 sec.
 *
 * \author Nemanja Medakovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "shtan.h"

// ------------------------------------------------------------------ VARIABLES

static shtan_t shtan;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    shtan_cfg_t 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.

    shtan_cfg_setup( &cfg );
    SHTAN_MAP_MIKROBUS( cfg, MIKROBUS_1 );

    if ( shtan_init( &shtan, &cfg ) == ADC_ERROR )
    {
        log_info( &logger, "---- Application Init Error. ----" );
        log_info( &logger, "---- Please, run program again... ----" );

        for ( ; ; );
    }

    log_info( &logger, "---- Application Init Done. ----" );

    shtan_reset( &shtan );

    log_info( &logger, "---- Application Running... ----\n" );
}

void application_task ( void )
{
    shtan_set_mode( &shtan, SHTAN_SET_ADC_MODE_TEMP );
    Delay_ms ( 200 );

    float shtan_temperature;

    if ( shtan_meas_temperature( &shtan, &shtan_temperature, SHTAN_SET_TEMP_MODE_DEG_C ) != ADC_ERROR )
    {
        log_printf( &logger, "  Temp [T] : %.2f degC\r\n", shtan_temperature );
    }

    shtan_set_mode( &shtan, SHTAN_SET_ADC_MODE_HUM );
    Delay_ms ( 200 );

    float shtan_humidity;

    if ( shtan_meas_humidity( &shtan, &shtan_humidity ) != ADC_ERROR )
    {
        log_printf( &logger, "  Hum [RH] : %.2f %%\r\n", shtan_humidity );
    }

    log_printf( &logger, "\n" );
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}


// ------------------------------------------------------------------------ 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.