Skip to content

Commit d9ca6c4

Browse files
author
Brandon Satrom
committed
clean-up tempo monitoring posts; closes #22
1 parent 8321d99 commit d9ca6c4

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

brew-buddy-firmware/src/brew-buddy-firmware.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,16 @@ void loop()
227227

228228
if (currentMillis - previousPostMillis > postInterval)
229229
{
230-
// Post curent values to the Device Cloud
231-
postTemp(lastTemp);
232-
postFermentationRate();
230+
previousPostMillis = millis();
231+
232+
if (isBrewingMode)
233+
{
234+
postTemp(lastTemp);
235+
}
236+
else if (isFermentationMode)
237+
{
238+
postFermentationRate();
239+
}
233240
}
234241
}
235242
}
@@ -391,13 +398,13 @@ float readTemp()
391398

392399
void postTemp(float temp)
393400
{
394-
String payload = "{ \"a\":" + String(temp, 2) + ", \"b\": \"" + brewId + "\", \"c\": \"" + brewStage + "\" }";
395-
Particle.publish("BrewStageTemp", payload);
401+
String payload = "{ \"temperature\":" + String(temp, 2) + ", \"time\": \"" + millis() + "\" }";
402+
Particle.publish("brewing/temp", payload);
396403
}
397404

398405
void postFermentationRate()
399406
{
400-
String payload = "{ \"current_rate\":" + String(fermentationRate, 2) + "\" }";
407+
String payload = "{ \"current_rate\":" + String(fermentationRate, 2) + ", \"time\": \"" + millis() + "\" }";
401408
Particle.publish("fermentation/rate", payload);
402409
}
403410

brew-buddy-firmware/src/brew-buddy-firmware.ino

+11-5
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,14 @@ void loop()
203203
{
204204
previousPostMillis = millis();
205205

206-
postTemp(lastTemp);
207-
postFermentationRate();
206+
if (isBrewingMode)
207+
{
208+
postTemp(lastTemp);
209+
}
210+
else if (isFermentationMode)
211+
{
212+
postFermentationRate();
213+
}
208214
}
209215
}
210216
}
@@ -366,13 +372,13 @@ float readTemp()
366372

367373
void postTemp(float temp)
368374
{
369-
String payload = "{ \"a\":" + String(temp, 2) + ", \"b\": \"" + brewId + "\", \"c\": \"" + brewStage + "\" }";
370-
Particle.publish("BrewStageTemp", payload);
375+
String payload = "{ \"temperature\":" + String(temp, 2) + ", \"time\": \"" + millis() + "\" }";
376+
Particle.publish("brewing/temp", payload);
371377
}
372378

373379
void postFermentationRate()
374380
{
375-
String payload = "{ \"current_rate\":" + String(fermentationRate, 2) + " }";
381+
String payload = "{ \"current_rate\":" + String(fermentationRate, 2) + ", \"time\": \"" + millis() + "\" }";
376382
Particle.publish("fermentation/rate", payload);
377383
}
378384

0 commit comments

Comments
 (0)