GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mauriciobarroso/sgia: ESP-IDF component for Sensirion Gas Index Algorithm

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
include
include
 
 
sensirion_gas_index_algorithm
sensirion_gas_index_algorithm
 
 
.gitignore
.gitignore
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
sgia.c
sgia.c
 
 

Repository files navigation

ESP-IDF SGIA (Sensirion Gas Index Algorithm) Component

ESP-IDF component for Sensirion Gas Index Algorithm based on Sensirion Gas Index Algorithm

Dependencies

This component only works with ESP-IDF v5.2 or higher.

The gas index algorithm depends on the values obtained from the SGP41 and SHT4x sensors. The ESP-IDF components of these sensors are available at the following links:

  • SGP41 ESP-IDF component
  • SHT4x ESP-IDF component

How to use

  1. Include the I2C driver and component headers
#include "driver/i2c_master.h"
#include "sgia.h"
  1. Declare a handle of I2C bus and an instance of SGIA
i2c_master_bus_handle_t i2c_bus_handle; 
sgia_t button1;
  1. Define a RTOS task to run SGIA process
void sgia_process_task(void *arg) {
    int32_t voc_index, nox_index;
    float temp, hum;
    
    for (;;) {
        /* Run SGIA process */
        ESP_ERROR_CHECK(sgia_run(&sgia));

        /* Get and print VOC and NOx indices */
        sgia_get_index_voc_and_nox(&sgia, &voc_index, &nox_index);
        printf("VOC index: %ld\tNOx index: %ld\r\n", sgia.voc_index, sgia.nox_index);

        /* Get and print temperature and humidity values */
        sgia_get_temp_and_hum(&sgia, &temp, &hum);
        printf("Temperature: %f\tHumidity: %f\r\n\n", sgia.temp, sgia.hum);
    
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}
  1. Configure and create a new I2C bus
/* Configure and create a new I2C bus */
i2c_master_bus_config_t i2c_bus_config = {
    .clk_source = I2C_CLK_SRC_DEFAULT,
    .i2c_port = I2C_NUM_0,
    .scl_io_num = GPIO_NUM_48,
    .sda_io_num = GPIO_NUM_47,
    .glitch_ignore_cnt = 7
};

ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_config, &i2c_bus_handle));
  1. Initialize SGIA instance
/* Initialize SGIA instance */
sgia_init(&sgia, i2c_bus_handle);
  1. Create the RTOS task defined in 3
xTaskCreate(
    sgia_process_task, /* Task code */
    "BSEC Task", /* Task name */
    configMINIMAL_STACK_SIZE * 4, /* Task stack depth */
    NULL, /* Task parameter */
    tskIDLE_PRIORITY + 2, /* Task priority */
    NULL); /* Task handle */

License

MIT License

Copyright (c) 2023 Mauricio Barroso Benavides

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

ESP-IDF component for Sensirion Gas Index Algorithm

Topics

air-qualityesp-idfesp32esp32c2esp32c3esp32c6esp32h2esp32s2esp32s3gas-indexi2cnoxsensirionsgp41sht4xvoc

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.