Giter VIP home page Giter VIP logo

arduino-snippets's Introduction

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

Name Protocol Description
SCD4x_I2C_minimal_example I2C Minimal example to get started
SCD4x_I2C_FRC_Forced_Recalibration_Example I2C Show forced recalibration

SEN44

Name Protocol Description
SEN44_I2C_minimal_example I2C Basic example for I2C
SEN44_I2C_pm_values_floating_point I2C Read out PM values as floating point
SEN44_I2C_change_T_offset_example I2C Change T offset over I2C
SEN44_I2C_change_VOC_parameters_example I2C Change VOC parameters over I2C
SEN44_SCD40_I2C_example I2C Example using SEN44 with SCD4x
SEN44_UART_minimal_example UART Basic example for UART (Serial) interface

SEN5x

Name Protocol Description
SEN5x_I2C_minimal_example I2C Basic example for I2C
SEN5x_I2C_config_STAR_example I2C Example configuration of STAR
SEN5x_I2C_config_coldstart_example I2C Change T offset for cold start compensation
SEN5x_I2C_config_warmstart_example I2C Change T behaviour in warm start scenario
SEN5x_I2C_change_VOC_parameters_example I2C Change VOC parameters over I2C
SEN5x_I2C_change_NOx_parameters_example I2C Change NOx parameters over I2C
SEN5x_I2C_read_raw I2C Example for reading raw VOC and NOX values from the sensor over I2C
SEN5x_I2C_switch_measurement_mode I2C Example for switching between gas only and full measurement mode (requires FW2.0) over I2C

SFA30

Name Protocol Description
SFA30_I2C_minimal_example I2C Minimal example to get started

SGP40

Name Protocol Description
SGP40_SHTC3_I2C_voc_algo_minimal_example I2C Minimal example to use SGP40 with VOC Index algorithm

SHT3x

Name Protocol Description
SHT3x_I2C_minimal_example I2C Minimal example to get started

SHT4x

Name Protocol Description
SHT4x_I2C_minimal_example I2C Minimal example to get started

SHTC3

Name Protocol Description
SHTC3_I2C_minimal_example I2C Minimal example to get started

SVM40

Name Protocol Description
SVM40_I2C_minimal_example I2C Minimal example to get started
SVM40_I2C_change_T_offset_example I2C Change T offset
SVM40_I2C_change_VOC_parameters_example I2C Change VOC index algorithm parameters

SDP8xx

Name Protocol Description
SDP8xx_I2C_minimal_example I2C Minimal example to get started

arduino-snippets's People

Contributors

fototux avatar leoniefierz avatar psachs avatar varesio avatar winkj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

arduino-snippets's Issues

Integer Overflow in SCD4x_I2C_FRC_Forced_Recalibration_Example.ino

Line 63 in SCD4x_I2C_FRC_Forced_Recalibration_Example.ino causes an integer overflow:
delay(5 * 60 * 1000);
In an Arduino Uno and other ATmega based boards the maximum value for an int is 32,767. Consequently, 5 * 60 * 1000 gets evaluated to a negative number and the delay never terminates.
Possible solution:
delay(5 * 60 * (long)1000);

Scd4x forced calibration code not working properly

Hi,
I found that your code "SCD4x_I2C_FRC_Forced_Recalibration_Example.ino" was not working properly.
Instead of waiting for the sensor to startup and equalize itself to ambient levels, it started the calibration directly after powerup.

I found that at line 99, the delay was commented.

97 // wait for another 5 minutes to equilibrate sensor to ambient
98 Serial.println("# Waiting 5 minutes for equilibration");
99 //delay(5 * 60 * 1000);

I uncommented this delay, but also moved it up to line 60. This was because the values used as "CO2 values before recalibration" (lines 66-76) where saved before the initial equilibration delay at line 99.

Could you confirm this?
After I made the changes, sensorreadings where as expected from ~400PPM co2 levels in the outside ambient air.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.