RTC was giving me errors and somehow even though I got it right the first time, I'm having new issues around it, so I decided to scrap this idea. My intent for capturing time was to know what time of day people were voting, but I figured that if neither RTC nor my MQTT connection are reliable, then it becomes a moot effort.
Something else that was on my dashboard wishlist was a running count of votes. I was able to add that in pretty easily in my code by just adding a count variable and setting it to +1 every time the trigger goes off, and then adding it to my mqtt message
c++; //format the message for JSON String message = "PEOPLE VOTED YES!"; //start a new MQTT message on the topic: mqttClient.beginMessage(topic); //start a message mqttClient.print(c); mqttClient.print(" "); mqttClient.print(message); //add the value: mqttClient.endMessage(); //send the message:
It worked pretty well, and I installed this on both my counters. They were both struggling to connect to the broker, then when I was about to give up on Shiftr, they both connected.
They maintained their connection for a minute, then disconnected. Boo!
As an exercise, I'm going to try this on Mosquitto...
and it's working quite well!!
Update: This worked for about 10 minutes, then it disconnected and failed to reconnect.