Tilt sensor stop after few reading

Hi,

I am using grovepi+ to connect the grove tilt sensor to raspberry pi 3 Model B Vl.2.
The grove pi works fine and its Firmware version is 1 3 0.
I also tried the version 1 4 0.
OS version is debian 10 2.

The problem is grove tilt sensor stops reading after few reading (in 1~5 minutes).
I use sample program “grove_tilt_switch.py”.
After stopped, command “Ctrl + C” doesn’t work.

This problem also occurs with infrared distance sensor.
The sample program name is “grove_infrared_distance_interrupt.py”.

Thanks.

@tnagaoka, I can’t really help directly, but I do have a suggestion to make your programs tolerant of sensor communication issues.

It can really help to put a try: except: around your sensor interface code. If a problem occurs, the except clause will be executed and you can work around occasional problems.

Example:

try:
    myReading = mySensor.getReading()
except:
    if debug: 
        print("Exception reading mySensor returning False")
    myReading = False
...

There are more sophisticated ways, as well, that can tell you what the exception was, or perform cleanup, but sometimes this simple structure will keep you going.