Making a rain sensor with e-mail notification using Arduino. Installing a rain sensor Connecting a leakage and rain sensor to Arduino

In this tutorial, we will use a rain sensor to detect the intensity of rain and will generate an analog variable signal from 0 to 1024. It will also generate a digital output according to its set value.

When the rain sensor detects rain, it sends an analog signal to Arduino Uno Board. Arduino Uno monitors changes occurring on the rain sensor. When the rain sensor value goes beyond a certain level, our Arduino Uno sends some commands to our GSM module and GSM module sends SMS to the desired phone number.

Arduino IDE Installation: You can download latest version Arduino IDE on this page.

Step 2: Components Used

For this project we will need some components:

  1. Rain sensor/sensor
  2. GSM module (sim 900)
  3. Set of wires/jumpers

Rain sensor/sensor

The Rain Sensor Module is a simple rain detection tool. It can be used as a switch when a raindrop falls on the sensor and also to measure the intensity of precipitation. Modular functions, rain board and control board which are separate for more convenience, power indicator and adjustable sensitivity, potentiometer.

The analog output is used to detect droplets in precipitation amounts. When connected to 5V power supply, the LED indicator turns on, when no rain falls on the induction board, the DO output is high. When the water quantity decreases, the DO output is low and the switch indicator turns on. Remove drops of water, when restored to its original state it will reach a high level.

GSM module (sim 900)

This is GSM/GPRS compatible quad band cell phone, which operates at a frequency of 850/900/1800/1900 MHz and which can be used not only for Internet access, but also for oral communication(provided it is connected to a microphone and a small speaker) and SMS.

Externally it looks like a small package (2.4 cm x 2.4 cm x 0.3 cm) with L-shaped contacts on four sides so that they can be soldered both from the side and from the bottom. Indoor module controlled by processor AMR926EJ-S, which controls telephone communication, data transfer (via the built-in TCP/IP stack) and (via UART and TTL serial interface) communication with the circuitry interfaced with the phone itself.

The processor is also responsible for the SIM card (3 or 1.8 V), which must be connected to the external wall of the module. In addition, the GSM900 device integrates an analog interface, A/D converter, RTC, SPI bus, I²C and PWM module. The radio section is GSM 2/2+ phase and is class 4 (2 W) at 850/900 MHz or class 1 (1 W) at 1800/1900 MHz.

The TTL serial interface is responsible not only for transmitting all data regarding already received SMS and those included during TCP/IP sessions in GPRS (data transfer rate is determined by GPRS class 10: maximum 85.6 kbit/s), but also receiving commands circuits (in our case, coming from the PIC controlling remote control), which can be either the AT standard or the AT-enhanced SIMCom type. The module is supplied with continuous power (3.4 to 4.5 V) and absorbs a maximum of 0.8 A during transmission.

Arduino Uno

Arduino Uno or Genuino Uno is a microcontroller board based on the ATmega328P ( technical description). It has 14 digital I/O (of which 6 can be used as PWM outputs), 6 analog inputs, 16 MHz quartz crystal, USB connection, power jack, ICSP header and reset button.

Step 3. Project description

In this project we will use Raindrop Sensor to detect Raindrop Intensity and generate some analog values. When the rain sensor detects the intensity of the raindrop, Arduino UNO sends a command to the GSM module, then the GSM module sends mail to the specified email ID.

The connection of our circuit is shown above. Eat two circuit diagrams: one for rain sensor with Arduino and another for Arduino with GSM module.

Step 4. Code for the project

You can download the source code for this project below.

/* RAIN DROP DETECTOR WITH GSM(USING SIM-900 MINI , RAINDROP SENSOR & ARDUINO UNO); Here We Are Using Raindrop Sensor To Detect Raindrop Intensity And Generate An Analog Varying Signal From 0 To 1024. It Also Generates A Digital Output According To Its Preset Value. When The Raindrop Sensor Detects Rain Then It"s Going To Send An Analog Signal To Arduino Uno Board. Arduino Uno Monitoring The Change Happening On Raindrop Sensor. When The Value Of Raindrop Sensor Going Beyond A Certain Level Our Arduino Uno Sends Some At Command To Our GSM Module And GSM Module Send An SMS To The Given Phone No. The circuit: * GSM MODULE(SIM-900 MINI) 5VT(TX) CONNECTED TO PIN 9(RX FOR SOFTWARE SERIAL) * GSM MODULE(SIM-900 MINI) 5VR(RX) CONNECTED TO PIN 10(TX FOR SOFTWARE SERIAL) * RAINDROP SENSOR DO TO PIN 11 * RAINDROP SENSOR AO TO PIN A0 * CONNECT VCC OF RAINDROP TO 5V OF ARDUINO UNO * CONNECT VCC OF GSM TO 5V OF ARDUINO UNO created. 8 NOV 2016 by SOUMYA RANJAN PANDA For any help contact [email protected]*/ #include SoftwareSerial mySerial(9, 10); //(RX,TX) int d=0; void setup() ( mySerial.begin(9600); Serial.begin(9600); pinMode(11,INPUT); //FOR DIGITAL INPUT pinMode(A0,INPUT); //FOR ANALOG INPUT delay(50); ) void loop() ( int sensorReading = analogRead(A0); //READ RAINDROP SENSOR VALUE if(sensorReading<500) //WHEN SENSOR DETACT RAIN IT"S ANALOG VALUE REDUCE { Serial.println("Raining"); SendMessage(); //SENDING SMS SIGNAL TO GSM MODULE while(analogRead(A0)<800); //HOLDING STATE UNTIL RAIN STOP } else if((sensorReading>500)&&(sensorReading<800)) // IT IS FOR RAINWARNING { Serial.println("Rain Warnigitng"); } else if(sensorReading>800) //WHEN RAIN STOP ( Serial.println("NotRaining"); ) delay(1000); ) /*************************FOR GSM SIM-900 MINI*************** *****************/ void SendMessage() //SENDING SMS SIGNAL ( mySerial.println("AT+CMGF=1"); //SELECTING SMS Text Mode delay(1000 ); mySerial.println("AT+CMGS=\"+91XXXXXXXXXX\"\r"); //PROVIDE YOUR MOBILE NUMBER delay(1000); mySerial.println("HELLO SIR, I AM YOUR HOUSE .IT"S RAINING OUTSIDE:)"); delay(100); mySerial.println((char)26); delay(1000); )

Step 5. Final video

See the full video of the project and its description above. That's all.

In some hobby projects involving monitoring weather conditions or, for example, growing plants outdoors, it can be useful to know whether it is currently raining or not. Since many radio amateurs use an Arduino board as a control board, a special drop/rain sensor was developed for these purposes, which can be easily connected to the Arduino. The simple Arduino project presented in this material will allow you to turn on a sound alarm when the drop/rain sensor is triggered.



The rain sensor consists of a sensor plate and a board with an LM393 comparator. In addition to the digital output, the sensor has an analog output, so the Arduino microcontroller can read analog readings in the voltage range from 0 to 5 V or a value from 0 to 1023 after the ADC.



If the sensor board is in a dry state, the analog output of the module is 5 V. If rain drops fall on the plate, connecting the board conductors to each other, the analog output changes from 5 V to 0 V depending on the amount of moisture on the plate. In this way, the sensor tells us whether it is raining heavily or lightly. The Arduino will trigger the alarm after a certain amount of rain and a certain delay, which will be defined in the code. This will avoid false positives. In this case, the response threshold is 300 and the delay is 30 seconds.


Below is an Arduino sketch that allows you to trigger an alarm connected to digital port 8 when detected by a rain sensor.


int rainSensePin= 0; // analog input 0 for sensor signal int alertPin= 8; // digital output 8 - for signaling int curCounter= 0; // counter - incremented by 1 every second after the sensor is triggered void setup())( Serial.begin(9600); pinMode(alertPin, OUTPUT); pinMode(rainSensePin, INPUT); ) void loop())( int rainSenseReading = analogRead(rainSensePin ); Serial.println(rainSenseReading); // for monitoring via serial port delay(250); // short delay if (curCounter >= 30)( // end of time delay digitalWrite(alertPin, HIGH); // alarm triggered) // if there is no more rain, reset the counter if (rainSenseReading<300){ curCounter++; } else if (rainSenseReading >300) ( // if the rain intensity does not exceed the threshold digitalWrite(alertPin, LOW); // do not turn on the alarm curCounter = 0; // reset the counter to 0 ) delay(1000); )

When it's raining(and the Arduino detects it) the output of D8 goes to logic high. This output can be connected to an audible alarm (piezo buzzer) or a switch (electromagnetic relay). The output connection diagram is shown below.



In this case, the Arduino is powered from an external 9V source, the buzzer/relay activation circuit can be powered from 5-12V. The Vcc supply voltage must be suitable for both voltage and current for this circuit.


Thus, creating a project in which the Arduino board can be used to detect the presence or absence of rain or falling drops from any liquid source is not a difficult task. The drop/rain sensor for Arduino is quite common, inexpensive and easy to use. Ultimately, you can do it yourself.

In principle, you can make an automatic windshield wiper control system yourself. This will allow you to monitor the operation of the wipers in different weather conditions. Modern cars are already equipped with this function.

Owners of old VAZ models are increasingly wondering about the possibility of installing a rain sensor on their car?

Many foreign cars have a rain sensor on the windshield (“DD” - hereinafter), which is built into the front glass, which does not allow it to be removed.

Drivers of a car that does not have such a sensor can install it themselves using a universal sensor. Such a device is suitable for any car, including “tens”.

Basic principles of operation of a universal DD.

The location of the optical sensor must be vertical. Place it inside the cabin on windshield into the area covered by the brushes. The location for installing the sensor is chosen without defects such as chips or cracks.

Thanks to infrared radiation, the state of the glass is scanned from outside. Moisture or dirt on the glass changes the signal reflection level. The electronic control unit receives a command to turn on the windshield wiper. The system automatically changes the pause for brush movement, which depends on the amount of precipitation.

DD will fit on various windshields; the upper tinted strip on the glass will not interfere with its installation. But the infrared filter on the glass will interfere with the operation of such a sensor, for example, in a Chevrolet Niva Lux.

Features of enabling DD.

The sensor operates only when the wipers are turned on in the first position, and then the sensor increases or decreases the speed of the wipers. In the 2nd and 3rd positions, the operation of the wipers does not change.

It is imperative to be able to manually control the windshield wipers, since there are different cases, and the sensor cannot always cope with them. Examples include cases where there is a lot of splashes on the driver’s side, but there is none in the sensor area, or when contamination in the form of bird droppings appears on the glass, but the driver does not immediately notice it when getting into the passenger compartment.

In dry weather, it is advisable to keep the DD turned off to avoid false activation due to a flying insect in the detected area, fluff, leaves and even shadows, which cause the wiper to operate by wiping the dry windshield.

In all cars, the windshield washer can only be activated manually, automatic switching on a jet of liquid may come as a surprise and limit the driver's visibility.

For clarity, a consideration of two DD models is given. The first uses a foreign microprocessor as a basis, and the second was created by domestic specialists:

Main characteristics of the rain sensor model RS-22 RAIN sensor

The sensor uses a microprocessor manufactured by the American company Microchip. Installation of such a sensor is possible for any car with 12 volt equipment.

Step-by-step connection of DD model RS-22:

1. The sensor holder is attached to the windshield using glue;
2. To equalize the refractive index, apply a little special gel to the surface of two working zones in the sensor body;
3. Fix the base of the sensor housing to the holder with a self-tapping screw;
4. Should be checked work area from the sensor to the car glass for the absence of air bubbles.




Connection to VAZ DD:

The windshield wiper operating mode switch serves as the sensor connection point, according to the attached diagram.

1. Using a blue wire, the sensor is connected to the car body.
2. The sensor is connected with a red wire to the switch in contact “I”, and the standard yellow cord with a green strip is disconnected.
3. The sensor is connected with a yellow wire to a yellow car cord with a green stripe.
4. The sensor is connected with a black wire to the switch block at “pin 53” using a blue wire.

In order for the device to work correctly, its sensitivity must be initially calibrated according to the throughput parameters of the front glass. During further use, the sensor is set to the required sensitivity threshold for the windshield wiper to operate. The instructions for the RS-22 model contain information about connecting and operating the system.

Main qualities of DDA sensors

Our domestic engineers came up with a special rain sensor, the creation of which did not copy ideas from other people's solutions. The system designers took into account the following conditions:

1. Easy operation and management of the system;
2. Self-installation DD at home;
3. Connectivity without interfering electrical wiring cars, especially cars under warranty;
4. The ability to turn off the rain sensor and control the windshield wipers manually;
5. Cheap purchase.

In addition to these conditions, the finished device has the ability to adjust the pause of the moving brushes, which is controlled by the speed of the vehicle. At low speed, the pause time increases. The system “recognizes” a large volume of water when driving through deep puddles before the water reaches the surface of the glass, at a distance of 50 to 100 mm, and therefore activates the glass wipers in advance.

The DDA-25 sensor model is installed on the Lada Priora and Kalina; its difference from the DDA-15 model lies in the different location of the relay contacts.

Availability of modes: for rain\snow\standard mode. The front side of the sensor is equipped with two indicators and a button for quickly changing modes.

In accordance with the wishes of customers, the creators are constantly improving the system and refining it. Thus, in the first model it was not possible to adjust the sensitivity of the sensor. The problem was solved by using a tint film, which was placed in several layers under the sensor elements, and then this useful function added DDA to new models (as indicated in the instructions).

Stages of sensor installation (SDA):

1. Glue the optical sensor holder to the front glass of the passenger compartment.
2. Disassemble the mounting block in the car, remove the windshield wiper control relay, and insert the DD unit in its place, following the markings and the position of the key.
3. Lay the wires along the windshield pillar on the left side.
4. Set the sensitivity level of the device.



For better clarity, you can watch the installation of the sensor in the video:

Purchase of a rain sensor for a VAZ

Online stores offer a wide selection of DD for any car; just go to the “Accessories” section and order the desired model.

The cost of rain sensors depends on the manufacturer and the markup of the store, the initial limit is about 1 thousand rubles.

In conclusion

Install this system It’s up to the car enthusiast to decide whether or not; for many it seems unnecessary. The fact remains that while driving, the driver does not need to take his eyes off the road to adjust the movement of the windshield wipers, and this reduces the risk of accidents and makes driving more comfortable in adverse weather conditions.

In negative reviews you can often hear complaints about poor quality work rain sensor. This may be when the wipers are triggered when the left turn signal is turned on, when there is no possibility of adjusting the sensitivity on the sensor.
When summing up, we can say that the positive aspects of this device outweigh the negative reviews.

To install a windshield wiper control system, it is not necessary to use the services of a car repair shop; you can do this work yourself. Almost all modern cars have this function, so the operation of the wipers in different weather conditions is controlled automatically. The rain sensor is built into the front window of any foreign car, so it is impossible to remove it.

However, you can install a rain sensor on an old domestic car. This device is quite easy to make, and it is quite suitable for VAZ cars. To work you will need a universal sensor.

How the device works

The device operates on the basis of optics, which must be positioned vertically. Place the universal sensor on the inside of the windshield. The installation location must be within the coverage area of ​​the brushes, and cracks, chips and other defects are not allowed on the transparent surface.

Using infrared radiation, the sensor scans the condition of the outer surface of the glass. Raindrops and dirt change the reflection strength of the light signal. After this, the electronic control unit gives a command to turn on the windshield wipers. Time lags between brush movements are set automatically and depend on the intensity of precipitation.

Such a rain sensor can be installed on the windshield. In this case, the upper tinted strip will not interfere with the adequate operation of the device. The sensor will not fit cars that have an infrared filter on the glass.

Turning on the rain sensor

The sensor works only when the windshield wipers are activated in the first position; the device selects the intensity of movement of the blades automatically. If the wipers are in the second or third position, their speed does not change.

When installing a rain sensor, you must leave the possibility of manual control of the windshield wipers. Any situation can arise on the road, and you should not rely entirely on automation. For example, on the driver’s side there is a lot of splashes from oncoming traffic, but these splashes do not reach the sensor’s operating area, and the glass does not clean.

Experts recommend keeping the rain sensor turned off in dry weather. Since the device reacts to different objects: a flying insect, tree leaves and fluff. In this case, the windshield washer must always be started manually. Automatic water supply to the glass can frighten the driver, unexpectedly limiting the view.

When making a sensor, you can choose an imported microprocessor as a basis or use domestic developments.

Rain sensor on a foreign microprocessor model RS-22 RAIN sensor

The microprocessor is manufactured by the American company Microchip and is suitable for any car with 12 V equipment. Connecting a rain sensor consists of four stages:

  1. Attach a special holder to the inside of the windshield using glue;
  2. Apply the gel to the surface of the working area of ​​the sensor to equalize the refractive index;
  3. The position of the sensor body on the holder is fixed with a screw;
  4. Check the work area for air bubbles.

Such a rain sensor can be connected in VAZ cars using the wiper mode switch:

  1. The sensor is connected to the car body with a blue wire;
  2. A red wire is pulled from the sensor to pin I on the switch;
  3. The yellow sensor wire is attached to a cord of the same color, but with a green stripe.
  4. The device is connected with a black wire to the block at pin No. 53.

For proper operation devices, at the initial stage you need to calibrate the sensitivity of the elements and check throughput windshield. The windshield wipers will begin to work adequately only after setting the response threshold for the rain sensor.

Domestic developments of a rain sensor

Russian engineers have created a rain sensor that has no analogues in the world. Its main advantages are:

  1. Simplicity and reliability of system management;
  2. Possibility of self-installation;
  3. The sensor is connected autonomously. The car's electrical wiring is not involved (and this factor is especially important when the car is under warranty);
  4. Possibility to disable the sensor and switch to manual mode wiper control;
  5. Low cost.

The device has the function of adjusting pauses that accompany the movements of the windshield wipers. Changing the frequency of operation of the brushes has a direct relationship with the speed developed by the car on the road. With slow movement, the pauses lengthen, and with fast movement, they shorten. If the driver wants to storm a deep puddle in his car, the system will detect the approach of a large volume of liquid to the glass in advance. At a distance of 5 to 10 cm, approaching water and dirt will be detected and the system will activate the wipers in advance.

The most widely used sensor model on the domestic market is DDA-25. Typically, Lada cars (Kalina or Priora) are equipped with such devices. The rain sensor has several modes to protect against snow and rain. Three built-in programs can be changed using a button on the device body. You can install such a sensor yourself; to do this, just follow the established procedure:

  1. Attach the optical sensor to the windshield using an adhesive base;
  2. Install the sensor in place of the relay in mounting block car (while observing the markings and position of the key);
  3. Lay the wiring along the front glass pillar;
  4. Set the sensitivity level of the sensor.

The installation of the rain sensor is shown more clearly in the video:

A suitable rain sensor can be found in most online stores for motorists. The cost of such a device is usually not high: you can focus on a price in the region of a thousand rubles.

Modern vehicles have complex design, which, in addition to various improved components, assemblies and mechanisms, is represented by a large number of useful additions, including a rain sensor. However, there are various conflicting rumors about it in car owner circles. Some argue that this device does not provide any benefit and is only necessary to increase the cost of the car. According to others, having this option is no less useful than the ABS system. Let's try to figure out whether installing a rain sensor on a car is necessary or not,

Structural and functional features

It is worth noting that the rain sensor, which appeared not so long ago, was installed exclusively on premium cars. However, later it became that useful addition that appeared on vehicles of the medium and budget categories. In addition, on sale you can find various modifications of this device, which can be independently installed on any car. Now every car enthusiast can install a rain sensor.

How does this work

How does a rain sensor work? Its circuit is represented by a sensitive element that reacts to precipitation falling on the windshield, after which the windshield wipers are automatically turned on. Most vehicle models have a multifunctional rain sensor, that is, in addition to turning on the car's wipers, it also controls the operation of the side window closers and closes the sunroof.

If such a system is installed on a car, the comfort when driving in rainy or snowy weather increases many times, because the driver no longer needs to independently turn on the windshield wipers and select the optimal operating mode. The electronics will do this for him.

The operation of the sensor is based on the principle of refraction of infrared radiation at the moment when drops of rain or snow fall on the windshield. Thanks to this feature, the rain sensor in the car is located on inside windshield, therefore it is completely excluded from contact with water. The device circuit consists of an electronic control system and an actuator (relay), which starts the electric motors of the wipers and, depending on the intensity of precipitation, adjusts their operation.

The design of the control system is represented by a sensitive photocell and LEDs, which emit infrared light during sensor operation. Next, the IR radiation passes through the glass, and when it is clean and dry, most of it is reflected from the surface and captured by a photocell. To equalize the refractive index, a special gel is applied to its working area. But as soon as moisture gets on the glass, the radiation begins to dissipate. Based on these changes, the sensor photocell sends appropriate signals to the control system, which, based on the embedded algorithms, starts the glass cleaners and corrects their operation.

Note that most devices are not customizable, that is, they respond to changes in weather conditions with a delay. But still, the rain sensor has more advantages:

  • reduces driver fatigue and increases comfort when driving during precipitation;
  • increases safety on the road due to the fact that the driver does not have to interrupt to switch operating modes of the windshield wipers;
  • significantly extends the service life of the wiper mechanism.

How does a rain sensor work?

The device starts working when the windshield wipers are turned to the first position, then, depending on the intensity of precipitation, the control unit selects the optimal operating mode for the wipers. The remaining positions of the glass wipers remain unchanged.

In any case, you should not disable manual control of the wipers, since the occurrence of an unusual situation cannot be completely ruled out. For example, splashes of puddles accidentally falling on the windshield after rain, which were not caught by the working element of the sensor, or the need to clean the glass from dust or bird droppings.

To eliminate false alarms of the sensor in dry weather, it is necessary to turn it off, since the wiper blades can damage a dry windshield.

Self-installation of a rain sensor on a car

Install this useful accessory possible for any vehicle. In the case when the machine is still under warranty, before installing it, you must select a universal, customizable model that completely eliminates interference electrical network. Otherwise, the warranty will be automatically excluded. When purchasing a sensor, its package must include a detailed installation diagram, sensor elements, gel and mounting adhesive.

Installing a rain sensor on a car is carried out in the following sequence:

  1. On work surface A special gel is applied to the sensor, thanks to which the refractive index of the infrared radiation of the LEDs is equalized.
  2. Using the mounting adhesive included in the kit, the optical part is attached to the inside of the windshield.
  3. The device control system is located in the car's mounting block instead of the windshield wiper relay (during installation, the main thing is not to make a mistake with the position and marking of the key).
  4. The optical part and the control system are connected by wires that are hidden in the rack casing.
  5. Finally, the required sensitivity is set.

In the event of a breakdown, replacing the rain sensor is carried out in the reverse order. But you need to know that on foreign cars the optical part of the accessory is mounted directly into the glass and you cannot remove it yourself.

Making your own rain sensor

Most car enthusiasts are interested in the question of how to make a rain sensor with their own hands? First, you need to decide on the type of device being manufactured, thoroughly know its operating principle and select parts that correspond to the diagram. In principle, there should be no problems with purchasing elements for making a device yourself. However, in addition to them, a special optical gel is also required, without which the sensor will not work correctly.

The most common type for self-production is optical. His detailed diagram and a description of the details can be found on the Internet. The design of the second type - a moisture meter - is more difficult to replicate in a home workshop, but it is different high accuracy work.