Home

Awesome

Sample Code for Arduino

Arduino code examples for raw sensor communication with many Sensirion sensors

Summary

The Arduino Platform allows for easy prototyping with endless possibilities. In addition to the documentation in the datasheet and application notes this repository demonstrates the communication with several Sensirion AG sensors through I2C and UART interfaces. The examples are very basic and typically are a starting point for customer specific implementations. The code for the minimal examples only uses the standard Wire or Serial libraries. No additional external libraries are needed.

The code for the I2C interface examples is written without the use of abstractions so it could be easily adapted to own projects. To keep the code simple usually no error handling like CRC check or I2C NAK checks are implemented.

The UART examples typically are referring to the SHDLC driver by Sensirion which is included in each example folder.

How to use

All samples in this directory share the same format; as such, you can follow the instructions below to get any of them up and running:

  1. If you haven't done so yet, install the Arduino IDE and run some basic test programs to ensure your system is configured properly
  2. Unplug your Arduino from your computer
  3. Connect your sensor to the Arduino board. If you're unsure how to do that, please consult the sensors datasheet and the Arduino pinout
  4. Reconnect your Arduino to your computer
  5. Create a new Sketch in the Arduino IDE
  6. Copy the contents of the .ino file and replace the content of your newly created sketch
  7. Save your project under a meaningful name
  8. Compile and flash the sketch
  9. Open the "Serial Monitor" from the "Tools" menu in the Arduino IDE to display the output data read from the sensor

Examples by sensor

SCD4x

NameProtocolDescription
SCD4x_I2C_minimal_exampleI2CMinimal example to get started
SCD4x_I2C_FRC_Forced_Recalibration_ExampleI2CShow forced recalibration

SEN44

NameProtocolDescription
SEN44_I2C_minimal_exampleI2CBasic example for I2C
SEN44_I2C_pm_values_floating_pointI2CRead out PM values as floating point
SEN44_I2C_change_T_offset_exampleI2CChange T offset over I2C
SEN44_I2C_change_VOC_parameters_exampleI2CChange VOC parameters over I2C
SEN44_SCD40_I2C_exampleI2CExample using SEN44 with SCD4x
SEN44_UART_minimal_exampleUARTBasic example for UART (Serial) interface

SEN5x

NameProtocolDescription
SEN5x_I2C_minimal_exampleI2CBasic example for I2C
SEN5x_I2C_config_STAR_exampleI2CExample configuration of STAR
SEN5x_I2C_config_coldstart_exampleI2CChange T offset for cold start compensation
SEN5x_I2C_config_warmstart_exampleI2CChange T behaviour in warm start scenario
SEN5x_I2C_change_VOC_parameters_exampleI2CChange VOC parameters over I2C
SEN5x_I2C_change_NOx_parameters_exampleI2CChange NOx parameters over I2C
SEN5x_I2C_read_rawI2CExample for reading raw VOC and NOX values from the sensor over I2C
SEN5x_I2C_switch_measurement_modeI2CExample for switching between gas only and full measurement mode (requires FW2.0) over I2C

SFA30

NameProtocolDescription
SFA30_I2C_minimal_exampleI2CMinimal example to get started

SGP40

NameProtocolDescription
SGP40_SHTC3_I2C_voc_algo_minimal_exampleI2CMinimal example to use SGP40 with VOC Index algorithm

SHT3x

NameProtocolDescription
SHT3x_I2C_minimal_exampleI2CMinimal example to get started

SHT4x

NameProtocolDescription
SHT4x_I2C_minimal_exampleI2CMinimal example to get started

SHTC3

NameProtocolDescription
SHTC3_I2C_minimal_exampleI2CMinimal example to get started

SVM40

NameProtocolDescription
SVM40_I2C_minimal_exampleI2CMinimal example to get started
SVM40_I2C_change_T_offset_exampleI2CChange T offset
SVM40_I2C_change_VOC_parameters_exampleI2CChange VOC index algorithm parameters

SDP8xx

NameProtocolDescription
SDP8xx_I2C_minimal_exampleI2CMinimal example to get started