Weather Station with Arduino

One of the most projects I would like to make was a Weather Station with Arduino. Why? Because I would monitor weather data from a local home in the countryside for our summer residence. Along the renovations and works on electrical system fo the house, I installed a cable ways running from the downside to the roof and an electrical box inside the wall as a space to be used for home-made weather station based on Arduino, as well. A Gewiss box for electrical home components (like power supplies, power button, protection guard devices and so on…) was installed and left empty. Due to the power of the Arduino and the space available inside the electrical wall box, I decided to use the system for domotic light control around the house and inside the garden.  So I bought a set of Solid State Relays (SSR) integrated on a ready-to-use electrical board compatible with the output pins of Arduino without the needs to be coupled with other components.

  1. System characteristics
  2. External installation
  3. Main electrical design of the Weather Station with Arduino control board
  4. Commands and control powered by SMS (short message system)
  5. Weather data on a MySQL database powered by a WEB service
  6. Weather Data in real time from the Weather Station with Arduino
  7. For who wants to build a weather station like this…

Stazione Meteo con Arduino - Box Gewiss a Muro

Two Ethernet cables have been installed from the inside of the electrical box to the roof. The target of those cables was to connect the external sensors and make the data available for the station. A set of other sensors are available inside the house to gets inside parameters.

System Characteristics

After the first evaluation, I decided the type of sensors needed for environmental data:

  • temperature and humidity:
    sensor DHT22 (AR2303)
    digital type with 1-Wire communication bus
  • Wind speed and direction:
    a Davis device, integrated anemometer with wind direction
    an analog signal for wind direction and a digital pulse signal for speed
  • environmental light:
    light sensors TEMT6000
    analog signal
  • barometric pressure:
    a sensor MS5611
    digital type with I2C communication bus
  • rain gauge:
    “Tipping Bucket” type with two moving plates
    digital pulse signal – a pulse every 0,3mm of dropped rain
  • rain detection:
    a digital signal for rain presence, an analog signal for quantity

For internal data:

  • temperature and humidity:
    sensor DHT22 (AR2303)
    digital type with 1-Wire communication bus

To complete the system, I added the following components:

  • Arduino Mega 2560
    the brain of the system
  • Graphical display 128×64 totally managed by Arduino
    for data visualization and to enable user interaction
  • a GSM module – a SIM800L series
    • to receive remote commands and send back the answers via SMS
    • through a GPRS data connection (or 2G) the module is able to send data obtained from the sensors to a web server using a specified designed PHP page to get data and insert into a MySQL Database to be available for further visualization (please continue to read)
  • a real-time clock module RTC – DS1307 – a continuous perpetual calendar buffered by a CR2303 battery
    digital type with I2C communication bus
  • main power supply 220V – 5V 2A switching
  • battery supply system
    • lithium battery 18650 – 2500mAh 3.7V
    • recharge power and control module
    • step-up for voltage adjusting from 3.3V (3.7V) to 5V to provide right power supply to Arduino and all the components
    • main power switch

External Installation

Up to the roof, on main tv antenna support, I installed the wind speed and direction sensor (the anemometer) connected to a metal box, industrial, recovered from a dismissed instrument.

Stazione Meteo con Arduino - Anemometro Direzionale   Stazione Meteo con Arduino - Box installazione esterna

Inside the box, with a transparent window, I installed a laboratory test board prepared to host the light sensor, the rain gauge electronic board, the fast connections plug, pull-up resistors.

The anemometer has a cable with 4 wires with different colors. The BLACK one is for wind speed and the GREEN one is for analog direction. For the power supply, the RED one is the Ground signal and the YELLOW one is the +5V line. Following the connection schema, we need to connect a pull-up resistor from wind speed terminal to +5V.
Stazione Meteo con Arduino - connessione anemometro direzionale vento

Main electrical design of the Weather Station with Arduino control board

When the external installation gots the end, I started the electronic board test.

In the beginning, I measured the space available inside the Gewiss electrical box, so there was clear the dimension of the board on which to host the Arduino Mega 2560 and all other elements included the two solid state relays boards.

On a laboratory desk prototyping board, I assembled the basic components of the system, included for test purpose only a display LCD 2004 I2C.

Stazione Meteo con Arduino - prototipazione elettronica e test

So in that phase, I was able to test the following:

  • Temperature and humidity sensors (both internal and external)
  • Light sensor
  • Atmospheric sensor
  • Wind speed and direction sensors
  • … and the buffered by battery real-time clock module

On the test display, I put all the basic data to evaluate the behavior of the whole system. After that, I attached the GSM module, the SIM800L. My primary target was the SMS management: receive SMS and react to accordingly and establish a method to obtain information about the GSM network status, for instance, the quality of the signal. Finally, I attached the battery module with power supply circuits.

So, I changed the LCD 2004 I2C display with a graphical one with a resolution of 128×64.

The finalization phase terminated with a home-made breadboard carefully cut. So, a set of connectors completed the board permitting a simple and fast connection and disconnection in case of maintenance or needs to gain access inside the box. A front-panel USB connector completed the installation. Thru it I could connect to Arduino without the needs to open the box.

Stazione Meteo con Arduino - realizzazione scheda Arduino con batteria, RTC, SIM800 e display grafico

With the entire system powered on, included the display, I tested the time of the battery, reaching the best time of 25 minutes. A great time to grant a good time in case of power outage.

I used an auxiliary PIN of Arduino to connect the output of the power charger module to monitor the mains and the power presence and in case of power missing the system is able to send an SMS or send a WEB alert through a reserved web page.

So the electrical board was ready to be tested locally into the wall box.

Stazione Meteo con Arduino - installazione stazione meteo con arduino in box gewiss a muro

The AT commands set of the SIM800L module, I finally tested the GSM quality signal inside the box, the results were really encouraging. So, my attention goes down the graphical aspect of the data on the new display.

After to proceed with the software development, I decided to finalize the mechanical part of the system. So, I assembled the frontal plastic part of the Gewiss box using steel screws and Ergal supports that I used on model radio-controlled helicopters.

Stazione Meteo con Arduino - stazione meteo con arduino installata in box gewiss a muro con display

At that point, I finalized the data display and I tested the solid state relays module to control the external lights and the garden lights: the domotic aspect of the station driven remotely by SMS.

I added 3 push buttons on the front of the panel with the following functions:

  • page change button
  • function selection button
  • function activation button

There are the following pages:

    • weather page with the following information:
      • Status and intensity of the signal received by GSM
      • SMS Status (receiving, sending, waiting)
      • Internal Box Temperature
      • Power supply status:
        • from the net (power connected symbol)
        • from the battery (power connected missing symbol) in case of a power outage
      • Power supply value in volts
      • Atmospheric pressure expressed in mBar included the pressure symbol
      • External light in lux
      • Date and hour from the real-time clock
      • Wind speed and direction with a graphical representation in term of degrees, speed in km/h and the conventional name of the wind
    • External light control
      • Status and intensity of the signal received by GSM
      • SMS Status (receiving, sending, waiting)
      • Internal Box Temperature
      • Power supply status:
        • from the net (power connected symbol)
        • from the battery (power connected missing symbol) in case of a power outage
      • Power supply value in volts
      • Home graphical representation of the real light disposition
      • External light in lux
      • Crepuscular activation in term of light threshold and timing
      • Crepuscular activation indicator with the real-time value of the time
      • Power on the whole light segments 
      • Light status as following:
        • upper left corner highlighted – crepuscular control enabled on that light segment
        • down right corner highlighted – timer enabled for the deactivation of that light segment with the timer set in minutes
        • full rectangle – light powered on by the system
        • in the bottom par,t there was numerical and textual indication in term of light segments and time for deactivation of the lights

Inside the control light page, the user, through the function keys, can power on or off a single segment of light, a group or all at the same time. For example, the user can power on the entire set of the lights in the garden or around the house.

Commands and control powered by SMS (short message system)

With a simple SMS sent to the SIM card telephone number inserted into the SIM800L module, the user, can control parameters and status, as follows:

  • To set the crepuscular timer in minutes
    TIMER SET #xxxx# where xxxx is the time in minutes
  • To set the threshold of the crepuscular in lux
    CREPUSCULAR SET #xxx.xx# where xxx.xx is the value of the lux threshold
  • To set the garden light in manual mode, the crepuscular and the timer are disabled
    GARDENLIGHT MANUAL 
  • To set the house light in manual mode, the crepuscular and the timer are disabled
    HOUSELIGHT MANUAL
  • To set the garden light in timer mode – when the lights are turned on (from the local panel or remote SMS) they are turned off after the expiration of the timer
    GARDENLIGHT TIMER
  • To set the house light in timer mode – when the lights are turned on (from the local panel or remote SMS) they are turned off after the expiration of the timer
    HOUSELIGHT TIMER
  • To set the garden light in crepuscular mode – the lights are turned on according to the crepuscular status
    GARDENLIGHT CREPUSCULAR
  • To set the house light in crepuscular mode – the lights are turned on according to the crepuscular status
    HOUSELIGHT CREPUSCUTIMER
  • To set the garden light in crepuscular and timer mode – the lights are turned on according to the crepuscular status but powered off after the timer
    GARDENLIGHT CREPUSCUTIMER
  • To set the house light in crepuscular and timer mode – the lights are turned on according to the crepuscular status but powered off after the timer
    HOUSELIGHT CREPUSCULAR
  • Powering on or off some light sections or group at the same time
    es. POWERON LEFT RIGHT REAR GARDENLIGHT FRONT REAR HOUSELIGHT 
    it powers-on the left, the right and the rear garden lights and even the front and the rear house lights
  • Request the system status
    SYSTEM STATUS
    when the system receives this message, immediately respond to an SMS including all data from the weather station and the whole setting values of the light (crepuscular and timer) and the status of powering of the light
  • For test purpose only, there are a couple of SMS:
    DISPLAY ON or DISPLAY OFF to power on or off the front display
    TEST ON or TEST OFF to power on or off the LED integrated on the board of the Arduino

The system stores the whole parameters set by SMS into the Arduino’s EEPROM. Every time an SMS reaches the system, date and time are extracted to synchronize the RTC calendar without the needs to set manually.

Weather data on a MySQL database powered by a WEB service

Thanks to the SIM800L module, the system is able to send the weather information to a remote MySQL database using a WEB page written in PHP language enabled to insert data into the database.

The weather station with Arduino, every 10 minutes, request the proper page through HTTP GET method appending the whole set of data.

The link of the page appears like this

http://www.yoursite.ext/page.php?par1=xxx&par2=yyy&….

where

  • www.yoursite.ext is the web address of the page for data insertion runs
  • page.php is the page able to catch-up the data and insert into the database
  • par1=…, par2=…. are the parameters to be memorized

Other pages are available in the same folder of the server to presents data in a graphical way for further evaluation. You can see the real-time data in the bottom of this page.

Weather Data in real time from the Weather Station with Arduino

Down here you can see the data upgraded about every 10 minutes.
There are 3 graphics and 2 radars displaying:

  • Inside/Outside Temperature and Humidity and Inside the Box Temperature graphical representation
  • Barometric and Light environment graphical representation
  • Wind speed and direction graphical representation
  • Wind direction distribution Radar
  • Wind speed distribution Radar

The graphical page is obtained extracting data from the database for the last day and some links enable the user to shift till 5 days ago.
A lot of new consulting functionality will be available soon.

And finally here you can see the weather data:

For who wants to build a weather station like this…

If you want to make a weather station with Arduino like this or with similar functionalities, please follow this link where you could find hardware and software details, with some sketch for Arduino ready to use.