Skip to content

Commit

Permalink
Add features, fix typos and filter outputs
Browse files Browse the repository at this point in the history
Fixed:
- Typo of void brodcastPump changed to void broadcastPump

- Added filtering to the temperatures being broadcasted, so that no changes within 3, under 15, above 115 for the HX and 250 degrees for the steamboiler will be reported. This was done to fix the data going to MQTT as spikes of 0 and up to 500 degrees would appear and ruin the graphs and data.

Added:
- Even more MQTT publishing.
   - Publish Machine heating state
   - Publish steam boost heating
- Dynamic authentication settings for connecting to the MQTT broker
  • Loading branch information
rallegade committed Jan 14, 2022
1 parent 4cccda6 commit 53a3a60
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
2 changes: 2 additions & 0 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ PubSubClient client(espClient);
const char* SSID = "";
const char* PSK = "";
const char* MQTT_BROKER = "";
const char* MQTT_USER = "";
const char* MQTT_PASSWORD = "";

// State
int timerCount = 0;
Expand Down
51 changes: 43 additions & 8 deletions main/wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ int lastHxTemperature = NULL;
int lastSteamTemperature = NULL;
long lastTimerStartMillis = 0;
bool lastTimerStarted = false;
bool lastMachineHeating = false;
bool lastMachineHeatingBoost = false;

void setupWifi() {
WiFi.begin(SSID, PSK);
Expand All @@ -15,9 +17,14 @@ void setupWifi() {
void updateWifi() {
if (!client.connected()) {
while (!client.connected()) {
client.connect("marax");

delay(100);
if ( MQTT_USER != "" && MQTT_PASSWORD != "" ) {
client.connect("marax", MQTT_USER, MQTT_PASSWORD);
delay(100);
}
else {
client.connect("marax");
delay(100);
}
}
}

Expand All @@ -30,12 +37,14 @@ void updateWifi() {

if (lastHxTemperature != hxTemperature) {
lastHxTemperature = hxTemperature;
broadcastHxTemperature();
if (hxTemperature > 15 && hxTemperature < 115 && abs(hxTemperature - lastHxTemperature) < 3) {
broadcastHxTemperature();}
}

if (lastSteamTemperature != steamTemperature) {
lastSteamTemperature = steamTemperature;
broadcastSteamTemperature();
if (steamTemperature > 15 && steamTemperature < 250 && abs(steamTemperature - lastSteamTemperature) < 3) {
broadcastSteamTemperature();}
}

if (lastTimerStartMillis != timerStartMillis && ((millis() - timerStartMillis ) / 1000) > 15 && timerStarted == false && timerCount > 0) {
Expand All @@ -45,7 +54,17 @@ void updateWifi() {

if (lastTimerStarted != timerStarted) {
lastTimerStarted = timerStarted;
brodcastPump();
broadcastPump();
}

if (lastMachineHeating != machineHeating) {
lastMachineHeating = machineHeating;
broadcastMachineHeating();
}

if (lastMachineHeatingBoost != machineHeatingBoost) {
lastMachineHeatingBoost = machineHeatingBoost;
broadcastMachineHeatingBoost();
}
}

Expand All @@ -69,10 +88,26 @@ void broadcastShot() {
client.publish("/marax/shot", String(timerCount).c_str());
}

void brodcastPump() {
void broadcastPump() {
if (timerStarted) {
client.publish("/marax/pump", "on");
} else {
client.publish("/marax/power", "off");
client.publish("/marax/pump", "off");
}
}

void broadcastMachineHeating () {
if (machineHeating) {
client.publish("/marax/machineheating", "on");
} else {
client.publish("/marax/machineheating", "off");
}
}

void broadcastMachineHeatingBoost () {
if (machineHeatingBoost) {
client.publish("/marax/machineheatingboost", "on");
} else {
client.publish("/marax/machineheatingboost", "off");
}
}

0 comments on commit 53a3a60

Please sign in to comment.