Select Page

In this post we include the Python code that triggers the motor to turn on when the rain sensor detects rain.

Raspberry Pi Rain Sensor & Motor

The motor will open the top of the tub so rain can be captured in the tub. The code also detects when the rain sensor is dry and will trigger the motor to spin the opposite way to close the top of the tub. This assures the water does not get polluted with outside elements when it is not raining. Download Rain Sensor Code

Note: this is the main script you want to call to run the rain sensor code. This script also imports motor_function.py which controls the motor so you will need to download both files for the rain sensor to work.

For those reading this who want to make their own Christmas Tree Circuit, following is where you can get the supplies