Counting Problems

If you are using SYSTEM_THREAD(ENABLED); do you think you also need to use SYSTEM_MODE(SEMI_AUTOMATIC);?

you could try waitUntil(WiFi.ready); instead of constantly toggling wifi on and off.

https://docs.particle.io/reference/firmware/photon/#system-thread

also another side note, your use of httpClient (its blocking nature) is likely to cause you missed pulses in your state-change-detection method of reading inPin. Since you have blocking code, you may want to think about putting the counting into an interrupt function.

I am troubled with your persistent vars using retained not holding, but noticed this thread earlier, and I have not played with that "EEPROM-like" feature yet.

2 Likes