Merge pull request #506 from cyberman54/master

sync dev to master
This commit is contained in:
Verkehrsrot 2019-12-21 14:29:04 +01:00 committed by GitHub
commit 12f00a9203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 8 deletions

View File

@ -55,7 +55,7 @@ Depending on board hardware following features are supported:
- Silicon unique ID
- Battery voltage monitoring
- GPS (Generic serial NMEA, or Quectel L76 I2C)
- Environmental sensor (Bosch BME280/BME680 I2C)
- Environmental sensor (Bosch BMP180/BME280/BME680 I2C)
- Real Time Clock (Maxim DS3231 I2C)
- IF482 (serial) and DCF77 (gpio) time telegram generator
- Switch external power / battery
@ -163,7 +163,7 @@ by pressing the button of the device.
# Sensors and Peripherals
You can add up to 3 user defined sensors. Insert sensor's payload scheme in [*sensor.cpp*](src/sensor.cpp). Bosch BME280 / BME680 environment sensors are supported. Enable flag *lib_deps_sensors* for your board in [*platformio.ini*](src/platformio.ini) and configure BME in board's hal file before build. If you need Bosch's proprietary BSEC libraray (e.g. to get indoor air quality value from BME680) further enable *build_flags_sensors*, which comes on the price of reduced RAM and increased build size. RTC DS3231, generic serial NMEA GPS, I2C LoPy GPS are supported, and to be configured in board's hal file. See [*generic.h*](src/hal/generic.h) for all options and for proper configuration of BME280/BME680.
You can add up to 3 user defined sensors. Insert sensor's payload scheme in [*sensor.cpp*](src/sensor.cpp). Bosch BMP180 / BME280 / BME680 environment sensors are supported. Enable flag *lib_deps_sensors* for your board in [*platformio.ini*](src/platformio.ini) and configure BME in board's hal file before build. If you need Bosch's proprietary BSEC libraray (e.g. to get indoor air quality value from BME680) further enable *build_flags_sensors*, which comes on the price of reduced RAM and increased build size. RTC DS3231, generic serial NMEA GPS, I2C LoPy GPS are supported, and to be configured in board's hal file. See [*generic.h*](src/hal/generic.h) for all options and for proper configuration of BME280/BME680.
Output of user sensor data can be switched by user remote control command 0x14 sent to Port 2.

View File

@ -9,6 +9,8 @@
#elif defined HAS_BME280
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#elif defined HAS_BMP180
#include <Adafruit_BMP085.h>
#endif
extern Ticker bmecycler;

View File

@ -7,7 +7,7 @@
; ---> SELECT THE TARGET PLATFORM HERE! <---
[board]
halfile = generic.h
;halfile = generic.h
;halfile = ebox.h
;halfile = eboxtube.h
;halfile = ecopower.h
@ -18,7 +18,7 @@ halfile = generic.h
;halfile = ttgov21old.h
;halfile = ttgov21new.h
;halfile = ttgofox.h
;halfile = ttgobeam.h
halfile = ttgobeam.h
;halfile = ttgobeam10.h
;halfile = fipy.h
;halfile = lopy.h
@ -58,7 +58,8 @@ lib_deps_lora =
;MCCI LoRaWAN LMIC library@>=3.1.0
https://github.com/mcci-catena/arduino-lmic.git#5322dd1
lib_deps_display =
ss_oled@>=3.0.0
ss_oled@=3.0.0
;https://github.com/bitbank2/ss_oled.git#26f5d40
BitBang_I2C@>=1.2.0
QRCode@>=0.0.1
lib_deps_matrix_display =
@ -70,6 +71,7 @@ lib_deps_gps =
lib_deps_sensors =
Adafruit Unified Sensor@>=1.0.3
Adafruit BME280 Library@>=1.0.10
Adafruit BMP085 Library@>=1.0.1
lib_deps_basic =
ArduinoJson@^5.13.1
76@>=1.2.2 ; #76 Timezone by Jack Christensen

View File

@ -32,10 +32,16 @@ Bsec iaqSensor;
#elif defined HAS_BME280
Adafruit_BME280 bme; // I2C
Adafruit_BME280 bme; // using I2C interface
// use these alternative constructors for other hw interface types
// Adafruit_BME280 bme(BME_CS); // hardware SPI
// Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
#elif defined HAS_BMP180
Adafruit_BMP085 bmp; // I2C
#endif
void bmecycle() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); }
@ -105,6 +111,23 @@ int bme_init(void) {
goto finish;
}
#elif defined HAS_BMP180
bool status;
// block i2c bus access
if (I2C_MUTEX_LOCK()) {
// Wire.begin(21, 22);
status = bmp.begin();
if (!status) {
ESP_LOGE(TAG, "BMP180 sensor not found");
rc = 0;
goto finish;
}
ESP_LOGI(TAG, "BMP180 sensor found and initialized");
} else {
ESP_LOGE(TAG, "I2c bus busy - BMP180 initialization error");
rc = 0;
goto finish;
}
#endif
finish:
@ -168,6 +191,11 @@ void bme_storedata(bmeStatus_t *bme_store) {
// bme.readAltitude(SEALEVELPRESSURE_HPA);
bme_store->humidity = bme.readHumidity();
bme_store->iaq = 0; // IAQ feature not present with BME280
#elif defined HAS_BMP180
bme_store->temperature = bmp.readTemperature();
bme_store->pressure = (bmp.readPressure() / 100.0); // conversion Pa -> hPa
// bme.readAltitude(SEALEVELPRESSURE_HPA);
bme_store->iaq = 0; // IAQ feature not present with BME280
#endif
I2C_MUTEX_UNLOCK(); // release i2c bus access

View File

@ -81,6 +81,9 @@ void doHousekeeping() {
#elif defined HAS_BME280
ESP_LOGI(TAG, "BME280 Temp: %.2f°C | Humidity: %.2f | Pressure: %.0f",
bme_status.temperature, bme_status.humidity, bme_status.pressure);
#elif defined HAS_BMP180
ESP_LOGI(TAG, "BMP180 Temp: %.2f°C | Pressure: %.0f",
bme_status.temperature, bme_status.pressure);
#endif
#endif

View File

@ -56,7 +56,7 @@ static const char TAG[] = __FILE__;
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
uint8_t DisplayIsOn = 0;
uint8_t displaybuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
static uint8_t displaybuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
QRCode qrcode;
@ -82,6 +82,9 @@ void init_display(bool verbose) {
oledInit(OLED_128x64, true, false, -1, -1, 400000L);
#endif
// set display buffer
//oledSetBackBuffer(displaybuf);
// clear display
oledSetContrast(DISPLAYCONTRAST);
oledFill(0, 1);

View File

@ -36,6 +36,10 @@
//#define HAS_BME280 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
//#define BME280_ADDR 0x76 // change to 0x77 depending on your wiring
// BMP180 sensor on I2C bus
//#define HAS_BMP180
//#define BMP180_ADDR 0x77
// user defined sensors
//#define HAS_SENSORS 1 // comment out if device has user defined sensors

View File

@ -12,6 +12,8 @@
//#define HAS_BME 1 // Enable BME sensors in general
//#define HAS_BME680 GPIO_NUM_4, GPIO_NUM_15 // SDA, SCL
//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND
//#define HAS_BMP180
//#define BMP180_ADDR 0x77
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define CFG_sx1276_radio 1

View File

@ -390,6 +390,8 @@ void setup() {
strcat_P(features, " BME680");
#elif defined HAS_BME280
strcat_P(features, " BME280");
#elif defined HAS_BMP180
strcat_P(features, " BMP180");
#endif
if (bme_init())
ESP_LOGI(TAG, "Starting BME sensor...");