mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
bme 280 support
This commit is contained in:
@@ -76,6 +76,9 @@ class LineParsing {
|
||||
if (arg.indexOf("type[") != -1) {
|
||||
_type = extractInner(arg);
|
||||
}
|
||||
if (arg.indexOf("addr[") != -1) {
|
||||
_addr = extractInner(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +124,10 @@ class LineParsing {
|
||||
String gtype() {
|
||||
return _type;
|
||||
}
|
||||
String gaddr() {
|
||||
return _addr;
|
||||
}
|
||||
|
||||
|
||||
void clear() {
|
||||
_key = "";
|
||||
@@ -136,6 +143,7 @@ class LineParsing {
|
||||
_state = "";
|
||||
_db = "";
|
||||
_type = "";
|
||||
_addr = "";
|
||||
}
|
||||
|
||||
String extractInnerDigit(String str) {
|
||||
|
||||
@@ -30,4 +30,11 @@ extern void dallasReading();
|
||||
extern void dhtTemp();
|
||||
extern void dhtReadingTemp();
|
||||
extern void dhtHum();
|
||||
extern void dhtReadingHum();
|
||||
extern void dhtReadingHum();
|
||||
|
||||
extern void bme280Temp();
|
||||
extern void bme280ReadingTemp();
|
||||
extern void bme280Hum();
|
||||
extern void bme280ReadingHum();
|
||||
extern void bme280Press();
|
||||
extern void bme280ReadingPress();
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
class SensorAnalogClass : public SensorConvertingClass {
|
||||
public:
|
||||
SensorAnalogClass() : SensorConvertingClass(){};
|
||||
|
||||
void SensorAnalogInit() {
|
||||
jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
||||
jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
}
|
||||
|
||||
int SensorAnalogRead(String key, String pin) {
|
||||
|
||||
int pinInt = pin.toInt();
|
||||
int value;
|
||||
|
||||
|
||||
@@ -1,45 +1,53 @@
|
||||
//#pragma once
|
||||
//#include <Arduino.h>
|
||||
//#include "Class/LineParsing.h"
|
||||
//#include "Global.h"
|
||||
//#include "items/SensorConvertingClass.h"
|
||||
//
|
||||
//class SensorBme280Class : public SensorConvertingClass {
|
||||
// public:
|
||||
// SensorBme280Class() : SensorConvertingClass(){};
|
||||
//
|
||||
// void SensorBme280Init() {
|
||||
// oneWire = new OneWire((uint8_t)_pin.toInt());
|
||||
// sensors.setOneWire(oneWire);
|
||||
// sensors.begin();
|
||||
// sensors.setResolution(48);
|
||||
//
|
||||
// sensorReadingMap += _key + ",";
|
||||
// //Bme280EnterCounter++;
|
||||
//
|
||||
// //jsonWriteInt(configOptionJson, _key + "_num", Bme280EnterCounter);
|
||||
// jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
// jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
// }
|
||||
//
|
||||
// void SensorBme280Read(String key) {
|
||||
// float value;
|
||||
// byte num = sensors.getDS18Count();
|
||||
// sensors.requestTemperatures();
|
||||
//
|
||||
// int cnt = jsonReadInt(configOptionJson, key + "_num");
|
||||
//
|
||||
// for (byte i = 0; i < num; i++) {
|
||||
// if (i == cnt) {
|
||||
// value = sensors.getTempCByIndex(i);
|
||||
// //value = this->mapping(key, value);
|
||||
// float valueFl = this->correction(key, value);
|
||||
// eventGen(key, "");
|
||||
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
// MqttClient::publishStatus(key, String(valueFl));
|
||||
// Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//extern SensorBme280Class mySensorBme280;
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
Adafruit_Sensor *bme_temp = bme.getTemperatureSensor();
|
||||
Adafruit_Sensor *bme_pressure = bme.getPressureSensor();
|
||||
Adafruit_Sensor *bme_humidity = bme.getHumiditySensor();
|
||||
|
||||
class SensorBme280Class : public SensorConvertingClass {
|
||||
public:
|
||||
SensorBme280Class() : SensorConvertingClass(){};
|
||||
|
||||
void SensorBme280Init() {
|
||||
bme.begin(hexStringToUint8(_addr));
|
||||
jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
}
|
||||
|
||||
void SensorBme280ReadTmp(String key) {
|
||||
float value;
|
||||
value = bme.readTemperature();
|
||||
float valueFl = this->correction(key, value);
|
||||
eventGen(key, "");
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
MqttClient::publishStatus(key, String(valueFl));
|
||||
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||
}
|
||||
|
||||
void SensorBme280ReadHum(String key) {
|
||||
float value;
|
||||
value = bme.readHumidity();
|
||||
float valueFl = this->correction(key, value);
|
||||
eventGen(key, "");
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
MqttClient::publishStatus(key, String(valueFl));
|
||||
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||
}
|
||||
|
||||
void SensorBme280ReadPress(String key) {
|
||||
float value;
|
||||
value = bme.readPressure();
|
||||
float valueFl = this->correction(key, value);
|
||||
eventGen(key, "");
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
MqttClient::publishStatus(key, String(valueFl));
|
||||
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||
}
|
||||
};
|
||||
extern SensorBme280Class mySensorBme280;
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
DHTesp dht;
|
||||
class SensorDhtClass : public SensorConvertingClass {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user