Coder Social home page Coder Social logo

sensirion / embedded-scd Goto Github PK

View Code? Open in Web Editor NEW
47.0 14.0 9.0 89 KB

Embedded SCD Drivers for Sensirion CO2 Sensors - Download the Zip Package from the Release Page

Home Page: https://github.com/Sensirion/embedded-scd/releases

License: BSD 3-Clause "New" or "Revised" License

Makefile 9.32% C 64.04% C++ 20.05% BitBake 6.59%
co2 co2-sensor embedded sensirion sensor driver scd30 i2c raspberry raspberrypi

embedded-scd's Introduction

embedded-scd GitHub license

Note: This repository is deprecated. Please use our new drivers:

This repository contains the embedded driver sources for Sensirion's SCD product line.

Clone this repository

 git clone --recursive https://github.com/Sensirion/embedded-scd.git

Repository content

  • embedded-common (submodule repository for the common embedded driver HAL)
  • scd30 (SCD30 driver related)

Collecting resources

make release

This will create the release folder with the necessary driver files in it, including a Makefile. That way, you have just one folder with all the sources ready to build your driver for your platform.

Files to adjust (from embedded-common)

You only need to touch the following files:

  • sensirion_arch_config.h (architecture specifics, you need to specify the integer sizes)

and depending on your i2c implementation either of the following:

  • embedded-common/hw_i2c/sensirion_hw_i2c_implementation.c functions for hardware i2c communication if your platform supports that
  • embedded-common/sw_i2c/sensirion_sw_i2c_implementation.c functions for software i2c communication via GPIOs

Building the driver

  1. Adjust sensirion_arch_config.h if you don't have the <stdint.h> header file available
  2. Implement necessary functions in one of the *_implementation.c files described above
  3. make

Please check the embedded-common repository for further information and sample implementations.


embedded-scd's People

Contributors

abrauchli avatar getpastthemonkey avatar psachs avatar rnestler avatar zifzaf avatar

Stargazers

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

Watchers

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

embedded-scd's Issues

Check for data ready not present in example

Hi Sensirion team, thank you for investing resources into this. I was able to quickly get started with the base demo. I wanted to point out an issue that unaltered demo currently has which others may come across.

In the example file scd30/scd30_example_usage.c, there is no data ready check or usage of scd30_get_data_ready as seen in tests/scd-test.cpp and indicated in the datasheet.

Without this check, the device occasionally returns correctly checksummed 0xFF bytes which do not indicate any immediate errors. On my bench there is a seemingly erroneous measurement every ~8 samples. The simple fix is to just add a check before sampling as done in the test file.

scd30_logs

read measurement fails

Hi Team,

I had problems with reading measurement values with the latest release of the SCD30 with Embedded-SCD 2.1.2:

I got crazy values, which caused the crc check to fail, cause those values represent a CO2 of about -1900ppm.
After a lot of testing i found out, that inserting a delay in function scd30_read_measurement (scd30.c LOC: 79) between the following sensirion_i2c_write_cmd(SCD30_I2C_ADDRESS, SCD30_CMD_READ_MEASUREMENT); and error = sensirion_i2c_read_words_as_bytes(SCD30_I2C_ADDRESS, &data[0][0], SENSIRION_NUM_WORDS(data)); like:

int16_t scd30_read_measurement(float* co2_ppm, float* temperature,
                               float* humidity) 
{
    int16_t error;
    uint8_t data[3][4];

    error =
        sensirion_i2c_write_cmd(SCD30_I2C_ADDRESS, SCD30_CMD_READ_MEASUREMENT);
	
	if (error != NO_ERROR)
        return error;
	
	sensirion_sleep_usec(SCD30_WRITE_DELAY_US); // @Markus

    error = sensirion_i2c_read_words_as_bytes(SCD30_I2C_ADDRESS, &data[0][0],
                                              SENSIRION_NUM_WORDS(data));
    if (error != NO_ERROR)
        return error;

	

    *co2_ppm = sensirion_bytes_to_float(data[0]);
    *temperature = sensirion_bytes_to_float(data[1]);
    *humidity = sensirion_bytes_to_float(data[2]);

    return NO_ERROR;
}

... solved this problem and correct readings came out of the sensor.
Could anyone possibly confirm this solution?

Thanks for your those great products like the SCD30!

Greetings from Bavaria,
Markus

Overflows on ESP32

Hi guys! I was using your excellent library to run up my SCD30 on ESP32 with Amazon FreeRTOS. I found a few little gotchas that I thought I'd mention.

Firstly, I was getting a full on kernel panic when I tried to read data. I tracked it down to a problem in the scd30_read_measurement function in scd30.c. The problem is when it calls sensirion_i2c_read_bytes, it gives it the wrong number of words. It should be 6 (defined as the number of words in the CO2, Temp & Hum excluding CRC bytes (as these are accounted for in the function). I think it was evaluating 12 instead from sizeof(data). Hence, it was asking to go and get 24 bytes and stick them into a defined variable only long enough for 12. I guess that's where the overflow came from. My humidity pointer was getting overwritten with a random address outside the allowable range.

Also, I think (although I may be mixing and matching the order in which I debugged things), that you need to do a soft reset after initialising the i2c driver. May be ESP32 specific, so not a bug in any case, just an observation.

Lastly, because I'm using an ESP32, I had to define the timeout specifically. Obviously not a bug either, but perhaps useful for others to know if they are using the ESP32.

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.