bme280 optimization
rodzic
e49c5b4ab6
commit
c1c8134530
|
@ -35,7 +35,8 @@ The symbol can now be changed without attached display - during normal operation
|
|||
<br>
|
||||
<b>Temperature Sensor:</b><br>
|
||||
for DHT22 I used the library from https://github.com/beegee-tokyo/DHTesp, as the standard library gives to many wrong readings<br>
|
||||
Now the DS18B20 is supported as well - uncomment line 31: // #define DS18B20 // use this if you use DS18B20, default ist DHT22<br>
|
||||
Now the DS18B20 is supported as well - uncomment line 37: // #define DS18B20 // use this if you use DS18B20, default ist DHT22<br>
|
||||
Now the BME280 is supported as well - uncomment line 38: // #define USE_BME280 // use this if you use BME280, default ist DHT22<br>
|
||||
<br>
|
||||
<b>show RX packets</b><br>
|
||||
by uncommenting <b>// #define SHOW_RX_PACKET</b> the tracker shows received LoRa APRS packets in raw format for the time in milliseconds defined in SHOW_RX_TIME - both in ...config.h<br>
|
||||
|
|
|
@ -49,10 +49,12 @@
|
|||
#ifdef DS18B20
|
||||
#include <OneWire.h> // libraries for DS18B20
|
||||
#include <DallasTemperature.h>
|
||||
#elif USE_BME280
|
||||
#include <Adafruit_BME280.h> // BME280 Library
|
||||
#else
|
||||
#ifdef USE_BME280
|
||||
#include <Adafruit_BME280.h> // BME280 Library
|
||||
#else
|
||||
#include <DHTesp.h> // library from https://github.com/beegee-tokyo/DHTesp for DHT22
|
||||
#endif
|
||||
#endif
|
||||
#include <driver/adc.h>
|
||||
#include <Wire.h>
|
||||
|
@ -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
|
||||
#ifdef USE_BME280
|
||||
Adafruit_BME280 bme; // if BME is used
|
||||
#else
|
||||
DHTesp dht; // Initialize DHT sensor for normal 16mhz Arduino
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -435,7 +439,8 @@ void setup()
|
|||
|
||||
#ifdef DS18B20
|
||||
sensors.begin();
|
||||
#elif USE_BME280
|
||||
#else
|
||||
#ifdef USE_BME280
|
||||
if (!bme.begin(0x76))
|
||||
{
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
|
@ -444,18 +449,21 @@ void setup()
|
|||
#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
|
||||
#else
|
||||
#ifdef USE_BME280
|
||||
temp = bme.readTemperature(); // bme Temperatur auslesen
|
||||
hum = bme.readHuminity();
|
||||
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=");
|
||||
Serial.print(String(temp));
|
||||
|
@ -522,20 +530,24 @@ 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
|
||||
#else
|
||||
#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
|
||||
#ifdef USE_BME280
|
||||
hum = bme.readHumidity();
|
||||
#else
|
||||
hum = dht.getHumidity();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (tracker_mode != WX_FIXED) {
|
||||
|
@ -827,13 +839,15 @@ 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
|
||||
#else
|
||||
#ifdef USE_BME280
|
||||
temp = bme.readTemperature();
|
||||
hum = bme.readHuminity();
|
||||
hum = bme.readHumidity();
|
||||
#else
|
||||
hum = dht.getHumidity();
|
||||
tempf = dht.getTemperature()*9/5+32;
|
||||
#endif
|
||||
#endif
|
||||
for (i=0; i<wxTcall.length();++i){ // remove unneeded "spaces" from callsign field
|
||||
if (wxTcall.charAt(i) != ' ') {
|
||||
outString += wxTcall.charAt(i);
|
||||
|
@ -875,13 +889,15 @@ 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
|
||||
#else
|
||||
#ifdef USE_BME280
|
||||
temp = bme.readTemperature(); // bme Temperatur auslesen
|
||||
hum = bme.readHuminity();
|
||||
hum = bme.readHumidity();
|
||||
#else
|
||||
hum = dht.getHumidity();
|
||||
tempf = dht.getTemperature()*9/5+32;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef TX_BASE91
|
||||
for (i=0; i<wxTcall.length();++i){ // remove unneeded "spaces" from callsign field
|
||||
if (wxTcall.charAt(i) != ' ') {
|
||||
|
@ -1000,13 +1016,15 @@ 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
|
||||
#else
|
||||
#ifdef USE_BME280
|
||||
temp = bme.readTemperature(); // bme Temperatur auslesen
|
||||
hum = bme.readHuminity();
|
||||
hum = bme.readHumidity();
|
||||
#else
|
||||
hum = dht.getHumidity();
|
||||
tempf = dht.getTemperature()*9/5+32;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef TX_BASE91
|
||||
|
|
Ładowanie…
Reference in New Issue