diff --git a/README.md b/README.md index 48e893b..e8e54cc 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ The symbol can now be changed without attached display - during normal operation
Temperature Sensor:
for DHT22 I used the library from https://github.com/beegee-tokyo/DHTesp, as the standard library gives to many wrong readings
-Now the DS18B20 is supported as well - uncomment line 31: // #define DS18B20 // use this if you use DS18B20, default ist DHT22
+Now the DS18B20 is supported as well - uncomment line 37: // #define DS18B20 // use this if you use DS18B20, default ist DHT22
+Now the BME280 is supported as well - uncomment line 38: // #define USE_BME280 // use this if you use BME280, default ist DHT22

show RX packets
by uncommenting // #define SHOW_RX_PACKET the tracker shows received LoRa APRS packets in raw format for the time in milliseconds defined in SHOW_RX_TIME - both in ...config.h
diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 1cfbf5b..5b43b93 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -49,10 +49,12 @@ #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 + #ifdef USE_BME280 + #include // BME280 Library + #else + #include // library from https://github.com/beegee-tokyo/DHTesp for DHT22 + #endif #endif #include #include @@ -240,10 +242,12 @@ 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 + #ifdef USE_BME280 + Adafruit_BME280 bme; // if BME is used + #else + DHTesp dht; // Initialize DHT sensor for normal 16mhz Arduino + #endif #endif @@ -435,26 +439,30 @@ 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 + #ifdef 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 #endif delay(250); #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 - hum = bme.readHuminity(); #else - temp = dht.getTemperature(); - hum = dht.getHumidity(); + #ifdef USE_BME280 + temp = bme.readTemperature(); // bme Temperatur auslesen + hum = bme.readHumidity(); + #else + temp = dht.getTemperature(); + hum = dht.getHumidity(); + #endif #endif writedisplaytext("LoRa-APRS","","Init:","Temp OK!","TEMP: "+String(temp,1),"HUM: "+String(hum,1),250); Serial.print("LoRa-APRS / Init / Temp OK! Temp="); @@ -522,19 +530,23 @@ 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(); + #ifdef USE_BME280 + temp = bme.readTemperature(); // bme Temperatur auslesen + #else + temp = dht.getTemperature(); + #endif #endif } else { hum_temp=true; #ifdef DS18B20 hum = 0; - #elif USE_BME280 - hum = bme.readHuminity(); #else - hum = dht.getHumidity(); + #ifdef USE_BME280 + hum = bme.readHumidity(); + #else + hum = dht.getHumidity(); + #endif #endif } @@ -827,12 +839,14 @@ 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; + #ifdef USE_BME280 + temp = bme.readTemperature(); + hum = bme.readHumidity(); + #else + hum = dht.getHumidity(); + tempf = dht.getTemperature()*9/5+32; + #endif #endif for (i=0; i