diff --git a/platformio.ini b/platformio.ini index a4b451d..477d83f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,23 +8,19 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -;[env:heltec_wifi_lora_32] [env:ttgo-t-beam] platform = espressif32 -;board = heltec_wifi_lora_32 board = ttgo-t-beam framework = arduino - -; Custom Serial Monitor speed (baud rate) monitor_speed = 115200 - -lib_deps = - RadioHead - TinyGPSPlus - DHT sensor library for ESPx - Adafruit SSD1306 - Adafruit GFX Library - Adafruit Unified Sensor - AXP202X_Library - OneWire - DallasTemperature +lib_deps = + RadioHead + TinyGPSPlus + DHT sensor library for ESPx + Adafruit SSD1306 + Adafruit GFX Library + Adafruit Unified Sensor + AXP202X_Library + OneWire + DallasTemperature + adafruit/Adafruit BME280 Library@^2.1.2 diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 33bb104..1cfbf5b 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -49,12 +49,15 @@ #ifdef DS18B20 #include // libraries for DS18B20 #include +#elif USE_BME280 + #include // BME280 Library #else #include // library from https://github.com/beegee-tokyo/DHTesp for DHT22 #endif #include #include +#include #include #include #include @@ -155,6 +158,7 @@ const byte RX_en = 0; //TX/RX enable 1W modul #define DHTPIN 25 // the DHT22 is connected to PIN25 #define ONE_WIRE_BUS 25 // the DS18B20 is connected to PIN25 + // Variables for APRS packaging String Tcall; //your Call Sign for normal position reports String wxTcall; //your Call Sign for weather reports @@ -236,6 +240,8 @@ void setup_data(void); #ifdef DS18B20 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); +#elif USE_BME280 + Adafruit_BME280 bme; // if BME is used #else DHTesp dht; // Initialize DHT sensor for normal 16mhz Arduino #endif @@ -429,19 +435,29 @@ void setup() #ifdef DS18B20 sensors.begin(); + #elif USE_BME280 + if (!bme.begin(0x76)) + { + Serial.println("Could not find a valid BME280 sensor, check wiring!"); + while (1); + } #else dht.setup(DHTPIN,dht.AUTO_DETECT); // initialize DHT22 #endif delay(250); + #ifdef DS18B20 sensors.requestTemperatures(); // Send the command to get temperature readings temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only - #else + #elif USE_BME280 + temp = bme.readTemperature(); // bme Temperatur auslesen + hum = bme.readHuminity(); + #else temp = dht.getTemperature(); hum = dht.getHumidity(); #endif - writedisplaytext("LoRa-APRS","","Init:","DHT OK!","TEMP: "+String(temp,1),"HUM: "+String(hum,1),250); - Serial.print("LoRa-APRS / Init / DHT OK! Temp="); + writedisplaytext("LoRa-APRS","","Init:","Temp OK!","TEMP: "+String(temp,1),"HUM: "+String(hum,1),250); + Serial.print("LoRa-APRS / Init / Temp OK! Temp="); Serial.print(String(temp)); Serial.print(" Hum="); Serial.println(String(hum)); @@ -506,6 +522,8 @@ void loop() { #ifdef DS18B20 sensors.requestTemperatures(); // Send the command to get temperature readings temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only + #elif USE_BME280 + temp = bme.readTemperature(); // bme Temperatur auslesen #else temp = dht.getTemperature(); #endif @@ -513,6 +531,8 @@ void loop() { hum_temp=true; #ifdef DS18B20 hum = 0; + #elif USE_BME280 + hum = bme.readHuminity(); #else hum = dht.getHumidity(); #endif @@ -807,6 +827,9 @@ switch(tracker_mode) { sensors.requestTemperatures(); // Send the command to get temperature readings tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only hum = 0; + #elif USE_BME280 + temp = bme.readTemperature(); + hum = bme.readHuminity(); #else hum = dht.getHumidity(); tempf = dht.getTemperature()*9/5+32; @@ -852,6 +875,9 @@ switch(tracker_mode) { sensors.requestTemperatures(); // Send the command to get temperature readings tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only hum = 0; + #elif USE_BME280 + temp = bme.readTemperature(); // bme Temperatur auslesen + hum = bme.readHuminity(); #else hum = dht.getHumidity(); tempf = dht.getTemperature()*9/5+32; @@ -974,6 +1000,9 @@ case WX_MOVE: sensors.requestTemperatures(); // Send the command to get temperature readings tempf = sensors.getTempFByIndex(0); // get temp from 1st (!) sensor only hum = 0; + #elif USE_BME280 + temp = bme.readTemperature(); // bme Temperatur auslesen + hum = bme.readHuminity(); #else hum = dht.getHumidity(); tempf = dht.getTemperature()*9/5+32; diff --git a/src/TTGO_T-Beam_LoRa_APRS_config.h b/src/TTGO_T-Beam_LoRa_APRS_config.h index 587429d..17dbe43 100644 --- a/src/TTGO_T-Beam_LoRa_APRS_config.h +++ b/src/TTGO_T-Beam_LoRa_APRS_config.h @@ -34,7 +34,8 @@ // #define T_BEAM_V0_7 // use this for older Boards AKA Rev0.x (first board release) // 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 // IF NOT CHANGED you have to go through the configuration routine at first boot up of the TTGO T-Beam