@@ -27,6 +27,7 @@ void printHeadingTextLine(String text);
27
27
void printSubheadingLine (String text);
28
28
float readTemp ();
29
29
void postTemp (float temp);
30
+ void postFermentationRate ();
30
31
void printReading (float reading);
31
32
void displayStageName (String stagename);
32
33
void displayFermentationHeading ();
@@ -80,6 +81,10 @@ unsigned long startTime = 0;
80
81
unsigned long elapsedTime;
81
82
float previousTemp = 0 ;
82
83
84
+ // Timing variables for posting readings to the cloud
85
+ unsigned long postInterval = 120000 ;
86
+ unsigned long previousPostMillis = 0 ;
87
+
83
88
// Text Size Variables
84
89
const uint8_t headingTextSize = 4 ;
85
90
const uint8_t subheadTextSize = 2 ;
@@ -92,6 +97,7 @@ const uint8_t pixelMultiplier = 7; //Used to clear text portions of the screen
92
97
QueueArray<int > tempGraphArray;
93
98
const uint8_t lowTemp = 70 ;
94
99
const uint8_t highTemp = 220 ;
100
+ float lastTemp = 0.0 ;
95
101
96
102
// Brew Stage Variables
97
103
bool isBrewingMode = false ;
@@ -104,7 +110,7 @@ unsigned long fermentationStartTime = 0;
104
110
105
111
// Variables for fermentation rate
106
112
QueueArray<long > knockArray;
107
- long fermentationRate = 0 ; // knocks per ms
113
+ float fermentationRate = 0 ; // knocks per ms
108
114
unsigned long lastKnock;
109
115
110
116
String brewStage;
@@ -218,6 +224,20 @@ void loop()
218
224
219
225
displayTime (elapsedTime);
220
226
}
227
+
228
+ if (currentMillis - previousPostMillis > postInterval)
229
+ {
230
+ previousPostMillis = millis ();
231
+
232
+ if (isBrewingMode)
233
+ {
234
+ postTemp (lastTemp);
235
+ }
236
+ else if (isFermentationMode)
237
+ {
238
+ postFermentationRate ();
239
+ }
240
+ }
221
241
}
222
242
}
223
243
@@ -365,7 +385,7 @@ float readTemp()
365
385
366
386
if (!isnan (temperature))
367
387
{
368
- postTemp ( temperature) ;
388
+ lastTemp = temperature;
369
389
370
390
return temperature;
371
391
}
@@ -378,8 +398,14 @@ float readTemp()
378
398
379
399
void postTemp (float temp)
380
400
{
381
- String payload = " { \" a\" :" + String (temp, 2 ) + " , \" b\" : \" " + brewId + " \" , \" c\" : \" " + brewStage + " \" }" ;
382
- Particle.publish (" BrewStageTemp" , payload);
401
+ String payload = " { \" temperature\" :" + String (temp, 2 ) + " , \" time\" : \" " + millis () + " \" }" ;
402
+ Particle.publish (" brewing/temp" , payload);
403
+ }
404
+
405
+ void postFermentationRate ()
406
+ {
407
+ String payload = " { \" current_rate\" :" + String (fermentationRate, 2 ) + " , \" time\" : \" " + millis () + " \" }" ;
408
+ Particle.publish (" fermentation/rate" , payload);
383
409
}
384
410
385
411
void printReading (float reading)
0 commit comments