Browse over 10,000 Electronics Projects

# Arduino Weather machine

Arduino is a great hardware platform when comes to prototyping and building cool stuffs. Using this i have designed and developed a simple Arduino Weather machine which measures three important parameters Temperature, Light intensity and Humidity and predict the weather condition according to the measured parameters. This following article will walk you through the operation, working and code of this project.

## SENSORS USED:

### LM35:

This is a precision temperature measurement sensor with its output proportional to the temperature of the environment. It measures temperature from the range of -55C to 150C. The output voltage varies by 10mV with every degree celsius change in temperature.

### HUMIDITY SENSOR:

I got this humidity sensor from a local merchant. The increase in humidity level will in turn increase the output voltage of this sensor. We are going to scale the output voltage in terms of percentage.

### LIGHT INTENSITY SENSOR:

This sensor uses a simple LDR to measure the light intensity. The sensor was designed in such a way the increase in light intensity will result in decrease in output voltage. We are going to calibrate and scale the output voltage in terms of percentage.

## DESIGN OF ARDUINO WEATHER MACHINE:

The design shows three simple sensors Light, Humidity and temperature sensors are connected to the ADC channels of Arduino Uno. LCD on the other hand connected to the digital pins to display sensor values and weather conditions. The operation is simple Arduino is gonna scan the sensor with periodical intervals and displays the readings in the LCD display after calibration. Based on those input readings i have  added simple conditions in the code to make a weather forecast. The weather forecast is then printed in the LCD display for users.

## CALIBRATION:

The calibration of this Project is pretty easy and simple. The temperature sensor LM35 will give a output change of about 10mV for every change in degree Celsius whereas the step size of Arduino ADC is given by the formula

Step Size = Aref / ADC bit size = 5 / 1024 = 4.88mV

So in order to get the real temperature we have to divide the ADC value by 2.

Our light sensor module give out high voltage readings in absence of light so in order to get the intensity of Light we have to subtract the ADC value obtained from light sensor from max value that is 1023

Real Light intensity value = 1023 – Light intensity value from sensor

The Humidity Sensor and Light sensor are measured as intensity and it was scaled out of 100%. In order to do that we have to

In Percentage = ( Light  or  Humidity ) * 100 / ADC Resolution

= ( Light or Humidity ) * 100 / 1023

This gives the percentage of humidity and light intensity in the environment.

## CODE:

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
short int i;
char converted_values[5];
int light,humidity,temperature;
int cursor_position[4]={2,7,12};
char msg[6][9]={"SUNNY","RAINY","HOT","CLOUDY","COLD"};

void setup() {
lcd.begin(16, 2);
lcd.display();
lcd.setCursor(0, 0);
lcd.print("H:");
lcd.setCursor(5, 0);
lcd.print("L:");
lcd.setCursor(10, 0);
lcd.print("T:");
lcd.setCursor(0, 1);
lcd.print("WEATHER:");
}

void loop() {
light =1023-light;
lcd_print(humidity);
lcd_print(light);
lcd_print(temperature);
lcd.setCursor(8, 1);
lcd.print(condition());
delay(5000);
}

void lcd_print(int parameter)
{
if(i<=1)
{
}
else
{
}
lcd.setCursor(cursor_position[i],0);
lcd.print(conversion);
conversion="";
if(i<2)
i++;
else
i=0;
}

char* condition()
{
if(temperature>=25&&humidity<20&&light>45)
return(msg[0]);                       //Sunny
else if(temperature>30&&humidity<20&&light>50)
return(msg[2]);           //hot
else if(temperature<=23&&humidity>60&&light<40)
return(msg[1]);           //Rainy
else if(temperature<=25&&humidity>50&&light<40)
return(msg[3]);           //cloudy
else if(temperature<=19&&humidity>70&&light<40)
return(msg[4]);           //cold
}

## NOTE:

• Note that temperature sensor voltage decreases with increase in light intensity, so proper calibration is necessary to get correct output.
• Note that the conditions for weather are just assumptions, you can alter the it based on your requirement.