mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
32 lines
867 B
C++
32 lines
867 B
C++
#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; |