The more functions of the car are turned on automatically, the safer and more comfortable it is. The equipment will work faster than a person, and he will not need to be distracted from controlling and monitoring the situation on the road. The sense organs of automation are sensors. One of them appeared in the car relatively recently, it was a rain sensor (RD).
Why do you need a rain sensor in your car?
The first drops of rain may appear suddenly on the windshield, immediately reducing visibility. In this case, the refraction of light in water occurs according to different laws; the picture will be so distorted that you may not notice the dangerous development of the situation. This is especially dangerous at high speed.
The condition of the road surface or the traffic situation may change, and the driver will not have time to react, being busy trying to see through the windshield that has lost clarity, while also trying to quickly activate the windshield wipers. Which also won’t immediately put things in order with visibility, so every fraction of a second is important.
The wipers must be turned on as soon as the first drops fall. To do this, you will need a device that can recognize the appearance of water, and not other interference.
On the subject: What kind of DTVV sensor is this, where is it located and how does it work?
We had to tinker with the development of a reliably triggered sensor. The first copies were expensive and were installed only on the most premium cars and as an option. Now this is a large-scale product and there is nothing special about such equipment, even for a budget car.
Location
For obvious reasons, the sensor is placed on the windshield, which it is designed to protect from water drops. In order not to interfere with the view, it is located in its upper part, in the area where the interior rear-view mirror is located.
For this purpose, there is a special platform, free from tinting, heating and other interference in the work.
Installing a light sensor
The work here is quite simple, you won't need to do anything special. But, keep in mind a few nuances. The first and main thing is the need for vertical installation. Otherwise, the sensor will give false signals much more often. It should be placed within the coverage area of the wipers, this will allow for more precise control. Be sure to check the installation location for chips and cracks. They can, under certain conditions, significantly refract light. To install you will need the following things:
- Sensor;
- Holder;
- Special gel;
- Wires;
- Microprocessor.
You can use the suction cup from the DVR as a holder, but it will have to be modified a little. It is much more efficient to purchase special fasteners, since they are inexpensive. Before installation, a gel is applied to the glass in direct contact with the sensor; it evens out the refraction. The device body is mounted in the holder, the assembly is complete, all that remains is to connect it.
Principle of operation
Any transition between substances in contact forms an optical boundary. All types of electromagnetic radiation are refracted on it, that is, they change the angle of propagation and energy properties. Part of the beam passes through the boundary, while the other is reflected and returned to an optically denser substance.
For example, fiber-optic communication lines operate on this principle, where at a certain angle light cannot escape the glass and spreads over long distances without loss.
The most suitable frequency range turned out to be infrared (IR) radiation. Its spectrum lies below the limit of visible light. Such radiation is felt only as heat, and therefore is considered thermal; the eye does not notice it. However, this is a wave with properties close to light, and therefore works according to optical laws.
Sketch for a project with an alarm system
Below is a test code that activates a sound signal on the above-mentioned digital output 6, with a time delay, in order to eliminate false alarms when water accidentally gets into the sensor. The work is implemented through a variable that is updated every second and acts as a threshold - curCounter. The alarm is activated when the value transmitted from the sensor becomes less than 300. The delay between moisture detection and the sound signal is slightly more than 30 seconds.
#define PIN_RAIN_SENSOR A1 // Analog input for leakage and rain sensor signal #define PIN_ALERT 6 // Digital output for alarm #define MAX_COUNTER 30 // Threshold value for the counter #define ALERT_LEVEL 300 // Threshold value for the counter int curCounter= 0; // Counter for collecting “statistics”, which increases by 1 every second after the sensor is triggered void setup(){ Serial.begin(9600); pinMode(PIN_ALERT, OUTPUT); pinMode(PIN_RAIN_SENSOR, INPUT); // Can be omitted, because this is the default } void loop(){ int sensorValue = analogRead(PIN_RAIN_SENSOR); Serial.println(sensorValue); // Output the value to the port monitor delay(300); // short delay // If enough reasons have accumulated to trigger the alarm if (curCounter >= MAX_COUNTER){ digitalWrite(PIN_ALERT, HIGH); // Alarm triggered curCounter = MAX_COUNTER; // Protection against variable overflow } // Determine the humidity level if (sensorValue < ALERT_LEVEL){ // Once again we made sure that everything is wet, increase the counter curCounter++; }else { // Rain intensity does not exceed the threshold digitalWrite(PIN_ALERT, LOW); // Turn off the alarm curCounter = 0; // Reset the counter } delay(1000); // Delay between measurements }
Device
A DD built according to this principle includes:
- infrared light sources, their role is played by IR LEDs;
- photodetectors configured for the same IR range;
- prismatic light guides that form a directed beam flow;
- a printed circuit board with electronic elements that create and process signals;
- a housing with fittings that ensure fastening to glass and an electrical connector.
With dry glass, the angle of placement of LEDs and photodetectors with optics is selected in such a way that there is complete internal reflection of the rays from the outer surface of the windshield. Just like the fiber optic lines mentioned above. The maximum amount of energy is supplied to the photodiode.
When a drop of water, even of the smallest size, appears in the sensor’s tracking zone, the refractive conditions at the interface between glass and atmosphere change. It is no longer possible to return all the energy of the beam to the glass body; part of it will go into the water. The signal at the receiver output will instantly respond to this and will decrease.
Further evaluation and decision is made by the electronics. The sensor controller will determine if there is enough water to operate the windshield wipers. The algorithm for their operation can be set in different ways. For example, if the glass is heavily soiled and water is poorly removed, the brushes will work longer and more intensely. You can decide to turn on the washer.
The devices are configured to exclude abnormal operations. They should not react to dry glass contamination, although this function can be added as a useful addition, but with a washer.
Thanks to the infrared range, the sensor works equally both day and night, visible light does not affect it in any way. And it’s easy to deal with other interference using modulated radiation.
This is interesting: How to check the speed sensor, 3 simple ways
Considering the intellectual level of a modern car, where all systems are connected via a computer data bus, it is not difficult to assume that the activation of the DD will be noticed by other devices.
The brake control reacts, preparing the pads for emergency operation and clearing water, additional lighting turns on, and the operating mode of the climate control and information screens changes. The machine will automatically adjust to changing conditions.
How it works
The operating principle of the rain sensor is based on the elementary laws of physics. Any glass is a translucent mirror and partially reflects the incident light. Moreover, the angle of incidence is equal to the angle of reflection (remember school textbooks). The beam is reflected from both the internal and external surfaces. The device is installed in such a way that only light reflected from the outer boundary is used. If the windshield is clear, the reflected light reaches its maximum intensity. As water becomes dirty or drops appear, the intensity of the reflected light decreases.
Let's look at the illustrations with the operation diagram
The device includes an LED and a photodiode. A reflector is installed on the inside of the windshield, parallel to it. The focused radiation is adjusted in such a way as to travel the longest possible path with several refractions and reach the photodiode. Under ideal clean conditions, the device is calibrated to minimum sensitivity. The photodiode produces a signal about the maximum possible brightness of light in this mode.
For reference: To prevent the light from the emitter from disturbing the driver and oncoming cars, an infrared LED is installed as a source. That is, the operation of the sensor does not create additional danger.
When drops of rain or dirt hit the glass, part of the emitted light is refracted on the outer surface, and the photodiode receives a weakened signal.
Its intensity is assessed by the control module, which decides whether to turn on the windshield wipers.
How to improve accuracy
If the beam path is set to a single drop, the sensor does not work effectively: to trigger, the drop needs to hit exactly the point where the light is reflected. Therefore, the refraction path on the car should be as long as possible. This solution works not only on “on.” and "off". The sensor can determine the intensity of rain (pollution), and, if necessary, change the speed of the wipers. In some advanced systems, the control unit can turn on the washer.
The light sensor is even simpler
A simple photodiode is enough and no complex beam refraction systems are needed. The device is installed in the most illuminated place inside the car (so as not to be exposed to contamination). Most often, this is the so-called “torpedo” above the dashboard, immediately below the windshield.
Important! For normal operation of the light sensor, the glass must be clean.
The photodiode detects the light level, and when the lower limit is reached, it gives a command to turn on the external lighting devices. In fact, the function of the low beam switch is duplicated.
- For normal and safe operation of the system, a deactivation function is required. The driver must decide for himself: to control the lighting manually, or to entrust this work to automation. The same goes for the rain sensor. Otherwise, when driving into a portal-type automatic car wash, the windshield wipers may be damaged.
Now you know what a rain and light sensor is. How can you find out if this device is installed on your machine? You can look at the instructions or the package. Or determine the presence of the device by the functions on the controls. The windshield wiper and light control switch should be in the "AUTO" position.
How to install a rain sensor yourself
Ready-made kits are produced for equipping cars where the DD option is not provided. It is only necessary to fix the sensor on the glass, ensuring the transparency necessary for its operation, that is, remove the tint, if there is any in this place.
It is better to choose a kit specifically for this model, then there will be no difficulties with its integration into the electrical equipment of the car.
Project diagram
The connection diagram of the rain sensor to the Arduino Uno board is shown in the following figure. The operation of this circuit was simulated in the Proteus simulator.
In the diagram shown, the rain detection board is connected to the control board. The VCC pin of the control board is connected to a 5V voltage source. The control board ground is connected to circuit ground. The output pin of the sensor can be connected to any digital pin of the Arduino board, however, as a result of our experiments, we found out that the circuit works more stably if it is connected to the analog pin of the Arduino board. The buzzer is connected to pin D5 of the Arduino board.
Note : there is a small error in the diagram drawn, the output pin of the rain sensor should not be connected to the Reset pin, but to the analog pin A0 of the Arduino board.
Disadvantages of the device
The main problems are related to setting the sensitivity threshold. Too fine a setting leads to numerous false alarms due to the slightest contamination of the glass.
Artificial hardening causes long delays in switching on. Even when checking, you have to wait ten seconds before turning it on, which nullifies all the benefits of the automatic response to rain.
Inconveniences appear and, if necessary, replace the windshield. The sensor has to be re-glued, which requires certain qualifications, and then initiated and configured. But qualified specialists are trained in this and can confidently cope with this, and glass is produced in all versions, including those prepared for DD.
Sketch example
#define PIN_ANALOG_RAIN_SENSOR A1 // Analog input for the signal of the leakage and rain sensor #define PIN_DIGITAL_RAIN_SENSOR 5 // Digital input for the signal of the leakage and rain sensor void setup(){ Serial.begin(9600);
} void loop(){ int sensorValue = analogRead(PIN_ANALOG_RAIN_SENSOR); // Read data from the analog port Serial.print("Analog value: "); Serial.println(sensorValue); // Output the analog value to the port monitor sensorValue = digitalRead(PIN_DIGITAL_RAIN_SENSOR); // Read data from the digital port Serial.print("Digital value: "); Serial.println(sensorValue); // Output a digital value to the port monitor delay(1000); // Delay between measurements } In this sketch we simply read the values from the sensor and output them to the port monitor. Conduct an experiment and see how the resulting value changes when you touch the sensor with a wet or dry hand. Wet the sensor - it started to rain or a leak appeared, wiped it with a dry cloth - the rain stopped.
Summarizing
The rain and leakage sensor can be used in Arduino to create devices that respond to the appearance of moisture in the form of drops. Among the advantages of the module considered are its simplicity, convenience and low cost. The sensor is connected very easily - using analog or digital outputs. To get the value in the sketch, use the standard function analogRead (or digitalRead for a digital pin). Using the obtained values, you can turn on the alarm or other external devices using a relay.
Hardware overview
A typical rain sensor has two components.
Touchpad
The sensor includes a touch panel with a series of exposed copper traces that is placed in an open area, such as a roof or where it may be exposed to precipitation.
Typically these tracks are not electrically connected to each other, but the water forms electrical contact between them.
Figure 2 – Touchpad
Module
The sensor also contains an electronic module that connects the touchpad to the Arduino.
The module produces an output voltage according to the touchpad resistance, which is available at the analog output (AO) pin.
The same signal is fed to the precision comparator LM393 for its digitization, the signal from the output of the comparator is fed to the module's digital output (DO) pin.
Figure 3 – Adjusting the sensitivity of the rain sensor
To adjust the sensitivity of the digital output (DO), the module has a built-in potentiometer. With this potentiometer you can set the trigger threshold; Thus, when the amount of water exceeds the threshold value, the module will output a low logic level, otherwise it will output a high logic level.
Turn the potentiometer clockwise to increase sensitivity, or counterclockwise to decrease it.
Figure 4 – Power and rain sensor status indicators
In addition, the module has two LEDs. The power indicator will light up when power is applied to the module. The status LED will light up when the digital output is driven low.