Tutorial: Getting Started with the SHTC1 and SHTW1 Extension Boards
2. Installation and Running Sample Code
The provided demo code is available as a sample project for Atmel Studio. It can be freely downloaded as VSIX extension file directly from Atmel Studio (Tools→Extensions and Updates→Search for Sensirion). After a restart of Atmel studio, select from the top menu File→New→Example project, and then select Sensirion’s example as shown below.
Having the sample project ready, connect the SAMD20 Xplained Pro Board with your Sensirion Xplained Extension Board, and run the example directly from Atmel Studio.
3. Functionality of Demo Code
The provided demo code implements communication with the SHTC1/SHTW1 sensor over the I2C bus. Values are read in a loop and used for detection of breathing on the sensor (so called AirTouch®).
On reset/start, a reference humidity value is calculated. During operation, humidity values are read in a loop and the difference between current value and reference value is calculated. If the difference exceeds a given threshold, LED0 is turned on. BUTTON0 can be used to re-initialize the reference value.
In addition, humidity values and calculated dew point values are sent to host PC over USART. When the example from Atmel Studio is running, the output can be read with any serial port terminal program (e.g., hyper-terminal or Tera term) from EDBG Virtual COM Port. Within Atmel Studio you can use Terminal for Atmel Studio (Tools→Extension Manager→Search for Terminal).
4. Code Structure
The code is structured as follows:
- SHTC1 driver (shtc1.c and shtc1.h) – Implements I2C driver for SHTC1 sensors.
- SHTW1 driver (shtw1.c and shtw1.h) – Implements I2C driver for SHTW1 sensors.
- Main file (main.c) – Contains an entry point of an example. The code in this file calls initialization routines and subsequently starts the main loop, where values from the sensor are read and air-touch is detected.
- Helpers (demo_tools.c and demo_tools.h) – Contain implementation of helper functions, e.g., printing messages back to the terminal (for debugging purposes) and initialization of I2C board support.