2024-07-03-01
This commit is contained in:
parent
d6e10959bc
commit
203c388ae2
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
|
@ -2,6 +2,7 @@
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
|
"ijustdev.gitea-vscode",
|
||||||
"platformio.platformio-ide"
|
"platformio.platformio-ide"
|
||||||
],
|
],
|
||||||
"unwantedRecommendations": [
|
"unwantedRecommendations": [
|
||||||
|
|
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"gitea.instanceURL": "https://hjkgitunix.dedyn.io/hans-jurgen/Wetterstation_Boris.git",
|
||||||
|
"gitea.owner": "hans-jürgen"
|
||||||
|
}
|
|
@ -1,154 +1,154 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Example sketch for the ADS1115_WE library
|
* Example sketch for the ADS1115_WE library
|
||||||
*
|
*
|
||||||
* This sketch shows how to use the ADS1115 in single shot mode.
|
* This sketch shows how to use the ADS1115 in single shot mode.
|
||||||
*
|
*
|
||||||
* Further information can be found on:
|
* Further information can be found on:
|
||||||
* https://wolles-elektronikkiste.de/ads1115 (German)
|
* https://wolles-elektronikkiste.de/ads1115 (German)
|
||||||
* https://wolles-elektronikkiste.de/en/ads1115-a-d-converter-with-amplifier (English)
|
* https://wolles-elektronikkiste.de/en/ads1115-a-d-converter-with-amplifier (English)
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include<ADS1115_WE.h>
|
#include<ADS1115_WE.h>
|
||||||
#include<Wire.h>
|
#include<Wire.h>
|
||||||
#define I2C_ADDRESS 0x48
|
#define I2C_ADDRESS 0x48
|
||||||
|
|
||||||
/* There are several ways to create your ADS1115_WE object:
|
/* There are several ways to create your ADS1115_WE object:
|
||||||
* ADS1115_WE adc = ADS1115_WE(); -> uses Wire / I2C Address = 0x48
|
* ADS1115_WE adc = ADS1115_WE(); -> uses Wire / I2C Address = 0x48
|
||||||
* ADS1115_WE adc = ADS1115_WE(I2C_ADDRESS); -> uses Wire / I2C_ADDRESS
|
* ADS1115_WE adc = ADS1115_WE(I2C_ADDRESS); -> uses Wire / I2C_ADDRESS
|
||||||
* ADS1115_WE adc = ADS1115_WE(&Wire); -> you can pass any TwoWire object / I2C Address = 0x48
|
* ADS1115_WE adc = ADS1115_WE(&Wire); -> you can pass any TwoWire object / I2C Address = 0x48
|
||||||
* ADS1115_WE adc = ADS1115_WE(&Wire, I2C_ADDRESS); -> all together
|
* ADS1115_WE adc = ADS1115_WE(&Wire, I2C_ADDRESS); -> all together
|
||||||
*/
|
*/
|
||||||
ADS1115_WE adc = ADS1115_WE(I2C_ADDRESS);
|
ADS1115_WE adc = ADS1115_WE(I2C_ADDRESS);
|
||||||
bool F_ADS1115;
|
bool F_ADS1115;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char Akku[15] = {0};
|
char Akku[15] = {0};
|
||||||
char Solar[15] = {0};
|
char Solar[15] = {0};
|
||||||
} ADSData;
|
} ADSData;
|
||||||
|
|
||||||
void initADS() {
|
void initADS() {
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
F_ADS1115 = true;
|
F_ADS1115 = true;
|
||||||
if(!adc.init()){
|
if(!adc.init()){
|
||||||
Serial.println("ADS1115 not connected!");
|
Serial.println("ADS1115 not connected!");
|
||||||
SystemStatus = (SystemStatus | ADS1115noReady);
|
SystemStatus = (SystemStatus | ADS1115noReady);
|
||||||
F_ADS1115 = false;
|
F_ADS1115 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the voltage range of the ADC to adjust the gain
|
/* Set the voltage range of the ADC to adjust the gain
|
||||||
* Please note that you must not apply more than VDD + 0.3V to the input pins!
|
* Please note that you must not apply more than VDD + 0.3V to the input pins!
|
||||||
*
|
*
|
||||||
* ADS1115_RANGE_6144 -> +/- 6144 mV
|
* ADS1115_RANGE_6144 -> +/- 6144 mV
|
||||||
* ADS1115_RANGE_4096 -> +/- 4096 mV
|
* ADS1115_RANGE_4096 -> +/- 4096 mV
|
||||||
* ADS1115_RANGE_2048 -> +/- 2048 mV (default)
|
* ADS1115_RANGE_2048 -> +/- 2048 mV (default)
|
||||||
* ADS1115_RANGE_1024 -> +/- 1024 mV
|
* ADS1115_RANGE_1024 -> +/- 1024 mV
|
||||||
* ADS1115_RANGE_0512 -> +/- 512 mV
|
* ADS1115_RANGE_0512 -> +/- 512 mV
|
||||||
* ADS1115_RANGE_0256 -> +/- 256 mV
|
* ADS1115_RANGE_0256 -> +/- 256 mV
|
||||||
*/
|
*/
|
||||||
adc.setVoltageRange_mV(ADS1115_RANGE_4096); //comment line/change parameter to change range
|
adc.setVoltageRange_mV(ADS1115_RANGE_4096); //comment line/change parameter to change range
|
||||||
|
|
||||||
/* Set the inputs to be compared
|
/* Set the inputs to be compared
|
||||||
*
|
*
|
||||||
* ADS1115_COMP_0_1 -> compares 0 with 1 (default)
|
* ADS1115_COMP_0_1 -> compares 0 with 1 (default)
|
||||||
* ADS1115_COMP_0_3 -> compares 0 with 3
|
* ADS1115_COMP_0_3 -> compares 0 with 3
|
||||||
* ADS1115_COMP_1_3 -> compares 1 with 3
|
* ADS1115_COMP_1_3 -> compares 1 with 3
|
||||||
* ADS1115_COMP_2_3 -> compares 2 with 3
|
* ADS1115_COMP_2_3 -> compares 2 with 3
|
||||||
* ADS1115_COMP_0_GND -> compares 0 with GND
|
* ADS1115_COMP_0_GND -> compares 0 with GND
|
||||||
* ADS1115_COMP_1_GND -> compares 1 with GND
|
* ADS1115_COMP_1_GND -> compares 1 with GND
|
||||||
* ADS1115_COMP_2_GND -> compares 2 with GND
|
* ADS1115_COMP_2_GND -> compares 2 with GND
|
||||||
* ADS1115_COMP_3_GND -> compares 3 with GND
|
* ADS1115_COMP_3_GND -> compares 3 with GND
|
||||||
*/
|
*/
|
||||||
//adc.setCompareChannels(ADS1115_COMP_0_GND); //uncomment if you want to change the default
|
//adc.setCompareChannels(ADS1115_COMP_0_GND); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* Set number of conversions after which the alert pin will assert
|
/* Set number of conversions after which the alert pin will assert
|
||||||
* - or you can disable the alert
|
* - or you can disable the alert
|
||||||
*
|
*
|
||||||
* ADS1115_ASSERT_AFTER_1 -> after 1 conversion
|
* ADS1115_ASSERT_AFTER_1 -> after 1 conversion
|
||||||
* ADS1115_ASSERT_AFTER_2 -> after 2 conversions
|
* ADS1115_ASSERT_AFTER_2 -> after 2 conversions
|
||||||
* ADS1115_ASSERT_AFTER_4 -> after 4 conversions
|
* ADS1115_ASSERT_AFTER_4 -> after 4 conversions
|
||||||
* ADS1115_DISABLE_ALERT -> disable comparator / alert pin (default)
|
* ADS1115_DISABLE_ALERT -> disable comparator / alert pin (default)
|
||||||
*/
|
*/
|
||||||
//adc.setAlertPinMode(ADS1115_ASSERT_AFTER_1); //uncomment if you want to change the default
|
//adc.setAlertPinMode(ADS1115_ASSERT_AFTER_1); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* Set the conversion rate in SPS (samples per second)
|
/* Set the conversion rate in SPS (samples per second)
|
||||||
* Options should be self-explaining:
|
* Options should be self-explaining:
|
||||||
*
|
*
|
||||||
* ADS1115_8_SPS
|
* ADS1115_8_SPS
|
||||||
* ADS1115_16_SPS
|
* ADS1115_16_SPS
|
||||||
* ADS1115_32_SPS
|
* ADS1115_32_SPS
|
||||||
* ADS1115_64_SPS
|
* ADS1115_64_SPS
|
||||||
* ADS1115_128_SPS (default)
|
* ADS1115_128_SPS (default)
|
||||||
* ADS1115_250_SPS
|
* ADS1115_250_SPS
|
||||||
* ADS1115_475_SPS
|
* ADS1115_475_SPS
|
||||||
* ADS1115_860_SPS
|
* ADS1115_860_SPS
|
||||||
*/
|
*/
|
||||||
//adc.setConvRate(ADS1115_128_SPS); //uncomment if you want to change the default
|
//adc.setConvRate(ADS1115_128_SPS); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* Set continuous or single shot mode:
|
/* Set continuous or single shot mode:
|
||||||
*
|
*
|
||||||
* ADS1115_CONTINUOUS -> continuous mode
|
* ADS1115_CONTINUOUS -> continuous mode
|
||||||
* ADS1115_SINGLE -> single shot mode (default)
|
* ADS1115_SINGLE -> single shot mode (default)
|
||||||
*/
|
*/
|
||||||
//adc.setMeasureMode(ADS1115_CONTINUOUS); //uncomment if you want to change the default
|
//adc.setMeasureMode(ADS1115_CONTINUOUS); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* Choose maximum limit or maximum and minimum alert limit (window) in volts - alert pin will
|
/* Choose maximum limit or maximum and minimum alert limit (window) in volts - alert pin will
|
||||||
* assert when measured values are beyond the maximum limit or outside the window
|
* assert when measured values are beyond the maximum limit or outside the window
|
||||||
* Upper limit first: setAlertLimit_V(MODE, maximum, minimum)
|
* Upper limit first: setAlertLimit_V(MODE, maximum, minimum)
|
||||||
* In max limit mode the minimum value is the limit where the alert pin assertion will be
|
* In max limit mode the minimum value is the limit where the alert pin assertion will be
|
||||||
* be cleared (if not latched)
|
* be cleared (if not latched)
|
||||||
*
|
*
|
||||||
* ADS1115_MAX_LIMIT
|
* ADS1115_MAX_LIMIT
|
||||||
* ADS1115_WINDOW
|
* ADS1115_WINDOW
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//adc.setAlertModeAndLimit_V(ADS1115_MAX_LIMIT, 3.0, 1.5); //uncomment if you want to change the default
|
//adc.setAlertModeAndLimit_V(ADS1115_MAX_LIMIT, 3.0, 1.5); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* Enable or disable latch. If latch is enabled the alert pin will assert until the
|
/* Enable or disable latch. If latch is enabled the alert pin will assert until the
|
||||||
* conversion register is read (getResult functions). If disabled the alert pin assertion
|
* conversion register is read (getResult functions). If disabled the alert pin assertion
|
||||||
* will be cleared with next value within limits.
|
* will be cleared with next value within limits.
|
||||||
*
|
*
|
||||||
* ADS1115_LATCH_DISABLED (default)
|
* ADS1115_LATCH_DISABLED (default)
|
||||||
* ADS1115_LATCH_ENABLED
|
* ADS1115_LATCH_ENABLED
|
||||||
*/
|
*/
|
||||||
//adc.setAlertLatch(ADS1115_LATCH_ENABLED); //uncomment if you want to change the default
|
//adc.setAlertLatch(ADS1115_LATCH_ENABLED); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* Sets the alert pin polarity if active:
|
/* Sets the alert pin polarity if active:
|
||||||
*
|
*
|
||||||
* ADS1115_ACT_LOW -> active low (default)
|
* ADS1115_ACT_LOW -> active low (default)
|
||||||
* ADS1115_ACT_HIGH -> active high
|
* ADS1115_ACT_HIGH -> active high
|
||||||
*/
|
*/
|
||||||
//adc.setAlertPol(ADS1115_ACT_LOW); //uncomment if you want to change the default
|
//adc.setAlertPol(ADS1115_ACT_LOW); //uncomment if you want to change the default
|
||||||
|
|
||||||
/* With this function the alert pin will assert, when a conversion is ready.
|
/* With this function the alert pin will assert, when a conversion is ready.
|
||||||
* In order to deactivate, use the setAlertLimit_V function
|
* In order to deactivate, use the setAlertLimit_V function
|
||||||
*/
|
*/
|
||||||
//adc.setAlertPinToConversionReady(); //uncomment if you want to change the default
|
//adc.setAlertPinToConversionReady(); //uncomment if you want to change the default
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float readChannel(ADS1115_MUX channel) {
|
float readChannel(ADS1115_MUX channel) {
|
||||||
float voltage = 0.0;
|
float voltage = 0.0;
|
||||||
adc.setCompareChannels(channel);
|
adc.setCompareChannels(channel);
|
||||||
adc.startSingleMeasurement();
|
adc.startSingleMeasurement();
|
||||||
while(adc.isBusy()){}
|
while(adc.isBusy()){}
|
||||||
voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
|
voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessungADS() {
|
void MessungADS() {
|
||||||
float voltage = 0.0;
|
float voltage = 0.0;
|
||||||
|
|
||||||
voltage = readChannel(ADS1115_COMP_0_GND);
|
voltage = readChannel(ADS1115_COMP_0_GND);
|
||||||
dtostrf(voltage,8,2,ADSData.Akku);
|
dtostrf(voltage,8,2,ADSData.Akku);
|
||||||
Serial.print("Akku:\t\t\t");
|
Serial.print("Akku:\t\t\t");
|
||||||
Serial.print(ADSData.Akku);
|
Serial.print(ADSData.Akku);
|
||||||
Serial.println(" V");
|
Serial.println(" V");
|
||||||
|
|
||||||
voltage = readChannel(ADS1115_COMP_1_GND);
|
voltage = readChannel(ADS1115_COMP_1_GND);
|
||||||
dtostrf(voltage,8,2,ADSData.Solar);
|
dtostrf(voltage,8,2,ADSData.Solar);
|
||||||
Serial.print("Solar:\t\t\t");
|
Serial.print("Solar:\t\t\t");
|
||||||
Serial.print(ADSData.Solar);
|
Serial.print(ADSData.Solar);
|
||||||
Serial.println(" V");
|
Serial.println(" V");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
87
include/mess_BME280.h
Normal file
87
include/mess_BME280.h
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#include "Wire.h"
|
||||||
|
|
||||||
|
#define Anzahl_Sensoren_BME280 1 // Mögliche Werte: '0','1','2'
|
||||||
|
#define Korrektur_Luftdruck 0.0 // Korrekturwert um Abweichungen zu offiziellen Wetterstationen auszugleichen
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
// Konfiguration BME280 - Temperatur und Luftfeuchte
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
#include "Adafruit_Sensor.h"
|
||||||
|
#include "Adafruit_BME280.h"
|
||||||
|
uint8_t BME280_adresse[2] = {0x76, 0x77};
|
||||||
|
#define SEALEVELPRESSURE_HPA (1013.25f)
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
const float No_Val = 999.99;
|
||||||
|
float Temp[2] = {No_Val, No_Val};
|
||||||
|
float Feuchte[2] = {No_Val, No_Val};
|
||||||
|
float L_Druck[2] = {No_Val, No_Val};
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char temperature[15] = {0};
|
||||||
|
char pressure[15] = {0};
|
||||||
|
char approx_altitud[15] = {0};
|
||||||
|
char humity[15] = {0};
|
||||||
|
} BME280Data;
|
||||||
|
|
||||||
|
void Sensor_BME280() {
|
||||||
|
if (Anzahl_Sensoren_BME280 > 0) {
|
||||||
|
float Temperatur_BME;
|
||||||
|
float Luftfeuchte_BME;
|
||||||
|
float Luftdruck_BME;
|
||||||
|
boolean check;
|
||||||
|
|
||||||
|
Adafruit_BME280 my_bme;
|
||||||
|
|
||||||
|
for (byte i = 0; i < Anzahl_Sensoren_BME280; i++) {
|
||||||
|
check = my_bme.begin(BME280_adresse[i]); // I2C Adresse
|
||||||
|
delay (100); // time to get system ready
|
||||||
|
if (check) { // if bme ok
|
||||||
|
Temperatur_BME = my_bme.readTemperature();
|
||||||
|
Luftfeuchte_BME = my_bme.readHumidity();
|
||||||
|
Luftdruck_BME = my_bme.readPressure();
|
||||||
|
Serial.print("Temperature (BME280):\t\t");
|
||||||
|
Serial.print(Temperatur_BME);
|
||||||
|
Serial.println(" °C");
|
||||||
|
Serial.print("Luftfeuchtigkeit (BME280):\t");
|
||||||
|
Serial.print(Luftfeuchte_BME);
|
||||||
|
Serial.println(" %");
|
||||||
|
Serial.print("Luftdruck (BME280):\t\t");
|
||||||
|
Serial.print(Luftdruck_BME/100);
|
||||||
|
Serial.println(" hPa");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Temperatur_BME = No_Val;
|
||||||
|
Luftfeuchte_BME = No_Val;
|
||||||
|
Luftdruck_BME = No_Val;
|
||||||
|
}
|
||||||
|
if (i == 0) { // erster BME
|
||||||
|
Temp[0] = Temperatur_BME; // Hier kann die Zuordnung der Sensoren geändert werden
|
||||||
|
Feuchte[0] = Luftfeuchte_BME; // Hier kann die Zuordnung der Sensoren geändert werden
|
||||||
|
L_Druck[0] = Luftdruck_BME/100;
|
||||||
|
}
|
||||||
|
if (i == 1) { // zweiter BME
|
||||||
|
Temp[1] = Temperatur_BME; // Hier kann die Zuordnung der Sensoren geändert werden
|
||||||
|
Feuchte[1] = Luftfeuchte_BME; // Hier kann die Zuordnung der Sensoren geändert werden
|
||||||
|
L_Druck[1] = Luftdruck_BME/100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void M2M_BME280(String deviceId = "4711") {
|
||||||
|
char topic[100];
|
||||||
|
dtostrf(Temp[0],7,1,BME280Data.temperature);
|
||||||
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/temperature_BME_280" );
|
||||||
|
client.publish(topic, BME280Data.temperature, true);
|
||||||
|
|
||||||
|
dtostrf(Feuchte[0],7,1,BME280Data.humity);
|
||||||
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/humity_BME280" );
|
||||||
|
client.publish(topic, BME280Data.humity, true);
|
||||||
|
|
||||||
|
dtostrf(L_Druck[0],7,1,BME280Data.pressure);
|
||||||
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/pressure" );
|
||||||
|
client.publish(topic, BME280Data.pressure, true);
|
||||||
|
}
|
|
@ -1,80 +1,80 @@
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
#include <Adafruit_BMP280.h>
|
#include <Adafruit_BMP280.h>
|
||||||
|
|
||||||
|
|
||||||
#define SEALEVELPRESSURE_HPA (1013.25) // 1013.25
|
#define SEALEVELPRESSURE_HPA (1013.25) // 1013.25
|
||||||
// Richen 219 m über NN
|
// Richen 219 m über NN
|
||||||
// Eppingem 195 m über NN
|
// Eppingem 195 m über NN
|
||||||
|
|
||||||
Adafruit_BMP280 bmp; // I2C
|
Adafruit_BMP280 bmp; // I2C
|
||||||
float K_BMP280 = -0.0;
|
float K_BMP280 = -0.0;
|
||||||
|
|
||||||
bool F_BMP280;
|
bool F_BMP280;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char temperature[15] = {0};
|
char temperature[15] = {0};
|
||||||
char pressure[15] = {0};
|
char pressure[15] = {0};
|
||||||
char approx_altitud[15] = {0};
|
char approx_altitud[15] = {0};
|
||||||
char humity[15] = {0};
|
char humity[15] = {0};
|
||||||
} BMP280Data;
|
} BMP280Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Init_BMP280(){
|
void Init_BMP280(){
|
||||||
bool status = bmp.begin();
|
bool status = bmp.begin();
|
||||||
F_BMP280 = true;
|
F_BMP280 = true;
|
||||||
if (!status) {
|
if (!status) {
|
||||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||||
F_BMP280 = false;
|
F_BMP280 = false;
|
||||||
SystemStatus = SystemStatus | BMP280noReady;
|
SystemStatus = SystemStatus | BMP280noReady;
|
||||||
} else{
|
} else{
|
||||||
/* Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
|
Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
|
||||||
delay(5000); */
|
delay(5000);
|
||||||
/* Default settings from datasheet. */
|
/* Default settings from datasheet. */
|
||||||
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
|
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
|
||||||
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
|
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
|
||||||
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
|
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
|
||||||
Adafruit_BMP280::FILTER_X16, /* Filtering. */
|
Adafruit_BMP280::FILTER_X16, /* Filtering. */
|
||||||
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
|
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
|
||||||
|
|
||||||
//bmp_temp->printSensorDetails();
|
//bmp_temp->printSensorDetails();
|
||||||
Serial.println("BMP280 gefunden");
|
Serial.println("BMP280 gefunden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_BMP_280() {
|
void read_BMP_280() {
|
||||||
|
|
||||||
|
|
||||||
Serial.print("Temperature (BMP280):\t");
|
Serial.print("Temperature (BMP280):\t");
|
||||||
float t = bmp.readTemperature();
|
float t = bmp.readTemperature();
|
||||||
t = t + K_BMP280;
|
t = t + K_BMP280;
|
||||||
dtostrf(t,7,1,BMP280Data.temperature);
|
dtostrf(t,7,1,BMP280Data.temperature);
|
||||||
Serial.print(BMP280Data.temperature);
|
Serial.print(BMP280Data.temperature);
|
||||||
Serial.println(" °C");
|
Serial.println(" °C");
|
||||||
|
|
||||||
Serial.print("Pressure:\t\t");
|
Serial.print("Pressure:\t\t");
|
||||||
float p = bmp.readPressure() / 100.0F;
|
float p = bmp.readPressure() / 100.0F;
|
||||||
p = p + 13;
|
p = p + KorrekturLuftdruck;
|
||||||
dtostrf(p,7,1,BMP280Data.pressure);
|
dtostrf(p,7,1,BMP280Data.pressure);
|
||||||
Serial.print(BMP280Data.pressure);
|
Serial.print(BMP280Data.pressure);
|
||||||
Serial.println(" hPa");
|
Serial.println(" hPa");
|
||||||
|
|
||||||
Serial.print("Approx. Altitude:\t");
|
Serial.print("Approx. Altitude:\t");
|
||||||
float a = bmp.readAltitude(SEALEVELPRESSURE_HPA);
|
float a = bmp.readAltitude(SEALEVELPRESSURE_HPA);
|
||||||
dtostrf(a,7,1,BMP280Data.approx_altitud);
|
dtostrf(a,7,1,BMP280Data.approx_altitud);
|
||||||
Serial.print(BMP280Data.approx_altitud);
|
Serial.print(BMP280Data.approx_altitud);
|
||||||
Serial.println(" m über NN");
|
Serial.println(" m über NN");
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
void M2M_BMP280(String deviceId = "4711") {
|
void M2M_BMP280(String deviceId = "4711") {
|
||||||
char topic[100];
|
char topic[100];
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/temperature_BMP_280" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/temperature_BMP_280" );
|
||||||
client.publish(topic, BMP280Data.temperature, true);
|
client.publish(topic, BMP280Data.temperature, true);
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/pressure" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/pressure" );
|
||||||
client.publish(topic, BMP280Data.pressure, true);
|
client.publish(topic, BMP280Data.pressure, true);
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/approx_altitude" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/approx_altitude" );
|
||||||
client.publish(topic, BMP280Data.approx_altitud);
|
client.publish(topic, BMP280Data.approx_altitud);
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
const float MinimalSpannung = 2.85;
|
const float MinimalSpannung = 2.85;
|
||||||
float korectur = 0.0009350;
|
float korectur = 0.001015;
|
||||||
char floatString[15] = {0};
|
char floatString[15] = {0};
|
||||||
float AKKU;
|
float AKKU;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ float getBattery()
|
||||||
return 3.05;
|
return 3.05;
|
||||||
#endif
|
#endif
|
||||||
int Vcc = analogRead(A0);
|
int Vcc = analogRead(A0);
|
||||||
Vcc = Vcc * ((100+220+680)/100);
|
Vcc = Vcc * ((100+220+220)/100);
|
||||||
float VCC = Vcc * korectur ;
|
float VCC = Vcc * korectur ;
|
||||||
Serial.printf("Rohdaten: %d, ", Vcc);
|
Serial.printf("Rohdaten: %d, ", Vcc);
|
||||||
dtostrf(VCC,8,2,floatString);
|
dtostrf(VCC,8,2,floatString);
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
const float MinimalSpannung = 2.85;
|
const float MinimalSpannung = 2.85;
|
||||||
float koa = 0.984326019;
|
float koa = 0.984326019;
|
||||||
char floatString[15] = {0};
|
char floatString[15] = {0};
|
||||||
float AKKU;
|
float AKKU;
|
||||||
|
|
||||||
float getBattery(float kor = 1.000)
|
float getBattery(float kor = 1.000)
|
||||||
{
|
{
|
||||||
#if (NOBATT == 1)
|
#if (NOBATT == 1)
|
||||||
Serial.print("Batterie:\t\t 3.05 V\n");
|
Serial.print("Batterie:\t\t 3.05 V\n");
|
||||||
return 3.05;
|
return 3.05;
|
||||||
#endif
|
#endif
|
||||||
float valA0 = analogRead(A0);
|
float valA0 = analogRead(A0);
|
||||||
valA0 = valA0 * 3.7; // (R1 + r1 + r2) / r2
|
valA0 = valA0 * 3.7; // (R1 + r1 + r2) / r2
|
||||||
// r1 und r2 Spannungsteiler
|
// r1 und r2 Spannungsteiler
|
||||||
// r1 = 270k, r2 = 100k
|
// r1 = 270k, r2 = 100k
|
||||||
// Spannungsbereich = 5.2 Volt
|
// Spannungsbereich = 5.2 Volt
|
||||||
valA0= valA0 / 1024;
|
valA0= valA0 / 1024;
|
||||||
valA0 = valA0 * kor;
|
valA0 = valA0 * kor;
|
||||||
dtostrf(valA0,7,2,floatString);
|
dtostrf(valA0,7,2,floatString);
|
||||||
Serial.printf("Batterie:\t\t %s V\n", floatString);
|
Serial.printf("Batterie:\t\t %s V\n", floatString);
|
||||||
return valA0;
|
return valA0;
|
||||||
}
|
}
|
|
@ -1,52 +1,52 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
#include <Adafruit_I2CDevice.h>
|
#include <Adafruit_I2CDevice.h>
|
||||||
#include <Adafruit_HTU21DF.h>
|
#include <Adafruit_HTU21DF.h>
|
||||||
|
|
||||||
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
||||||
|
|
||||||
bool F_HTU_21D;
|
bool F_HTU_21D;
|
||||||
float K_HTU= -0.00;
|
float K_HTU= -0.00;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char temperature[15] = {0};
|
char temperature[15] = {0};
|
||||||
char humity[15] = {0};
|
char humity[15] = {0};
|
||||||
} htuData;
|
} htuData;
|
||||||
|
|
||||||
void init_HTU21(){
|
void init_HTU21(){
|
||||||
F_HTU_21D = false;
|
F_HTU_21D = false;
|
||||||
if (!htu.begin()) {
|
if (!htu.begin()) {
|
||||||
Serial.println("Couldn't find sensor HUT21D!");
|
Serial.println("Couldn't find sensor HUT21D!");
|
||||||
SystemStatus = SystemStatus | HTU21noReady;
|
SystemStatus = SystemStatus | HTU21noReady;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
F_HTU_21D = true;
|
F_HTU_21D = true;
|
||||||
Serial.println("HUT21D gefunden");
|
Serial.println("HUT21D gefunden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_HTU21D() {
|
void read_HTU21D() {
|
||||||
float t = htu.readTemperature();
|
float t = htu.readTemperature();
|
||||||
t = t + K_HTU;
|
t = t + K_HTU;
|
||||||
dtostrf(t,7,1,htuData.temperature);
|
dtostrf(t,7,1,htuData.temperature);
|
||||||
float h = htu.readHumidity();
|
float h = htu.readHumidity();
|
||||||
dtostrf(h,7,1,htuData.humity);
|
dtostrf(h,7,1,htuData.humity);
|
||||||
Serial.print("Temperature (HTU21D):\t");
|
Serial.print("Temperature (HTU21D):\t");
|
||||||
Serial.print(htuData.temperature);
|
Serial.print(htuData.temperature);
|
||||||
Serial.println(" °C");
|
Serial.println(" °C");
|
||||||
Serial.print("Luftfeuchtigkeit:\t");
|
Serial.print("Luftfeuchtigkeit:\t");
|
||||||
Serial.print(htuData.humity);
|
Serial.print(htuData.humity);
|
||||||
Serial.println(" %");
|
Serial.println(" %");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void M2M_HTU21D(String deviceId = "4711") {
|
void M2M_HTU21D(String deviceId = "4711") {
|
||||||
char topic[100];
|
char topic[100];
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/temperature_Htu_21" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/temperature_Htu_21" );
|
||||||
client.publish(topic, htuData.temperature, true);
|
client.publish(topic, htuData.temperature, true);
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/humity" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", deviceId.c_str(), "/telemetry/humity" );
|
||||||
client.publish(topic, htuData.humity, true);
|
client.publish(topic, htuData.humity, true);
|
||||||
/* Serial.printf("HTU21:\t\t %s °C\n", htuData.temperature);
|
/* Serial.printf("HTU21:\t\t %s °C\n", htuData.temperature);
|
||||||
Serial.printf("HTU21:\t\t %s %%\n", htuData.humity); */
|
Serial.printf("HTU21:\t\t %s %%\n", htuData.humity); */
|
||||||
}
|
}
|
|
@ -13,16 +13,18 @@ platform = espressif8266
|
||||||
board = d1
|
board = d1
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
monitor_port = COM6
|
monitor_port = COM5
|
||||||
monitor_speed = 74800
|
monitor_speed = 74800
|
||||||
monitor_filters = time
|
monitor_filters = time
|
||||||
upload_port = COM6
|
upload_port = COM5
|
||||||
lib_deps =
|
lib_deps =
|
||||||
knolleary/PubSubClient @ 2.8
|
knolleary/PubSubClient @ 2.8
|
||||||
adafruit/Adafruit HTU21DF Library @ 1.0.5
|
adafruit/Adafruit HTU21DF Library @ 1.0.5
|
||||||
adafruit/Adafruit BMP280 Library @ 2.6.6
|
|
||||||
wollewald/ADS1115_WE @ 1.4.3
|
wollewald/ADS1115_WE @ 1.4.3
|
||||||
adafruit/Adafruit MCP9808 Library @ 2.0.0
|
adafruit/Adafruit MCP9808 Library @ 2.0.0
|
||||||
|
adafruit/Adafruit BusIO @ 1.16.1
|
||||||
|
adafruit/Adafruit BME280 Library @ 2.2.4
|
||||||
|
adafruit/Adafruit Unified Sensor @ 1.1.14
|
||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
-DTEMPTEST33=1
|
-DTEMPTEST33=1
|
||||||
|
@ -46,6 +48,7 @@ build_flags = ${env.build_flags}
|
||||||
-DTERROR=5
|
-DTERROR=5
|
||||||
-DTLOWBATT=60
|
-DTLOWBATT=60
|
||||||
-DTINTERVAL=1
|
-DTINTERVAL=1
|
||||||
|
-DKorrekturLuftdruck=0.0
|
||||||
|
|
||||||
[env:marcel] ; Produktivsystem:
|
[env:marcel] ; Produktivsystem:
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
|
@ -62,6 +65,7 @@ build_flags = ${env.build_flags}
|
||||||
-DTERROR=20
|
-DTERROR=20
|
||||||
-DTLOWBATT=60
|
-DTLOWBATT=60
|
||||||
-DTINTERVAL=10
|
-DTINTERVAL=10
|
||||||
|
-DKorrekturLuftdruck=0.0
|
||||||
|
|
||||||
[env:boris] ; Produktivsystem:
|
[env:boris] ; Produktivsystem:
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
|
@ -78,6 +82,7 @@ build_flags = ${env.build_flags}
|
||||||
-DTERROR=20
|
-DTERROR=20
|
||||||
-DTLOWBATT=60
|
-DTLOWBATT=60
|
||||||
-DTINTERVAL=5
|
-DTINTERVAL=5
|
||||||
|
-DKorrekturLuftdruck=0.0
|
||||||
|
|
||||||
[env:hjk]
|
[env:hjk]
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
|
@ -93,7 +98,8 @@ build_flags = ${env.build_flags}
|
||||||
-Dmqtt_port=61883
|
-Dmqtt_port=61883
|
||||||
-DTERROR=5
|
-DTERROR=5
|
||||||
-DTLOWBATT=60
|
-DTLOWBATT=60
|
||||||
-DTINTERVAL=5
|
-DTINTERVAL=10
|
||||||
|
-DKorrekturLuftdruck=23.6
|
||||||
|
|
||||||
[env:filamentbox]
|
[env:filamentbox]
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
|
@ -110,4 +116,5 @@ build_flags = ${env.build_flags}
|
||||||
-DTERROR=5
|
-DTERROR=5
|
||||||
-DTLOWBATT=60
|
-DTLOWBATT=60
|
||||||
-DTINTERVAL=15
|
-DTINTERVAL=15
|
||||||
|
-DKorrekturLuftdruck=0.0
|
||||||
|
|
||||||
|
|
28
src/main.cpp
28
src/main.cpp
|
@ -5,7 +5,7 @@
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
|
|
||||||
#define BUILTIN_LED D15
|
// #define BUILTIN_LED D2
|
||||||
#define TRIGGER_PIN D7
|
#define TRIGGER_PIN D7
|
||||||
#define START_STOP_PIN D6
|
#define START_STOP_PIN D6
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ PubSubClient client(espClient);
|
||||||
|
|
||||||
#include<mess_htu21.h>
|
#include<mess_htu21.h>
|
||||||
|
|
||||||
#include <mess_BMP280.h>
|
//#include <mess_BMP280.h>
|
||||||
|
#include <mess_BME280.h>
|
||||||
|
|
||||||
#include <mess_Ub.h>
|
#include <mess_Ub.h>
|
||||||
|
|
||||||
|
@ -72,6 +73,10 @@ long int Feldstaerke;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
startTime = millis();
|
startTime = millis();
|
||||||
|
/* pinMode(BUILTIN_LED, OUTPUT);
|
||||||
|
digitalWrite(BUILTIN_LED, LOW);
|
||||||
|
delay(5000);
|
||||||
|
digitalWrite(BUILTIN_LED, HIGH); */
|
||||||
Serial.begin(74880);
|
Serial.begin(74880);
|
||||||
while ( !Serial ) delay(100); // wait for native usb
|
while ( !Serial ) delay(100); // wait for native usb
|
||||||
WiFi.mode( WIFI_OFF );
|
WiFi.mode( WIFI_OFF );
|
||||||
|
@ -84,10 +89,13 @@ void setup() {
|
||||||
readSystemStatus();
|
readSystemStatus();
|
||||||
Serial.printf("Systemstatus : 0x%02x \n", SystemStatus);
|
Serial.printf("Systemstatus : 0x%02x \n", SystemStatus);
|
||||||
SystemStatus = 0x00;
|
SystemStatus = 0x00;
|
||||||
|
writeSystemStatus();
|
||||||
delay(500);
|
delay(500);
|
||||||
#if (MQTT == 0)
|
#if (MQTT == 0)
|
||||||
init_HTU21();
|
init_HTU21();
|
||||||
Init_BMP280();
|
//Init_BMP280();
|
||||||
|
Sensor_BME280();
|
||||||
|
|
||||||
init_MCP9808();
|
init_MCP9808();
|
||||||
initADS();
|
initADS();
|
||||||
#endif
|
#endif
|
||||||
|
@ -106,9 +114,9 @@ void setup() {
|
||||||
if (F_ADS1115 == true){
|
if (F_ADS1115 == true){
|
||||||
MessungADS();
|
MessungADS();
|
||||||
}
|
}
|
||||||
if (F_BMP280 == true){
|
/* if (F_BMP280 == true){
|
||||||
read_BMP_280();
|
read_BMP_280();
|
||||||
}
|
}*/
|
||||||
if (F_MCP9808 == true){
|
if (F_MCP9808 == true){
|
||||||
valTemp = getTemperature_MCP9808();
|
valTemp = getTemperature_MCP9808();
|
||||||
}
|
}
|
||||||
|
@ -143,7 +151,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (F_HTU_21D) M2M_HTU21D(hostname.c_str());
|
if (F_HTU_21D) M2M_HTU21D(hostname.c_str());
|
||||||
if (F_BMP280) M2M_BMP280(hostname.c_str());
|
M2M_BME280(hostname.c_str());
|
||||||
if (F_MCP9808) M2M_Temperatur_MCP9808(hostname.c_str());
|
if (F_MCP9808) M2M_Temperatur_MCP9808(hostname.c_str());
|
||||||
sprintf(msg,"%ld", Feldstaerke);
|
sprintf(msg,"%ld", Feldstaerke);
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" );
|
||||||
|
@ -153,7 +161,7 @@ void loop() {
|
||||||
client.publish(topic, msg, true);
|
client.publish(topic, msg, true);
|
||||||
client.loop();
|
client.loop();
|
||||||
delay(500);
|
delay(500);
|
||||||
digitalWrite(BUILTIN_LED, HIGH);
|
//digitalWrite(BUILTIN_LED, HIGH);
|
||||||
/* ESP.deepSleep(5e6);
|
/* ESP.deepSleep(5e6);
|
||||||
delay(100); */
|
delay(100); */
|
||||||
endTime = millis();
|
endTime = millis();
|
||||||
|
@ -265,7 +273,7 @@ void callback(char* topic1, byte* payload, unsigned int length)
|
||||||
|
|
||||||
void reconnect() {
|
void reconnect() {
|
||||||
// Loop until we're reconnected
|
// Loop until we're reconnected
|
||||||
sprintf(clientName, "%s%s", "ESP8266Client", sID);
|
sprintf(clientName, "%s%s", "ESP8266Wetter", sID);
|
||||||
while (!client.connected()) {
|
while (!client.connected()) {
|
||||||
Serial.print("Attempting MQTT connection...");
|
Serial.print("Attempting MQTT connection...");
|
||||||
//verifyFingerprint();
|
//verifyFingerprint();
|
||||||
|
@ -273,9 +281,9 @@ void reconnect() {
|
||||||
if (client.connect(clientName)) {
|
if (client.connect(clientName)) {
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
// Once connected, publish an announcement...
|
// Once connected, publish an announcement...
|
||||||
client.publish("outTopic", "hello world");
|
// client.publish("outTopic", "hello world");
|
||||||
// ... and resubscribe
|
// ... and resubscribe
|
||||||
client.subscribe("inTopic");
|
// client.subscribe("inTopic");
|
||||||
} else {
|
} else {
|
||||||
Serial.print("failed, rc=");
|
Serial.print("failed, rc=");
|
||||||
Serial.print(client.state());
|
Serial.print(client.state());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user