rain detection

Rainwater alert system

Rain alert alarm with code

In this post we are creating an arduino based rain alert alarm circuit with the code explanation line by line.Here we also discuss about the working of the rain water sensor which includes the intensity of rain falls into the circuit

Rain water sensor working

This module works on the basics of opamp LM393, The sensor board is coated with Nickel as lines which helps analyse the moisture content in the board. when there is moisture content the resistance is low and when the board is dry the resistance will be high and the opamp amplifies the output


  • Adopts high quality of RF-04 double sided material.
  • Area: 5cm x 4cm nickel plate on side,
  • Anti-oxidation, anti-conductivity, with long use time;
  • Comparator output signal clean waveform is good, driving ability, over 15mA;
  • Potentiometer adjust the sensitivity;
  • Working voltage 5V;
  • Output format: Digital switching output (0 and 1) and analog voltage output AO;
  • With bolt holes for easy installation;
  • Small board PCB size: 3.2cm x 1.4cm;
  • Uses a wide voltage LM393 comparator

Arduino code

//paste this code in arduino IDE 

const int sensorMin = 0; // set minimum sensor value 

const int sensorMax = 1024; //set maximum sensor value

//void setup is single time running program in Arduino 

void setup()


Serial.begin(9600);//here we initialize the baud rate to 9600


//loops are continuously executing the programme in Arduino programming

void loop() 


  int sensorReading = analogRead(A0); //to read analog value from the A0 pin

  int range = map(sensorReading, sensorMin, sensorMax, 0, 3); //map funtion to map the values to our rated range 

  switch (range) 


    case 0: // Sensor getting completely wet



    case 1: // Sensor getting partially wet

      Serial.println(“RAIN WARNING”);


    case 2: // Sensor dry

      Serial.println(“NOT RAINING”);



  delay(1000); //delay 1 second




Automatic Temperature Controlled Switch

We can make control temperature using this Automatic Temperature Controlled Switch circuit; it will make control temperature automatically. LM35 is the temperature sensor used in this circuit for detection of temperature and also it helps to turn ON/OFF the output devices or appliances.
Once we tune the LM35’s sensitivity level of temperature, the circuit becomes control as an automatic switch. Easily available components can be used for developing this circuit prototype with small PCB boards like line/dot PCBs.




Construction & Working

Regulator unit and rectifier are the first stage of this circuit. 110V to 220V AC Supply is the input voltage and it is converted into 9V AC by using step-down transformer. After that, it is being rectified into DC voltage using bridge rectifier. Capacitor C1 reacts as filter to remove AC ripples then using 7805 regulator IC regulates provides constant 5V DC Voltage Supply.

LM35 is the temperature sensor used in this circuit and it gives an output voltage linearly proportional to the centigrade temperature. And an operational amplifier LM358 used here to help us to choose the temperature level through the variable resistor, VR1 and output of this Op-Amp is drives the transistor, Q1. In between +5V DC and collector terminal of the transistor Q1, the relay coil has been connected. When output voltage is higher than 2.5V from Op-Amp transistor Q1 turns ON and it connect the relay coil to neutral/ground. Hence, the coil gets power and makes the Normally-Open contact to Normally-Closed one. So, we can control electrical loads or an appliance automatically depends on temperature.



12v to 220v inverter DIY circuit

Inverters are made for producing high voltage from low voltage DC sources/batteries. We are here to design an inverter circuit for converting 12V DC source into 220V AC power. Its components are easily available in our electronics markets and so easy to build on PCB boards.


Operations of this kind of inverters are based on switching pulses and were uses step-up transformers. So, the CD4047 microcontroller acts as a switching pulse oscillator and IRFZ44N (N-channel power MOSFET) acts as it’s switch. Then the 12-0-12 secondary transformer will inversely used as a step-up transformer.

Inverter Circuit Diagram


Components Required

  1. Micro-controller CD4047
  2. Power MOSFET IRFZ44 = 2.
  3. 12-0-12V secondary transformer 1 amps
  4. Variable Resistor 22KΩ
  5. Resistors 100Ω / 10 watts = 2
  6. capacitor 0.22µF
  7. 12 volt battery

Construction & Working

This inverter circuit has switch device and step-up transformer. As per the theories, high switch frequency pulse reaches the step up transformer and due to the mutual inductance; output voltage will reach high value.

The microcontroller CD 4047 is configured as an astable multi-vibrator mode with the help of variable resistor RV1 and capacitor C1. By varying the value of RV1, we will collect different range of output pulse at Q and Q’ pins. These all results the variation of output voltage at the step-up transformer.

The IRFZ44 (N-channel power MOSFET) will drain, pins are connected with secondary pins of the transformer and common pin connected with the secondary winding and is connected with battery positive bias. Both MOSFETs source pins are connected to the negative bias of battery. And these are driven by Q and Q’ output from CD4047 micro-controller. If an alternate square pulse drives the MOSFETs switches, the secondary winding may forced to induce alternate magnetic field. This magnetic field induce primary winding of transformer and will produce high alternate voltage.

Note: High AC voltage circuit. Attention for handle with extreme care.