May-10-2022, 02:28 AM
Greeting all. First post here and a bit of a newbie to coding.
I have built a simple weather station. It samples a rain detector sensor once every 10 seconds in a try: loop. I am running this on a Raspberry Pi 4/8Gb running Buster which uses Python 3.7.2. I wish to output CSV data to a local file each time it rains or does not rain. I do not want o output data every 10 seconds. I want a new data point only on state change i.e. only when it starts raining or has stopped.
I am sampling every 10 seconds because I am sampling other sensors too but this one is giving my embryonic programming skills trouble.
If anyone can give me a code fragment that solves this problem I would be most grateful.
Thanks in advance
Pete
I have built a simple weather station. It samples a rain detector sensor once every 10 seconds in a try: loop. I am running this on a Raspberry Pi 4/8Gb running Buster which uses Python 3.7.2. I wish to output CSV data to a local file each time it rains or does not rain. I do not want o output data every 10 seconds. I want a new data point only on state change i.e. only when it starts raining or has stopped.
I am sampling every 10 seconds because I am sampling other sensors too but this one is giving my embryonic programming skills trouble.
If anyone can give me a code fragment that solves this problem I would be most grateful.
Thanks in advance
Pete