BME280 1st test

pull/9/head
Christian OE3CJB Bauer 2020-12-13 10:35:40 +01:00
rodzic b919e2969d
commit e49c5b4ab6
3 zmienionych plików z 45 dodań i 19 usunięć

Wyświetl plik

@ -8,16 +8,11 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
;[env:heltec_wifi_lora_32]
[env:ttgo-t-beam] [env:ttgo-t-beam]
platform = espressif32 platform = espressif32
;board = heltec_wifi_lora_32
board = ttgo-t-beam board = ttgo-t-beam
framework = arduino framework = arduino
; Custom Serial Monitor speed (baud rate)
monitor_speed = 115200 monitor_speed = 115200
lib_deps = lib_deps =
RadioHead RadioHead
TinyGPSPlus TinyGPSPlus
@ -28,3 +23,4 @@ lib_deps =
AXP202X_Library AXP202X_Library
OneWire OneWire
DallasTemperature DallasTemperature
adafruit/Adafruit BME280 Library@^2.1.2

Wyświetl plik

@ -49,12 +49,15 @@
#ifdef DS18B20 #ifdef DS18B20
#include <OneWire.h> // libraries for DS18B20 #include <OneWire.h> // libraries for DS18B20
#include <DallasTemperature.h> #include <DallasTemperature.h>
#elif USE_BME280
#include <Adafruit_BME280.h> // BME280 Library
#else #else
#include <DHTesp.h> // library from https://github.com/beegee-tokyo/DHTesp for DHT22 #include <DHTesp.h> // library from https://github.com/beegee-tokyo/DHTesp for DHT22
#endif #endif
#include <driver/adc.h> #include <driver/adc.h>
#include <Wire.h> #include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_SSD1306.h> #include <Adafruit_SSD1306.h>
#include <splash.h> #include <splash.h>
#include <Adafruit_GFX.h> #include <Adafruit_GFX.h>
@ -155,6 +158,7 @@ const byte RX_en = 0; //TX/RX enable 1W modul
#define DHTPIN 25 // the DHT22 is connected to PIN25 #define DHTPIN 25 // the DHT22 is connected to PIN25
#define ONE_WIRE_BUS 25 // the DS18B20 is connected to PIN25 #define ONE_WIRE_BUS 25 // the DS18B20 is connected to PIN25
// Variables for APRS packaging // Variables for APRS packaging
String Tcall; //your Call Sign for normal position reports String Tcall; //your Call Sign for normal position reports
String wxTcall; //your Call Sign for weather reports String wxTcall; //your Call Sign for weather reports
@ -236,6 +240,8 @@ void setup_data(void);
#ifdef DS18B20 #ifdef DS18B20
OneWire oneWire(ONE_WIRE_BUS); OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); DallasTemperature sensors(&oneWire);
#elif USE_BME280
Adafruit_BME280 bme; // if BME is used
#else #else
DHTesp dht; // Initialize DHT sensor for normal 16mhz Arduino DHTesp dht; // Initialize DHT sensor for normal 16mhz Arduino
#endif #endif
@ -429,19 +435,29 @@ void setup()
#ifdef DS18B20 #ifdef DS18B20
sensors.begin(); sensors.begin();
#elif USE_BME280
if (!bme.begin(0x76))
{
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
#else #else
dht.setup(DHTPIN,dht.AUTO_DETECT); // initialize DHT22 dht.setup(DHTPIN,dht.AUTO_DETECT); // initialize DHT22
#endif #endif
delay(250); delay(250);
#ifdef DS18B20 #ifdef DS18B20
sensors.requestTemperatures(); // Send the command to get temperature readings sensors.requestTemperatures(); // Send the command to get temperature readings
temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only
#elif USE_BME280
temp = bme.readTemperature(); // bme Temperatur auslesen
hum = bme.readHuminity();
#else #else
temp = dht.getTemperature(); temp = dht.getTemperature();
hum = dht.getHumidity(); hum = dht.getHumidity();
#endif #endif
writedisplaytext("LoRa-APRS","","Init:","DHT OK!","TEMP: "+String(temp,1),"HUM: "+String(hum,1),250); writedisplaytext("LoRa-APRS","","Init:","Temp OK!","TEMP: "+String(temp,1),"HUM: "+String(hum,1),250);
Serial.print("LoRa-APRS / Init / DHT OK! Temp="); Serial.print("LoRa-APRS / Init / Temp OK! Temp=");
Serial.print(String(temp)); Serial.print(String(temp));
Serial.print(" Hum="); Serial.print(" Hum=");
Serial.println(String(hum)); Serial.println(String(hum));
@ -506,6 +522,8 @@ void loop() {
#ifdef DS18B20 #ifdef DS18B20
sensors.requestTemperatures(); // Send the command to get temperature readings sensors.requestTemperatures(); // Send the command to get temperature readings
temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only
#elif USE_BME280
temp = bme.readTemperature(); // bme Temperatur auslesen
#else #else
temp = dht.getTemperature(); temp = dht.getTemperature();
#endif #endif
@ -513,6 +531,8 @@ void loop() {
hum_temp=true; hum_temp=true;
#ifdef DS18B20 #ifdef DS18B20
hum = 0; hum = 0;
#elif USE_BME280
hum = bme.readHuminity();
#else #else
hum = dht.getHumidity(); hum = dht.getHumidity();
#endif #endif
@ -807,6 +827,9 @@ switch(tracker_mode) {
sensors.requestTemperatures(); // Send the command to get temperature readings sensors.requestTemperatures(); // Send the command to get temperature readings
tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only
hum = 0; hum = 0;
#elif USE_BME280
temp = bme.readTemperature();
hum = bme.readHuminity();
#else #else
hum = dht.getHumidity(); hum = dht.getHumidity();
tempf = dht.getTemperature()*9/5+32; tempf = dht.getTemperature()*9/5+32;
@ -852,6 +875,9 @@ switch(tracker_mode) {
sensors.requestTemperatures(); // Send the command to get temperature readings sensors.requestTemperatures(); // Send the command to get temperature readings
tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only
hum = 0; hum = 0;
#elif USE_BME280
temp = bme.readTemperature(); // bme Temperatur auslesen
hum = bme.readHuminity();
#else #else
hum = dht.getHumidity(); hum = dht.getHumidity();
tempf = dht.getTemperature()*9/5+32; tempf = dht.getTemperature()*9/5+32;
@ -974,6 +1000,9 @@ case WX_MOVE:
sensors.requestTemperatures(); // Send the command to get temperature readings sensors.requestTemperatures(); // Send the command to get temperature readings
tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only
hum = 0; hum = 0;
#elif USE_BME280
temp = bme.readTemperature(); // bme Temperatur auslesen
hum = bme.readHuminity();
#else #else
hum = dht.getHumidity(); hum = dht.getHumidity();
tempf = dht.getTemperature()*9/5+32; tempf = dht.getTemperature()*9/5+32;

Wyświetl plik

@ -34,7 +34,8 @@
// #define T_BEAM_V0_7 // use this for older Boards AKA Rev0.x (first board release) // #define T_BEAM_V0_7 // use this for older Boards AKA Rev0.x (first board release)
// SET temperature sensor type // SET temperature sensor type
// #define DS18B20 // use this if you use DS18B20, default ist DHT22 // #define DS18B20 // use this if you use DS18B20, default is DHT22
// #define USE_BME280 // use this if you use BME280,m default is BDHT22
// USER DATA - USE THESE LINES TO MODIFY YOUR PREFERENCES // USER DATA - USE THESE LINES TO MODIFY YOUR PREFERENCES
// IF NOT CHANGED you have to go through the configuration routine at first boot up of the TTGO T-Beam // IF NOT CHANGED you have to go through the configuration routine at first boot up of the TTGO T-Beam