Giter VIP home page Giter VIP logo

esp-idf-scd4x's Introduction

Sensirion Embedded I2C SCD4x Driver ported to esp-idf component

This is the generic embedded driver for the Sensirion SCD4x Carbon Dioxide Sensor ported to an esp-idf component for use with the esp32 familiy of microcontrollers.

Getting started

Add component to your esp-idf project

To add the component to your esp-idf based project, first clone this repository, preferably into your project directory but somewhere else should also work.

git clone git://github.com/timbuntu/esp-idf-scd4x.git

Or add it as a submodule if you are also using git:

git submodule add git://github.com/timbuntu/esp-idf-scd4x.git

After cloning the repository, add the directory as extra component by adding the following line to the project cmake file, or append the directory to the line if it alrady exists (replace esp-idf-scd4x with the path to the cloned repo):

set(EXTRA_COMPONENT_DIRS "esp-idf-scd4x")

Finally add the esp-idf-scd4x component to your own component by adding it as a requirement in the component CMakeLists.txt idf_component_register call so that it looks something like this:

idf_component_register(SRCS "src/main.c" INCLUDE_DIRS "include/" REQUIRES "esp-idf-scd4x")

Configuration

You can configure the GPIOs, i2c port and clock speed to use in the sensirion_config.h file.

Background

Files

sensirion_i2c.[ch]

In these files you can find the implementation of the I2C protocol used by Sensirion sensors. The functions in these files are used by the embedded driver to build the correct frame out of data to be sent to the sensor or receive a frame of data from the sensor and convert it back to data readable by your machine. The functions in here calculate and check CRCs, reorder bytes for different byte orders and build the correct formatted frame for your sensor.

sensirion_i2c_hal.[ch]

In these files you can find the implementation of the hardware abstraction layer used by Sensirion's I2C embedded drivers. This part of the code is specific to the underlying hardware platform. This is implemented using the esp-edf i2c driver component. In the sample-implementations/ folder we provide implementations for the most common platforms.

sensirion_config.h

In this file we keep all the included libraries for our drivers and global defines. Next to sensirion_i2c_hal.c it's the only file that needed to be edited to get the driver working.

sensirion_common.[ch]

In these files you can find some helper functions used by Sensirion's embedded drivers. It mostly contains byte order conversions for different variable types. These functions are also used by the UART embedded drivers therefore they are kept in their own file.

esp-idf-scd4x's People

Contributors

mbjoern avatar psachs avatar rnestler avatar rol-la avatar timbuntu avatar

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.