DPP301A000

MEAS HTU21D XPLAINED PRO BOARD
Digital Humidity DCS Development Tools
SENSOR SOLUTIONS /// MEAS HTU21D XPLAINED PRO BOARD 05/2016
Page 4
Project Setup
This project is based on ATSAMD20J18 board with Measurement Specialties Xplained Pro extension board connected to
EXT1 pad as shown on figure below.
Running the Application
1. Download the HTU21D Xplained Pro example package on TE Website
2. Decompress the archive file
3. Open the .cproj project file with Atmel Studio 6
4. You will now be able to build the HTU21D example project -
5. Finally, run the build result on your Xplained Pro Board -
Application Code
This section is intended to provide a basic example of functionality.
/**
* \file main.c
*
* \brief HTU21 Temperature & Humidity monitoring application file
*
* Copyright (c) 2014 Measurement Specialties. All rights reserved.
*
*/
#include <asf.h>
uint64_t serial;
float temperature;
float relative_humidity;
float compensated_humidity;
float dew_point;
enum htu21_heater_status heater;
int main (void)
MEAS HTU21D XPLAINED PRO BOARD
Digital Humidity DCS Development Tools
SENSOR SOLUTIONS /// MEAS HTU21D XPLAINED PRO BOARD 05/2016
Page 5
{
enum htu21_status status;
float last_temperature = 0;
float variation = 0;
uint8_t n=0;
system_init();
delay_init();
// Configure device and enable
htu21_init();
if( !htu21_is_connected() )
return -1;
// Reset HTU21
status = htu21_reset();
if( status != htu21_status_ok)
return -1;
// Read serial number
status = htu21_read_serial_number(&serial);
if( status != htu21_status_ok)
return -1;
// Configure resolution
status = htu21_set_resolution(htu21_resolution_t_12b_rh_8b);
if( status != htu21_status_ok)
return -1;
// Monitor temperature every 500ms
while (1) {
// Enable heater for 10s
if( (n==10) ) {
status = htu21_enable_heater();
if( status != htu21_status_ok)
return -1;
}
// Disable heater after 20s
if( (n==20) ) {
status = htu21_disable_heater();
if( status != htu21_status_ok)
return -1;
}
// Check heater status
status = htu21_get_heater_status(&heater);
if( status != htu21_status_ok)
MEAS HTU21D XPLAINED PRO BOARD
Digital Humidity DCS Development Tools
SENSOR SOLUTIONS /// MEAS HTU21D XPLAINED PRO BOARD 05/2016
Page 6
return -1;
// Alternate between w and w/o hold temperature read
if( n&1 )
htu21_set_i2c_master_mode(htu21_i2c_no_hold);
else
htu21_set_i2c_master_mode(htu21_i2c_hold);
status = htu21_read_temperature_and_relative_humidity(&temperature, &relative_humidity);
if( status != htu21_status_ok)
return -1;
compensated_humidity = htu21_compute_compensated_humidity(temperature,relative_humidity);
dew_point = htu21_compute_dew_point(temperature,relative_humidity);
variation += temperature - last_temperature;
// Look for significant temperature variation
if ( variation >= 0.5 ) {
// Yes, so turn LED on.
port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
variation = 0;
} else if ( variation <= -0.5 ) {
// No, so turn LED off.
port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
variation = 0;
}
delay_ms(500);
last_temperature = temperature;
n++;
if(n==50) n=0;
}
return 0;
}

DPP301A000

Mfr. #:
Manufacturer:
TE Connectivity / Measurement Specialties
Description:
Temperature Sensor Development Tools Xplained Pro HTU21
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet