BME680 support (experimental)
This commit is contained in:
parent
4ae4633a15
commit
9c66167303
@ -47,11 +47,11 @@ typedef struct {
|
||||
} gpsStatus_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t temperature;
|
||||
uint16_t pressure;
|
||||
uint16_t humidity;
|
||||
uint16_t gas_resistance;
|
||||
uint16_t altitude;
|
||||
float_t temperature;
|
||||
float_t pressure;
|
||||
float_t humidity;
|
||||
float_t gas_resistance;
|
||||
float_t altitude;
|
||||
} bmeStatus_t;
|
||||
|
||||
// global variables
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
uint8_t reset1, uint8_t reset2);
|
||||
void addAlarm(int8_t rssi, uint8_t message);
|
||||
void addGPS(gpsStatus_t value);
|
||||
void addBME(bmeStatus_t value);
|
||||
void addButton(uint8_t value);
|
||||
|
||||
#if PAYLOAD_ENCODER == 1 // format plain
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
; ---> SELECT TARGET PLATFORM HERE! <---
|
||||
[platformio]
|
||||
;env_default = generic
|
||||
env_default = generic
|
||||
;env_default = ebox
|
||||
;env_default = eboxtube
|
||||
env_default = heltec
|
||||
;env_default = heltec
|
||||
;env_default = heltecv2
|
||||
;env_default = ttgov1
|
||||
;env_default = ttgov2
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user