BME680 support (experimental)

This commit is contained in:
Klaus K Wilting committed 2018-11-14 23:10:59 +01:00
1 parent 4ae4633a15
commit 9c66167303
7 files changed
+38 -21

No files matched your search

+7 -8
View File
@@ -47,15 +47,14 @@ void bme_loop(void *pvParameters) {
if (!bme.performReading()) {
ESP_LOGE(TAG, "BME680 read error");
continue;
} else {
// read current BME data and buffer in global struct
bme_status.temperature = bme.temperature;
bme_status.pressure = bme.pressure / 100.0;
bme_status.humidity = bme.humidity;
bme_status.gas_resistance = bme.gas_resistance / 1000.0;
bme_status.altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
}
// read BME data and cast to global struct
bme_status.temperature = (uint16_t)bme.temperature;
bme_status.pressure = (uint16_t)(bme.pressure / 100.0);
bme_status.humidity = (uint16_t)bme.humidity;
bme_status.gas_resistance = (uint16_t)(bme.gas_resistance / 1000.0);
bme_status.altitude = (uint16_t)bme.readAltitude(SEALEVELPRESSURE_HPA);
} // end of infinite loop
vTaskDelete(NULL); // shoud never be reached
-4
View File
@@ -3,13 +3,9 @@
#include <stdint.h>
#define HAS_BME 1 // BME680 sensor on I2C bus (SDA=4/SCL=15); comment out if not present
// Hardware related definitions for Heltec LoRa-32 Board
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define CFG_sx1276_radio 1
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board
#define HAS_LED (25) // white LED on board
#define HAS_BUTTON (0) // button "PROG" on board
+3 -2
View File
@@ -21,7 +21,8 @@
//#define LMIC_USE_INTERRUPTS
#define LMIC_ENABLE_DeviceTimeReq 1
//time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3)
//#define LMIC_ENABLE_DeviceTimeReq 1
// 16 μs per tick
// LMIC requires ticks to be 15.5μs - 100 μs long
@@ -40,7 +41,7 @@
// enable more verbose output. Make sure that printf is actually
// configured (e.g. on AVR it is not by default), otherwise using it can
// cause crashing.
#define LMIC_DEBUG_LEVEL 2
#define LMIC_DEBUG_LEVEL 0
// Enable this to allow using printf() to print to the given serial port
// (or any other Print object). This can be easy for debugging. The
+20
View File
@@ -93,6 +93,16 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
#endif
}
void PayloadConvert::addBME(bmeStatus_t value) {
#ifdef HAS_BME
buffer[cursor++] = (byte)(value.temperature);
buffer[cursor++] = (byte)(value.pressure);
buffer[cursor++] = (byte)(value.humidity);
buffer[cursor++] = (byte)(value.gas_resistance);
buffer[cursor++] = (byte)(value.altitude);
#endif
}
void PayloadConvert::addButton(uint8_t value) {
#ifdef HAS_BUTTON
buffer[cursor++] = value;
@@ -150,6 +160,16 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
#endif
}
void PayloadConvert::addBME(bmeStatus_t value) {
#ifdef HAS_BME
writeUint8((byte)value.temperature);
writeUint8((byte)value.pressure);
writeUint8((byte)value.humidity);
writeUint8((byte)value.gas_resistance);
writeUint8((byte)value.altitude);
#endif
}
void PayloadConvert::addButton(uint8_t value) {
#ifdef HAS_BUTTON
writeUint8(value);