Return support for BMP280 support
parent
197c65353e
commit
1e84436a99
|
@ -1,10 +1,10 @@
|
|||
|
||||
#ifndef BUILD_NUMBER
|
||||
#define BUILD_NUMBER "24"
|
||||
#define BUILD_NUMBER "42"
|
||||
#endif
|
||||
#ifndef VERSION
|
||||
#define VERSION "v0.3.24- - 2021-09-29 22:13:03.131112"
|
||||
#define VERSION "v0.4.4.42- - 2021-10-01 23:06:06.962206"
|
||||
#endif
|
||||
#ifndef VERSION_SHORT
|
||||
#define VERSION_SHORT "v0.3.24-"
|
||||
#define VERSION_SHORT "v0.4.4.42-"
|
||||
#endif
|
||||
|
|
|
@ -20,11 +20,12 @@ extra_scripts =
|
|||
pre:tools/buildscript_versioning.py
|
||||
pre:tools/compress_assets.py
|
||||
lib_deps =
|
||||
RadioHead
|
||||
http://git.mis.ks.ua/US1GHQ/RadioHead.git
|
||||
TinyGPSPlus
|
||||
Adafruit SSD1306
|
||||
Adafruit GFX Library
|
||||
Adafruit Unified Sensor
|
||||
adafruit/Adafruit BMP280 Library @ 2.4.0
|
||||
https://github.com/SQ9MDD/AXP202X_Library.git
|
||||
SparkFun u-blox Arduino Library
|
||||
bblanchon/ArduinoJson
|
||||
|
@ -56,6 +57,8 @@ build_flags =
|
|||
-D 'TNC_SELF_TELEMETRY_INTERVAL=3600L' ; can be set from www interface (seconds)
|
||||
-D 'SHOW_OLED_TIME=15000' ; OLED Timeout
|
||||
; -D 'TX_RX_LNA' ; Set external pins for 1W modules
|
||||
; -D 'USE_BME280' ; BMP280 Temp sensor for simple WX station
|
||||
; -D 'HEIGTH_PRESET=34'
|
||||
|
||||
[env:ttgo-t-beam-v1.0]
|
||||
platform = espressif32 @ 3.3.2
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
#include "taskWebServer.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BME280
|
||||
#include <Adafruit_BMP280.h> // BMP280 Library
|
||||
#endif
|
||||
|
||||
// oled address
|
||||
#define SSD1306_ADDRESS 0x3C
|
||||
|
||||
|
@ -166,6 +170,11 @@ String tel_path;
|
|||
#else
|
||||
boolean enabled_oled = false;
|
||||
#endif
|
||||
#ifdef USE_BME280
|
||||
boolean enable_bme280 = true;
|
||||
#else
|
||||
boolean enable_bme280 = false;
|
||||
#endif
|
||||
|
||||
// Variables and Constants
|
||||
String loraReceivedFrameString = ""; //data on buff is copied to this string
|
||||
|
@ -245,6 +254,16 @@ String infoApAddr = "";
|
|||
float average_course[ANGLE_AVGS];
|
||||
float avg_c_y, avg_c_x;
|
||||
|
||||
//Variables for BME Sensors
|
||||
boolean hum_temp = false;
|
||||
uint8_t hum_temp_ctr, hum_temp_ctr_max = 3;
|
||||
boolean tempsensoravailable=true;
|
||||
float hum=0; //Stores humidity value
|
||||
float temp=99.99; //Stores temperature value
|
||||
float tempf=99.99; //Stores temperature value
|
||||
float pressure=0; //Stores pressure value in hPa
|
||||
int pressure_offset=0; //Stores offset for pressure correction
|
||||
|
||||
uint8_t txPower = TXdbmW;
|
||||
|
||||
#ifdef ENABLE_WIFI
|
||||
|
@ -274,6 +293,11 @@ uint8_t loraReceivedLength = sizeof(lora_RXBUFF);
|
|||
#define OLED_RESET 16
|
||||
#endif
|
||||
|
||||
//Temp sensor
|
||||
#ifdef USE_BME280
|
||||
Adafruit_BMP280 bme; // if BME is used
|
||||
#endif
|
||||
|
||||
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
|
||||
|
||||
// + FUNCTIONS-----------------------------------------------------------+//
|
||||
|
@ -347,6 +371,39 @@ void prepareAPRSFrame(){
|
|||
outString += aprsSymbolTable;
|
||||
outString += aprsLonPreset;
|
||||
outString += aprsSymbol;
|
||||
#ifdef USE_BME280
|
||||
if(enable_bme280)
|
||||
{
|
||||
// bme.takeForcedMeasurement();
|
||||
tempf = bme.readTemperature()*9/5+29;
|
||||
// hum = bme.readHumidity();
|
||||
pressure = bme.readPressure()/100 + pressure_offset;
|
||||
outString += ".../...g...t";
|
||||
if (tempf < 0) { // negative Werte erstellen
|
||||
outString += "-";
|
||||
if(tempf>-10) {outString += "0"; }
|
||||
tempf = abs(tempf);
|
||||
}
|
||||
else
|
||||
{ // positive Werte erstellen
|
||||
if(tempf<100) {outString += "0"; }
|
||||
if(tempf<10) {outString += "0"; }
|
||||
}
|
||||
helper = String(tempf-3,0);
|
||||
helper.trim();
|
||||
outString += helper;
|
||||
outString += "r...p...P...h";
|
||||
if(hum<10) {outString += "0"; }
|
||||
helper = String(hum,0);
|
||||
helper.trim();
|
||||
outString += helper;
|
||||
outString += "b";
|
||||
if(pressure<1000) {outString += "0"; }
|
||||
helper = String(pressure*10,0);
|
||||
helper.trim();
|
||||
outString += helper;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(show_cmt){
|
||||
|
@ -660,6 +717,7 @@ void setup(){
|
|||
#endif
|
||||
|
||||
SPI.begin(SPI_sck,SPI_miso,SPI_mosi,SPI_ss); //DO2JMG Heltec Patch
|
||||
bool bme_status;
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef BUZZER
|
||||
|
@ -1037,10 +1095,26 @@ void setup(){
|
|||
writedisplaytext("","","","","","");
|
||||
time_to_refresh = millis() + showRXTime;
|
||||
displayInvalidGPS();
|
||||
#ifdef TX_RX_LNA
|
||||
|
||||
#ifdef USE_BME280
|
||||
bme_status = bme.begin(0x76);
|
||||
if (!bme_status)
|
||||
{
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
//writedisplaytext("LoRa-APRS","","Init:","BME280 ERROR!","","",3000);
|
||||
tempsensoravailable = false;
|
||||
}
|
||||
pressure_offset = calc_pressure_offset(HEIGTH_PRESET);
|
||||
// bme.takeForcedMeasurement();
|
||||
temp = bme.readTemperature() - 3; // bme Temperatur auslesen
|
||||
// hum = bme.readHumidity();
|
||||
pressure = bme.readPressure()/100 + pressure_offset;
|
||||
#endif
|
||||
|
||||
#ifdef TX_RX_LNA
|
||||
digitalWrite(TXPIN, LOW);
|
||||
digitalWrite(RXPIN, HIGH);
|
||||
#endif
|
||||
#endif
|
||||
digitalWrite(TXLED, LOW);
|
||||
|
||||
// Hold the OLED ON at first boot
|
||||
|
@ -1188,6 +1262,34 @@ void loop() {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (hum_temp)
|
||||
{
|
||||
++hum_temp_ctr;
|
||||
if (hum_temp_ctr>hum_temp_ctr_max)
|
||||
{
|
||||
hum_temp_ctr = 0;
|
||||
hum_temp=false;
|
||||
}
|
||||
#ifdef USE_BME280
|
||||
//bme.takeForcedMeasurement();
|
||||
temp = bme.readTemperature() - 3; // bme Temperatur auslesen
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
++hum_temp_ctr;
|
||||
if (hum_temp_ctr>hum_temp_ctr_max)
|
||||
{
|
||||
hum_temp_ctr = 0;
|
||||
hum_temp=true;
|
||||
}
|
||||
#ifdef USE_BME280
|
||||
//bme.takeForcedMeasurement();
|
||||
//hum = bme.readHumidity();
|
||||
pressure = bme.readPressure()/100 + pressure_offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rf95.waitAvailableTimeout(100)) {
|
||||
#ifdef T_BEAM_V1_0
|
||||
#ifdef ENABLE_LED_SIGNALING
|
||||
|
@ -1329,3 +1431,15 @@ void loop() {
|
|||
#endif
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
int calc_pressure_offset(int height) {
|
||||
//
|
||||
// A very simple method to calculate the offset for correcting the measured air pressure
|
||||
// to the pressure at mean sea level (MSL). It is simplificated to "For each 8m change in height
|
||||
// the pressure is changing by 1hPa."
|
||||
// The exact method is described at
|
||||
// https://de.wikipedia.org/wiki/Barometrische_H%C3%B6henformel#Internationale_H%C3%B6henformel
|
||||
//
|
||||
int offset = round(height / 8);
|
||||
return(offset);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
FILENAME_BUILDNO = '.pio/versioning'
|
||||
FILENAME_VERSION_H = 'include/version.h'
|
||||
version = 'v0.3.'
|
||||
version = 'v0.4.4.'
|
||||
|
||||
import datetime
|
||||
from subprocess import *
|
||||
|
|
Loading…
Reference in New Issue