Rain-Sensing Wiper Controller on Raspberry Pi 5 - Proteus Simulation: the Raspberry Pi 5, the rain gauge, the two relays, the wiper motor and the LCD

Rain-Sensing Wiper Controller on Raspberry Pi 5 - Proteus Simulation

40
700
60
25
60
PCBWay

Hello friends, I hope you all are doing great. Today, I am going to share the Rain-Sensing Wiper Controller on Raspberry Pi 5 - Proteus Simulation, the eighty-eighth project of our IoT Projects series. If you have searched for automatic wipers with a Raspberry Pi, how to drive a car wiper motor with relays, how the park switch of a wiper motor works, or how to read a tipping-bucket rain gauge, here is a complete one in a Proteus simulation. Many cars now switch their wipers on by themselves when it starts to rain, wipe faster in a downpour and stop when the rain does.

This project builds that behaviour around the real parts of a car's wiper system. A Raspberry Pi 5 measures the rain with a tipping-bucket rain gauge, works out the rain rate from the time between the bucket's tips, and picks a mode: intermittent with a pause that shortens as the rain gets heavier, low speed, high speed, or off. It drives a 12 V car wiper motor through the classic two-relay wiper circuit, the same circuit cars have used for decades, and it reads the motor's park switch through a transistor to count the wipes and to notice when the blade is frozen to the glass. In this tutorial, we will go through the circuit, how a tipping-bucket gauge measures rain, why the time between tips is the best rate, the two-relay circuit and its run-on to the park position, the two-speed motor and the level shifting for the Pi. Then we drive through a whole storm in the simulation, take over by hand, and freeze the glass. At the end, you can download the project with the program and every library file.

NOTICE: Our team has put a lot of effort into this project: the circuit, the code and every part in the simulation are our own work, and you get them all free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below. And if our free projects help you, you can buy us a coffee. So, let's get started with the rain-sensing wiper controller on Raspberry Pi 5 in Proteus simulation:

Rain-Sensing Wiper Controller on Raspberry Pi 5 - Proteus Simulation: the Raspberry Pi 5, the rain gauge, the two relays, the wiper motor and the LCD
Figure: The rain-sensing wiper controller in a Proteus simulation.
Rain-Sensing Wiper Controller on Raspberry Pi 5: the working Proteus simulation, an animated view of the project's main steps
Figure: The project working in the Proteus simulation (an animation of the main steps).

What Does This Rain-Sensing Wiper Do?

  • Measures the rain: a tipping-bucket rain gauge, one pulse for every 0.2794 mm, the rate from the time between tips.
  • Chooses the mode: intermittent with a pause of 48 / the rate seconds, LOW from 25 mm/h, HIGH from 60 mm/h, OFF when dry.
  • Wipes at once: one wipe at the first tip of a shower, and a last wipe when the rain stops.
  • Drives a real wiper motor: the classic two-relay circuit with the run-on to the park position.
  • Counts the wipes: the motor's park switch through a BC547 into the Pi, and STALLED when the blade stops.
  • Shows and takes orders: an I2C LCD, and a dashboard with AUTO, OFF, INT, LOW and HIGH.

It is a great project for learning how automotive circuits work, how to interface 12 V signals safely with a Raspberry Pi, and how to turn a slow pulse sensor into a responsive rate. In the simulation, the rain gauge plays a whole 20-minute storm by itself, and the wiper's pop-up shows the arm sweeping, the current and the park switch, so every decision of the program can be checked.

Components Used in the Proteus Simulation

All the parts come from our Proteus libraries, each with its own tutorial. The project zip at the end includes every LIB and DLL file and the Python runtime of the simulated Pi.

The parts of the rain-sensing wiper and their library posts
PartProteus deviceLibrary postConnection
Raspberry Pi 5RASPBERRY PI 5Raspberry Pi 5 Library for ProteusPI1, wiper_rain.py, Ethernet 192.168.1.51:8000
Rain gaugeRAINGAUGETEPRain Gauge Library for ProteusU1, the reed switch on GPIO17 with R1 10k to 3.3 V
2-channel relay moduleRELAY2ADVTEPRelay Module Library for ProteusRLY1, IN1 GPIO22, IN2 GPIO23 (active LOW)
Car wiper motorWIPERMOTORTEPCar Wiper Motor Library for ProteusM1, 53 / 53b / 31b / 53a / 31 on the relays and 12 V
BC547B transistorBC547BTEPSmall Transistors Library for ProteusQ1, the park switch to GPIO27
Resistors 10kRESISTOR4BANDTEPResistor Library for ProteusR1 pull-up, R2 base, R3 collector pull-up
I2C LCD 16x2I2CLCD16X2BLUEADVTEPI2C LCD 16x2 Library for ProteusLCD1 on I2C1, 0x27
Laptop WiFi MonitorLAPTOP WIFI MONITORLaptop WiFi MonitorPC1
Mobile WiFi MonitorMOBILE WIFI MONITORMobile WiFi MonitorMOB1

Proteus Simulation of the Rain-Sensing Wiper: the Circuit

Rain-sensing wiper Proteus simulation circuit: a Raspberry Pi 5, a rain gauge, two relays, a car wiper motor, a BC547 and an LCD
Figure: The complete circuit of the rain-sensing wiper on an A3 Proteus sheet.
The connections of the rain-sensing wiper
NetRaspberry Pi 5Goes to
RAINGPIO17 (pin 11)U1's reed switch to ground, R1 10k to 3.3 V
RLY1 / RLY2GPIO22 / GPIO23 (pins 15 / 16)RLY1 IN1 / IN2: LOW = the relay on
PARKGPIO27 (pin 13)Q1's collector, R3 10k to 3.3 V
53 / 53B-the motor's low and high speed brushes from COM1 and NO2
31B-the park switch: to relay 1's NC and through R2 to Q1's base
L12-relay 2's NC to relay 1's NO: 12 V for LOW unless HIGH is on
+12V-relay 2's COM and the motor's 53a (the park switch's supply)

How the Rain-Sensing Wiper Works

The Tipping-Bucket Rain Gauge

A tipping-bucket gauge funnels the rain into a tiny see-saw with two buckets. When one side holds 0.2794 mm of rain over the funnel's area (0.011 inch, a common size), it tips, empties, and brings the other bucket under the funnel. A magnet on the see-saw passes a reed switch, which closes for a moment: one pulse per tip. The rainfall is simply tips x 0.2794 mm. In the simulation, the reed switch connects GPIO17 to ground and R1 pulls it up to 3.3 V otherwise; the program counts each falling edge, ignoring bounces closer than 20 ms.

The Rain Rate From the Time Between Tips

Counting tips in a fixed window is slow in light rain: at 6 mm/h a tip comes only every 2.8 minutes, so a one-minute window would mostly read zero. The better way is the time between the last two tips: rate (mm/h) = 0.2794 / the hours between them. Worked example: tips 25 seconds apart give 0.2794 / (25 / 3600) = 40.2 mm/h. If a long silence follows, the time since the last tip lowers the rate even before the next tip, and after 5 minutes (or twice the last gap) without a tip the program calls it dry. In the simulation the storm runs 60 times faster than real time (the gauge's SPEED): one simulated second is one minute of rain, and the program converts its times with RAIN_SPEED = 60.

Choosing the Wiper Mode

The program's modes (typical values for learning)
Rain rateModeWhat the wiper does
dryOFFparked
below 25 mm/hINTone wipe, then a pause of 48 / rate seconds (1.5 to 12 s)
25 to 60 mm/hLOWcontinuous, about 40 wipes a minute
60 mm/h and moreHIGHcontinuous, about 58 wipes a minute

Worked example: in 10 mm/h of rain the pause is 48 / 10 = 4.8 s, plus about 1.5 s for the wipe itself, so a wipe every 6.3 s. At the first tip of a shower the program wipes at once, and when the rain stops it gives one last wipe, as drivers expect.

The Two-Speed Wiper Motor

A car wiper motor is a 12 V DC motor with a worm gear (60:1) that cannot be driven backwards, a crank and a rod that sweep the arm 90 degrees. It has a third brush for a second speed: 12 V on terminal 53 runs the low-speed brush, 12 V on 53b the high-speed one, and 31 is ground. On wet glass it makes about 40 wipes a minute on LOW and 58 on HIGH, drawing 2 to 3.5 A.

The Park Switch and the Run-On

If the wipers simply stopped when switched off, the blades would stop wherever they were, in the driver's view. So the motor has a park switch: a cam on the gear wheel connects terminal 31b to ground while the arm is down and to 53a (+12 V) everywhere else. In the classic circuit, relay 1's normally closed contact connects 53 to 31b. When relay 1 drops out mid-sweep, 31b is at 12 V, so the low-speed brush keeps running from the park switch until the arm reaches the bottom; there 31b goes to ground, shorting the brush, and the motor brakes. That is why a single short pulse on relay 1 is enough for one complete wipe in intermittent mode.

The Two-Relay Circuit

Relay 1 chooses between the run-on (NC = 31b) and power (NO = L12). Relay 2 chooses between L12 (NC) and the high-speed brush (NO = 53b), with its COM on +12 V. So relay 1 on alone gives LOW (12 V through relay 2's NC to L12 and on to 53), and both relays on give HIGH (12 V to 53b, while 53 is left open). With relay 1 off, nothing can feed the motor except the park switch, which only finishes the wipe. The relay module's inputs are active LOW: the Pi writes 0 to switch a relay on.

Reading 12 V Safely: the BC547

31b swings between 0 and 12 V, and in a car between 0 and 14.4 V while the alternator charges. A Raspberry Pi's GPIO tolerates 3.3 V at most. A resistor divider would scale 12 V to about 3 V, but 14.4 V would then give 3.6 V, too much, and 3 V sits close to the input's switching threshold. The robust way is a transistor: 31b drives a BC547's base through R2 10k (about 1.1 mA), the emitter goes to ground, and the collector has R3 10k to 3.3 V. With the arm up, 31b is high, the transistor conducts and pulls GPIO27 low; with the arm parked, 31b is at ground, the transistor is off and R3 pulls GPIO27 high. Each return of GPIO27 to high is one wipe completed. If the motor is fed but no wipe completes for 3.5 s, the blade must be stuck: STALLED.

Why a Frozen Blade Is Dangerous

A blade frozen to the glass stalls the motor: about 9 A flows and the windings heat quickly. Look closely at the run-on circuit, though: when the program switches relay 1 off, the park switch still feeds the motor, because the arm is not parked. The Pi can warn, but it cannot cut the current with this circuit; that is why real wiper motors have a thermal cut-out inside, and why cars switch the wipers off when they detect a stall. This project reports STALLED so the driver can clear the glass.

The Python Code Explained

The program is wiper_rain.py, plain Python for the Raspberry Pi with lgpio. The rain constants:

TIP = 0.2794                                               # mm of rain a tip
HIGH_MMH, LOW_MMH = 60.0, 25.0                             # mm/h: HIGH and LOW from these rates, INT below

The rate from the gap between the last two tips, in minutes of rain:

    gap = (tips[-1] - tips[-2]) * RAIN_SPEED / 60.0
    return TIP / max(gap, since) * 60.0                    # (a long silence lowers the rate before it ends)

The relays, active LOW, and the choice of mode:

    lgpio.gpio_write(chip, RLY1, 0 if r1 else 1)           # (active LOW)
            drive = 'HIGH' if rate >= HIGH_MMH else 'LOW' if rate >= LOW_MMH else 'INT' if rate > 0 else 'OFF'
        pause = min(12.0, max(1.5, 48.0 / rate)) if rate > 0 else 6.0

One intermittent wipe: relay 1 for 0.4 s, then the park switch finishes it:

            relays(True, False); pulse_off = t + 0.4       # one wipe: relay 1 for 0.4 s - the arm leaves the park position

Counting the wipes on the park switch, and the stall test:

                s['parked'] = p == 1
        stalled = fed and t - max(last_wipe, fed_since) > STALL_S

The LCD shows the mode (A for AUTO, M for by hand), the drive and the pause or the wipes a minute on the first line, and the rain rate and the wipes on the second. The dashboard's links switch the mode; /data gives everything as JSON.

How to Run the Proteus Simulation

  1. Download the project zip below and install the library files (the steps are under the download button).
  2. Open Pi-5-Rain-Wiper.pdsprj from the Proteus Simulation folder. Keep wiper_rain.py and the DLL files next to it.
  3. Press Play. The storm starts at minute 2 (2 s): watch the wiper follow it on the sheet and the LCD.
  4. Open the Laptop WiFi Monitor (press Go) and switch the modes by hand.
  5. Click M1 for the wiper's pop-up and choose Ice to see the stall warning.

Simulation Results: a Storm in Proteus

We pressed Play and let the rain gauge play its 20-minute storm, then took over from the dashboard and froze the glass. The times below are the program's clock; in the storm one second is one minute of rain. The whole run took 50.8 simulated seconds, and at the end the motor's own counter and the Pi's count agreed: 15 wipes.

The First Tip

At 4.2 s the bucket tipped for the first time. The program wiped at once and chose INT: with only one tip, it assumes light rain (3.4 mm/h), a wipe every 13.5 s. The LCD shows A INT 13.5s and the rate.

Rain-sensing wiper Proteus simulation at the first tip: the LCD shows A INT 13.5s, 3.4 mm/h
Figure: The first tip: a wipe at once, then INT.
Rain gauge pop-up in the rain-sensing wiper simulation: the first tip, the bucket and the reed switch
Figure: The rain gauge: the first tip of the storm.
I2C LCD pop-up in the rain-sensing wiper simulation: A INT 13.5s, 3.4 MM/H, W0
Figure: The LCD: the mode, the pause, the rate and the wipes.

Heavy Rain: LOW

At 6.1 s the rain grew heavy and the next tips came about 26 seconds of rain apart: 38 mm/h, so LOW. Relay 1 switched on (the relay's pop-up: K1 ON, the NO contact carrying 1.39 A), the motor ran continuously at about 44 wipes a minute by the model's own count, and the Pi counted 3 wipes by 9.7 s from the park switch.

Rain-sensing wiper Proteus simulation in heavy rain: the LCD shows A LOW 39.6 mm/h, the wiper sweeping
Figure: Heavy rain: LOW.
Car wiper motor pop-up in the rain-sensing wiper simulation: LOW, 44 wipes a minute, 1.9 A on wet glass
Figure: The wiper motor on LOW.
Relay module pop-up in the rain-sensing wiper simulation: K1 on, the NO contact closed, 1.39 A
Figure: Relay 1 on: LOW.
I2C LCD pop-up in the rain-sensing wiper simulation: A LOW, 39.6 MM/H, W2
Figure: The LCD on LOW.

A Downpour: HIGH

At 11.7 s came the downpour: tips 0.21 s apart in simulation, 78 to 80 mm/h, so HIGH. Both relays switched on: relay 2 now fed the high-speed brush (3.89 A through its NO contact) while relay 1 kept the low brush off its supply. The wiper ran at about 55 wipes a minute by the model and 58 by the Pi's count of the park switch.

Rain-sensing wiper Proteus simulation in a downpour: the LCD shows A HIGH 49/MIN, 79.8 mm/h
Figure: A downpour: HIGH.
Car wiper motor pop-up in the rain-sensing wiper simulation: HIGH, 55 wipes a minute, 3.7 A
Figure: The wiper motor on HIGH.
Relay module pop-up in the rain-sensing wiper simulation: K1 and K2 on, 3.89 A to the high-speed brush
Figure: Both relays on: HIGH.
Rain gauge pop-up in the rain-sensing wiper simulation: 80 mm/h, 0.209 s between tips, 7.82 mm
Figure: The rain gauge in the downpour.

Easing: INT

From 15.5 s the rain eased: LOW again for a moment, then INT at 16.4 s. As the rate fell to 10.1 mm/h the pause grew to 4.8 s, a wipe every 6.3 s, exactly the worked example. Between wipes the wiper's pop-up shows the arm parked, the run-on having taken it home after each 0.4 s pulse on relay 1.

Rain-sensing wiper Proteus simulation as the rain eases: the LCD shows A INT 6.3s, 10.1 mm/h
Figure: Easing: INT, a wipe every 6.3 s.
I2C LCD pop-up in the rain-sensing wiper simulation: A INT 6.3s, 10.1 MM/H, W9
Figure: The LCD in intermittent mode.
Car wiper motor pop-up in the rain-sensing wiper simulation: parked between two intermittent wipes
Figure: Parked in the pause between wipes.

Dry: a Last Wipe

The storm ended at minute 20. After 5 minutes of rain without a tip, at 24.1 s, the program said DRY, gave a last wipe and switched off. The gauge had counted 37 tips, 10.34 mm of rain, and the wiper had made 10 wipes.

Rain-sensing wiper Proteus simulation after the storm: the LCD shows A OFF, 10 wipes
Figure: Dry: OFF after a last wipe.
Car wiper motor pop-up in the rain-sensing wiper simulation: OFF, parked after 10 wipes
Figure: The arm parked after the storm.
Rain gauge pop-up in the rain-sensing wiper simulation: dry, 37 tips, 10.34 mm, the whole storm
Figure: The whole storm on the gauge's graph.
Laptop WiFi Monitor showing the rain-sensing wiper dashboard in the simulation: AUTO OFF, 10 wipes
Figure: The dashboard after the storm.

Ice on the Glass: STALLED

We chose LOW by hand from the dashboard, then picked Ice on the wiper's pop-up: the blade froze to the glass. The motor stalled at 9.0 A with the arm up, so no wipe could finish, and at 38.6 s the program reported STALLED, the LCD in capitals. Choosing Wet glass again freed the blade, and at 42.0 s the program saw a wipe complete: the wiper moves again.

Dashboard in the rain-sensing wiper simulation just after LOW by hand
Figure: LOW by hand.
Rain-sensing wiper Proteus simulation with ice on the glass: the LCD shows STALLED!
Figure: Ice on the glass: STALLED.
Car wiper motor pop-up in the rain-sensing wiper simulation: STALLED, 9.0 A, the arm not moving
Figure: The motor stalled on ice: 9 A.
I2C LCD pop-up in the rain-sensing wiper simulation: STALLED!, W12
Figure: The LCD warns the driver.

Off: the Run-On Parks It

Last, OFF from the dashboard at 43.6 s, with the arm somewhere in its sweep. Both relays dropped out, the park switch fed the low-speed brush until the arm reached the bottom, and the motor braked there: parked, 15 wipes in all.

Dashboard in the rain-sensing wiper simulation after OFF: the arm parked
Figure: OFF by hand.
Rain-sensing wiper Proteus simulation switched off: the LCD shows M OFF, 15 wipes
Figure: Off: the arm parked.
Car wiper motor pop-up in the rain-sensing wiper simulation: OFF, parked, 15 wipes so far
Figure: The run-on took the arm home.
Relay module pop-up in the rain-sensing wiper simulation: both relays off
Figure: Both relays off.
Mobile WiFi Monitor in the rain-sensing wiper simulation: the dashboard with its buttons
Figure: The phone: the same dashboard.
Raspberry Pi 5 terminal in the rain-sensing wiper simulation: every mode change of the storm
Figure: The Pi's terminal: the whole run.
The wiper through the storm
TimeRainModeRelays
4.2 sfirst tip, 3.4 mm/hINT, a wipe every 13.5 spulses on relay 1
6.1 s38 mm/hLOWrelay 1
11.7 s78 mm/hHIGHrelays 1 and 2
16.4 s24.6 to 10.1 mm/hINT, a wipe every 3.5 to 6.3 spulses on relay 1
24.1 sdrya last wipe, OFFnone

The wiper followed the rain from the first tip to the last wipe, every wipe was counted on the park switch, and the frozen blade was caught within 3.5 seconds.

Download the Project Files

Click the button below to download Rain-Sensing-Wiper-Controller-Raspberry-Pi-5-Proteus-Simulation-v1.0.zip (about 14.8 MB, without the source code of the models):

Rain-Sensing Wiper Controller on Raspberry Pi 5 - Proteus Simulation V1.0
  • Proteus Simulation: Pi-5-Rain-Wiper.pdsprj, wiper_rain.py and copies of the models.
  • Python Code: wiper_rain.py, the program.
  • Proteus Library Files: the LIB files of every part.
  • Proteus Model Files: the DLL models and the TEPPi folder (the Python runtime of the simulated Pi).
  • README.txt: the installation steps, the properties, the test results and the links to every library post.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install the Project Files

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy everything from Proteus Model Files, the DLL files and the TEPPi folder, into the MODELS folder.
  4. Start Proteus and open the project from the Proteus Simulation folder.

Changing the Code

wiper_rain.py is plain Python: edit it next to the project and press Play again. The tip size, the HIGH and LOW thresholds, the pause rule, the stall time and RAIN_SPEED are near the top. On a real Raspberry Pi the same file runs with python3-lgpio installed and I2C enabled in raspi-config; set RAIN_SPEED to 1.

Ideas to Extend the Project

  • Use an optical rain sensor on the windscreen, as cars do, and keep the rain gauge for calibration.
  • Add the washer pump: a squirt and three wipes on a button, then one more wipe a few seconds later.
  • Link the wipers to the headlights: lights on whenever the wipers run continuously.
  • Add a third relay to cut the motor completely after a stall, and a current sensor to see the 9 A.
  • Log the rain of each day and show the total on the dashboard.
  • Slow the intermittent rate with the car's speed: less rain hits a slow car.

From Simulation to Real Hardware

  • Fuse the 12 V: a wiper motor stalls at about 9 A; fuse the supply for it, and use relays rated well above that.
  • Flyback: the relay module has its own coil diodes; the motor's brushes and the park switch make sparks, so keep the Pi's wiring apart.
  • Level shifting: keep the BC547 (or an optocoupler) between the car's 12 - 14.4 V and the Pi.
  • Relay inputs: some 5 V relay modules need more than a 3.3 V HIGH to switch off; check yours, or drive them through a transistor.
  • Weather: mount the gauge level, away from spray, and clean its funnel.

Troubleshooting

  • No tips counted: the reed switch between GPIO17 and ground, R1 10k to 3.3 V.
  • The wiper stops mid-sweep when switched off: relay 1's NC must feed 53 from 31b.
  • No wipes counted: 31b through R2 to Q1's base, Q1's collector to GPIO27 with R3 to 3.3 V.
  • The relays do not click: VCC on 5 V, the JD-VCC jumper on; the inputs are active LOW.
  • STALLED with wet glass: the arm never reaches the park point - check the park switch's wiring.

Limitations of the Simulation

  • The motor and the gauge are our libraries' models: the storm is a scene, the glass a choice of wet, dry or ice.
  • The storm runs 60 times faster than real time while the wiper runs in real time; the program converts the rain's times.
  • The network to the laptop and the phone is simulated inside Proteus.
  • Raspberry Pi is a trademark of Raspberry Pi Ltd; this project is not made or endorsed by Raspberry Pi Ltd or by Labcenter.

So, that was all about the Rain-Sensing Wiper Controller on Raspberry Pi 5 - Proteus Simulation. I hope it helps you understand how a tipping-bucket gauge measures rain, why the time between tips is the best rate, how the two-relay circuit and the park switch make a wiper stop in the right place, and how to bring a car's 12 V safely into a Raspberry Pi, all tested in a simulation before you wire up a real motor. More projects with the ESP32 and the Raspberry Pi 5 are coming. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!


Comments

0

Join the conversation