mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
not working version
This commit is contained in:
32
include/items/SensorAnalogClass.h
Normal file
32
include/items/SensorAnalogClass.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "Class/LineParsing.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
#include "Global.h"
|
||||
|
||||
class SensorAnalogClass : public SensorConvertingClass {
|
||||
public:
|
||||
SensorAnalogClass() : SensorConvertingClass(){};
|
||||
|
||||
int SensorAnalogRead(String key, String pin) {
|
||||
|
||||
int pinInt = pin.toInt();
|
||||
int value;
|
||||
|
||||
#ifdef ESP32
|
||||
value = analogRead(pinInt);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
value = analogRead(A0);
|
||||
#endif
|
||||
|
||||
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));
|
||||
return value;
|
||||
}
|
||||
};
|
||||
extern SensorAnalogClass* mySensorAnalog;
|
||||
Reference in New Issue
Block a user