1
This commit is contained in:
@@ -61,13 +61,15 @@ void FanStateService::save() {
|
|||||||
void FanStateService::compute() {
|
void FanStateService::compute() {
|
||||||
unsigned long period = millis() - this->lastpoll;
|
unsigned long period = millis() - this->lastpoll;
|
||||||
this->sensor_intake.requestTemperatures();
|
this->sensor_intake.requestTemperatures();
|
||||||
this->Tin = this->sensor_intake.getTempCByIndex(0);
|
_state.Tin = this->sensor_intake.getTempCByIndex(0);
|
||||||
|
|
||||||
this->Tout = this->sensor_intake.getTempCByIndex(1);
|
_state.Tout = this->sensor_intake.getTempCByIndex(1);
|
||||||
this->RPM = 60000/period*this->ROT/2; // Hall sensor = 2 tick per rotation
|
_state.RPM = 60000/period*this->ROT/2; // Hall sensor = 2 tick per rotation
|
||||||
Serial.print("Intake: " + (String) this->Tin + " - " + (String) this->Tout + " [ "+ (String) this->RPM + " RPM ]\n");
|
Serial.print("Intake: " + (String) _state.Tin + " - " + (String) _state.Tout + " [ "+ (String) _state.RPM + " RPM ]\n");
|
||||||
this->ROT=0;
|
this->ROT=0;
|
||||||
|
|
||||||
this->_mqttPubSub.setPubTopic("testmqtt1/state");
|
this->_mqttPubSub.setPubTopic("testmqtt1/state");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,10 @@ class FanState {
|
|||||||
int thresLow;
|
int thresLow;
|
||||||
int thresHigh;
|
int thresHigh;
|
||||||
|
|
||||||
|
float Tin;
|
||||||
|
float Tout;
|
||||||
|
float RPM;
|
||||||
|
|
||||||
int OneWireGPIO;
|
int OneWireGPIO;
|
||||||
float sensorInTemp;
|
float sensorInTemp;
|
||||||
float sensorOutTemp;
|
float sensorOutTemp;
|
||||||
@@ -103,9 +107,9 @@ class FanState {
|
|||||||
|
|
||||||
static void haRead(FanState& settings, JsonObject& root) {
|
static void haRead(FanState& settings, JsonObject& root) {
|
||||||
root["state"] = settings.fanStatus ? ON_STATE : OFF_STATE;
|
root["state"] = settings.fanStatus ? ON_STATE : OFF_STATE;
|
||||||
root["Tinput"] = settings.sensorInTemp;
|
root["Tinput"] = settings.Tin;
|
||||||
root["Toutput"] = settings.sensorOutTemp;
|
root["Toutput"] = settings.Tout;
|
||||||
root["RPM"] = settings.fanSpeed;
|
root["RPM"] = settings.RPM;
|
||||||
String s = root["state"];
|
String s = root["state"];
|
||||||
Serial.println(" ** Fan haRead [" + s + "]");
|
Serial.println(" ** Fan haRead [" + s + "]");
|
||||||
}
|
}
|
||||||
@@ -133,13 +137,10 @@ class FanState {
|
|||||||
class FanStateService : public StatefulService<FanState> {
|
class FanStateService : public StatefulService<FanState> {
|
||||||
public:
|
public:
|
||||||
unsigned long lastpoll;
|
unsigned long lastpoll;
|
||||||
float Tin;
|
|
||||||
float Tout;
|
|
||||||
OneWire oneWire1;
|
OneWire oneWire1;
|
||||||
DallasTemperature sensor_intake;
|
DallasTemperature sensor_intake;
|
||||||
float RPM;
|
|
||||||
unsigned int ROT;
|
|
||||||
|
|
||||||
|
unsigned int ROT;
|
||||||
|
|
||||||
FanStateService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager, AsyncMqttClient* mqttClient, FanMqttSettingsService* fanMQTTSettingsService);
|
FanStateService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager, AsyncMqttClient* mqttClient, FanMqttSettingsService* fanMQTTSettingsService);
|
||||||
void begin();
|
void begin();
|
||||||
|
|||||||
Reference in New Issue
Block a user