Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Arduino Library Registry #3

Merged
merged 7 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# Bosch BME280 Arduino
based on Bosch BME280_driver v3.5.1

List of content<br>
* [About](#about)<br>
* [Functionality](#functionality)<br>
* [Namespace](#namespace)<br>
* [Methods](#methods)<br>
* [Example](#example)<br>
* [Compatibility](#compatibility)
* [Copyright](#copyright)


## About
The Bosch BME280 is an environmental sensor which is able to measure temperature, humidity and air pressure.

This library is based on the Bosch Sensortec BME280 driver API v3.5.1, and is intented to measure the these environmental signals via I²C connection on an Arduino based or ESP based microcontroller.
This library is based on the Bosch Sensortec BME280 driver API v3.5.1, and is intented to measure these environmental signals via I²C connection on an Arduino based or ESP based microcontroller.

The github repository of Bosch Sensortec is: https://github.com/BoschSensortec/BME280_driver
The github repository of Bosch Sensortec is: [Github BOSCH Sensor Driver](https://github.com/BoschSensortec/BME280_driver)

The website of the BME280 on Bosch Sensortec is: https://www.bosch-sensortec.com/products/environmental-sensors/humidity-sensors-bme280/
The website of the BME280 on Bosch Sensortec is: [Bosch Sensortec BME280](https://www.bosch-sensortec.com/products/environmental-sensors/humidity-sensors-bme280/)

## Functionality
The original Bosch driver is included in this package and it has not been modified in any way.
The Bosch BME280 sensor do have 3 operation modes.
1. Sleep mode - the sensor is in sleep mode after power on reset. No measurements are performed and power consumtion is on minimum.
2. Forced mode - one single measurement is performed and returns then to sleep mode. The measurements can be obtained from the data registers.
3. Normal mode - cyclic measurements are performed. The measurements can be obtained fron the data registers.
1. **Sleep mode** - the sensor is in sleep mode after power on reset. No measurements are performed and power consumtion is on minimum.
2. **Forced mode** - one single measurement is performed and returns then to sleep mode. The measurements can be obtained from the data registers.
3. **Normal mode** - cyclic measurements are performed. The measurements can be obtained fron the data registers.

## Namespace
This Bosch BME280 Wraper uses a namespace as `BME` so if you construct the object you have to call:
Expand Down Expand Up @@ -52,7 +62,17 @@ getHumidity()
getPressure()
getSealevelForAltitude()
```
### Short Example
#### Sensor Status
Also it is possible to get and set the sensor status.
```
int8_t status = getSensorStatus();
setSensorStatus(status);
```

### Example
See also in:
[Arduino_example.ino](https://github.com/hasenradball/Bosch_BME280_Arduino/blob/master/examples/Arduino_example/Arduino_example.ino)

```
#include <Arduino.h>
#include <Bosch_BME280_Arduino.h>
Expand Down Expand Up @@ -89,12 +109,18 @@ void loop() {


## Compatibility
* Tested with Arduino Nano, ESP8266 and ESP32
Tested with:
* Arduino Nano
* ESP8266
* ESP32
* Arduino Nano 33 IOT

## Copyright
The Files:
The Files of the original Bosch BME280 driver API:
* bme280.c
* bme280.h
* bme280_defs.h

are Copyright (c) 2013 - 2017 by Bosch Sensortec GmbH

[back to top](#bosch-bme280-arduino)
20 changes: 20 additions & 0 deletions keyword.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Syntax Coloring Map For Bosch_BME280_Arduino Library

# Datatypes (KEYWORD1)
BME KEYWORD1
Bosch_BME280 KEYWORD1

# Methods and Functions (KEYWORD2)
begin KEYWORD2
measure KEYWORD2
getTemperature KEYWORD2
getHumidity KEYWORD2
getPressure KEYWORD2
getSealevelForAltitude KEYWORD2
getSensorStatus KEYWORD2
setSensorStatus KEYWORD2


# Constants (LITERAL1)
BME280_I2C_ADDR_PRIM LITERAL1
BME280_I2C_ADDR_SEC LITERAL1
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bosch_BME280_Arduino",
"version": "1.0.1",
"version": "1.0.2",
"repository":
{
"type": "git",
Expand All @@ -16,5 +16,5 @@
"maintainer": true
},
"frameworks": ["Arduino"],
"platforms": ["atmelavr", "espressif8266", "espressif32"]
"platforms": ["atmelavr", "espressif8266", "espressif32", "atmelsam"]
}
10 changes: 10 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=Bosch_BME280_Arduino
version=1.0.2
author=Frank Häfele <[email protected]>
maintainer=Frank Häfele <[email protected]>
sentence=C++ Library for the Bosch BME280 Sensor based on the original Bosch Sensor API v3.5.1
paragraph=Provides a Namespace, setter and getter functions to get access to read temperature, humidity amd pressure signals.
category=Sensors
url=https://github.com/hasenradball/Bosch_BME280_Arduino
architectures=*
includes=Bosch_BME280_Arduino.h
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 16 additions & 10 deletions Bosch_BME280_Arduino.cpp → src/Bosch_BME280_Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,31 +194,37 @@ int8_t BME::Bosch_BME280::setSensorSettings() {
*/
void BME::Bosch_BME280::bme280_print_error_codes(const char *api_name, int8_t result) {
if (result != BME280_OK) {
Serial.printf("%s\t", api_name);
Serial.print(api_name);
Serial.print("\tError [");
switch (result)
{
case BME280_E_NULL_PTR:
Serial.printf("Error [%d] : Null pointer error.\n", result);
Serial.printf("\t\t=> It occurs when the user tries to assign value (not address) to a pointer, which has been initialized to NULL.\r\n\n");
Serial.print(result);
Serial.print("] : Null pointer error.\n");
Serial.print("\t\t=> It occurs when the user tries to assign value (not address) to a pointer, which has been initialized to NULL.\r\n\n");
break;

case BME280_E_COMM_FAIL:
Serial.printf("Error [%d] : Communication failure error.\n", result);
Serial.printf("\t\t=> It occurs due to read/write operation failure and also due to power failure during communication\r\n\n");
Serial.print(result);
Serial.print("] : Communication failure error.\n");
Serial.print("\t\t=> It occurs due to read/write operation failure and also due to power failure during communication\r\n\n");
break;

case BME280_E_DEV_NOT_FOUND:
Serial.printf("Error [%d] : Device not found error.\n", result);
Serial.printf("\t\t=> It occurs when the device chip id is incorrectly read\r\n\n");
Serial.print(result);
Serial.print("] : Device not found error.\n");
Serial.print("\t\t=> It occurs when the device chip id is incorrectly read\r\n\n");
break;

case BME280_E_INVALID_LEN:
Serial.printf("Error [%d] : Invalid length error.\n", result);
Serial.printf("\t\t=> It occurs when write is done with invalid length\r\n\n");
Serial.print(result);
Serial.print("] : Invalid length error.\n");
Serial.print("\t\t=> It occurs when write is done with invalid length\r\n\n");
break;

default:
Serial.printf("Error [%d] : Unknown error code\r\n\n", result);
Serial.print(result);
Serial.print("] : Unknown error code\r\n\n");
break;
}
}
Expand Down
1 change: 0 additions & 1 deletion Bosch_BME280_Arduino.h → src/Bosch_BME280_Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define _BOSCH_BME280_ARDUINO_H_
#include <Arduino.h>
#include <Wire.h>
#include <DBG_Print.h>
#include "BME280_API/bme280.h"

namespace BME {
Expand Down