diff --git a/README.md b/README.md new file mode 100644 index 0000000..6f77c24 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +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 +------------ +```c +#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. \ No newline at end of file diff --git a/bmx280.c b/bmx280.c index 04b375f..573907d 100644 --- a/bmx280.c +++ b/bmx280.c @@ -1,8 +1,18 @@ /** * BMX280 - BME280 & BMP280 Driver for Esspressif ESP-32. - * Copyright (C) 2020 - * H. Utku Maden + * + * MIT License + * + * Copyright (C) 2020 Halit Utku Maden + * Please contact at */ + +// LEGAL NOTE: +// Any code between below the caption "// HERE BE DRAGONS" and above the caption +// "// END OF DRAGONS" contains modified versions of code owned by Bosch +// Sensortec GmbH and it is not clearly licensed, therefore this code is not +// covered by the MIT of this repository. Use at your own risk. + #include "bmx280.h" #include "esp_log.h" @@ -422,6 +432,13 @@ bool bmx280_isSampling(bmx280_t* bmx280) return false; } + +// LEGAL NOTE: +// Any code between below the caption "// HERE BE DRAGONS" and above the caption +// "// END OF DRAGONS" contains modified versions of code owned by Bosch +// Sensortec GmbH and it is not clearly licensed, therefore this code is not +// covered by the MIT of this repository. Use at your own risk. + // HERE BE DRAGONS // This code is revised from the Bosch code within the datasheet of the BME280. // I do not understand it enough to tell you what it does. diff --git a/include/bmx280.h b/include/bmx280.h index 9a9b842..4580d68 100644 --- a/include/bmx280.h +++ b/include/bmx280.h @@ -1,8 +1,12 @@ /** * BMX280 - BME280 & BMP280 Driver for Esspressif ESP-32. - * Copyright (C) 2020 - * H. Utku Maden + * + * MIT License + * + * Copyright (C) 2020 Halit Utku Maden + * Please contact at */ + #ifndef _BMX280_H_ #define _BMX280_H_ diff --git a/include/bmx280_bits.h b/include/bmx280_bits.h index 7dc61ff..7f147d8 100644 --- a/include/bmx280_bits.h +++ b/include/bmx280_bits.h @@ -1,3 +1,12 @@ +/** + * BMX280 - BME280 & BMP280 Driver for Esspressif ESP-32. + * + * MIT License + * + * Copyright (C) 2020 Halit Utku Maden + * Please contact at + */ + #ifndef _BMX280_DEFAULT_H_ #define _BMX280_DEFAULT_H_ #ifndef _BMX280_H_