Hi,
I am a newbie to microcontrollers, so apologies if this is a stupid question. I have tried to search for this issue, but I am not really sure what search terms I should use. I hope this is in the right section, but ask the mods to move it, or point me at the correct one, if necessary.
I have an Arduino Uno R4 WiFi, counting the number of trigger inputs on a pin. This count is then uploaded to server using an HTTP request (local network) every minute. Once the request is verified, the count on the Arduino is lowered by the amount uploaded (this allows for a missed upload, as the amount at the next upload will include the current and previous count).
This works fine. I can record the trigger counts and query the server for an almost live count (it should be a maximum of 1 minute behind and will also tell me the timestamp of the last count update).
However, the problem I have is that the count drifts low over time. I THINK this is because the triggers are not being counted while the HTTP request is being done, as the code is only doing one thing at a time. The request takes only a very short amount of time, but at times there can be 5 or 6 triggers per second, so it can easily miss a couple at each upload.
My first question is – does that sound like it could be the cause?
If it is, my second question is – is it possible to make the count continue while uploading the result (HTTP request or some other method) at the same time?
Thanks for taking the time to read, and any help you may be able to give.