Giter VIP home page Giter VIP logo

esp-idf-bmx280's Introduction

BMX280 for ESP-IDF

BMX280 is a basic I2C based driver for ESP32 devices licensed mostly under MIT. (See caption "License" for details.)

Usage

Clone this repository or add it as a submodule into your components directory. Add the module as a requirement to your main module, or other modules.

Example Code

#include "esp_log.h"
#include "bmx280.h"

void app_main(void)
{
    // Entry Point
    //ESP_ERROR_CHECK(nvs_flash_init());
    i2c_config_t i2c_cfg = {
        .mode = I2C_MODE_MASTER,
        .sda_io_num = GPIO_NUM_17,
        .scl_io_num = GPIO_NUM_16,
        .sda_pullup_en = false,
        .scl_pullup_en = false,

        .master = {
            .clk_speed = 100000
        }
    };

    ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &i2c_cfg));
    ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0));

    bmx280_t* bmx280 = bmx280_create(I2C_NUM_0);

    if (!bmx280) { 
        ESP_LOGE("test", "Could not create bmx280 driver.");
        return;
    }

    ESP_ERROR_CHECK(bmx280_init(bmx280));

    bmx280_config_t bmx_cfg = BMX280_DEFAULT_CONFIG;
    ESP_ERROR_CHECK(bmx280_configure(bmx280, &bmx_cfg));

    while (1)
    {
        ESP_ERROR_CHECK(bmx280_setMode(bmx280, BMX280_MODE_FORCE));
        do {
            vTaskDelay(pdMS_TO_TICKS(1));
        } while(bmx280_isSampling(bmx280));

        float temp = 0, pres = 0, hum = 0;
        ESP_ERROR_CHECK(bmx280_readoutFloat(bmx280, &temp, &pres, &hum));

        ESP_LOGI("test", "Read Values: temp = %f, pres = %f, hum = %f", temp, pres, hum);
    }
}

License

This repository contains a lot of code I have written which is licensed under MIT, however there are sections modified from the BME280 datasheet which is unclearly licensed.

The unclearly licensed section is clearly marked with two comments. Any code between // HERE BE DRAGONS and // END OF DRAGONS contains modified versions of the Bosch Sensortec code.

Please take note of this in production.

esp-idf-bmx280's People

Contributors

jacobvc avatar utkumaden avatar

Stargazers

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

Watchers

 avatar

esp-idf-bmx280's Issues

bug in humidity readout?

*humidity = bme280_compensate_H_int32(bmx280, 
      (buffer[0] << 8) | buffer[0]
);

looks like a typo to me, bits from buffer[0] are 'double-used' and bits from buffer[1] are ignored ..

looks better like this:

*humidity = bme280_compensate_H_int32(bmx280, 
      (buffer[0] << 8) | buffer[1]
);

Fails to compile if BMP is selected in Kconfig

The bug is in the file bmx280_bits.h
The #ifndef CONFIG_BMX280_EXPECT_BMP280
is closed with #endif at the end of the file and not before
the #if !(CONFIG_BMX280_EXPECT_BMP280)
statement and this statement never will be executed

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.