mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
35 lines
740 B
C++
35 lines
740 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "Class/LineParsing.h"
|
|
#include "Global.h"
|
|
|
|
class SensorAnalog : public LineParsing {
|
|
public:
|
|
SensorAnalog() : LineParsing(){};
|
|
|
|
void SensorAnalogInit() {
|
|
//if (_pin != "") {
|
|
// pinMode(_pin.toInt(), INPUT);
|
|
//}
|
|
}
|
|
|
|
int SensorAnalogRead(String key, String pin) {
|
|
int pinInt = pin.toInt();
|
|
int value;
|
|
#ifdef ESP32
|
|
value = analogRead(pinInt);
|
|
#endif
|
|
#ifdef ESP8266
|
|
pinInt = pinInt;
|
|
value = analogRead(A0);
|
|
#endif
|
|
|
|
eventGen(key, "");
|
|
jsonWriteInt(configLiveJson, key, value);
|
|
MqttClient::publishStatus(key, String(value));
|
|
return value;
|
|
}
|
|
};
|
|
extern SensorAnalog* mySensorAnalog; |