Weather station powered with Arduino

Weather station powered with Arduino

Thanks to all the sensors compatible with Arduino board, it is very easy to build a complete weather station. Here is how I proceed.

About components

To achieve this weather station, one should first choose what has to be monitored. I chose temperature, humidity and atmospheric pressure. One could also consider the amount of rain, luminosity, rate of oxygen, etc.. Everything is about finding the appropriate sensor. Be careful about the limited number of pins on your Arduino board. Beyond a certain number of sensors, it may need other components to increase the number of inputs / outputs of the Arduino. Here, we want to keep a simple installation, the following components were used:

– for pressure, a BMP085

BMP085

-for humidity, a DHT22

large_DHT22

The advantage of these sensors is that they have an embedded temperature sensor used for their own compensation. The one from the BMP085 is the most accurate, but we will record data from DHT22 anyway.

Now that we have the sensors, we need to save data and know at which time they were measured. We then choose:

– a SD card breakout to store measurements:

– a component called TinyRTC for Real Time Clock:

At the heart of all this, we add a ATMEGA 328P that will be used with its internal 8MHz oscillator in order to further simplify installation. For power, we want to use a 9V battery, so we add an LM075 which is responsible for the regulation part.

Then, we want to set the date and view sensor values without going through a computer. We then add a Nokia 5110 LCD screen and some push buttons to interact with the ATMEGA.

Some resistors to ensure 5/3.3 volts conversions and here we are, it only remains to make the wiring.

The wiring

Before welding everything definitely, we work with an Arduino Uno on a prototyping board. For wiring, it is noted that the RTC and the BMP085 communicates both with the I2C protocol, which requires a single loop of wire through the SDA and SCL ports of these two units.

For the SD card, the protocol is a bit more expensive in cable and pins, since in addition to the power supply, it takes 4 pins (MISO, MOSI, CS, SCK).

The DHT22 is the most economical using a single pin for measurement.

We slightly changes the TinyRTC by unsoldering the diode and connecting the power supply directly on battery pins. Indeed, this component is supposed to work with a rechargeable button cell battery, quite difficult to obtain, and in any case, in this arrangement, the power will always be available at least to power the Arduino.

The other available Arduino pins are used to send a display on the LCD screen and retrieve information from 4 pushbuttons.

Here is the wiring with an Arduino Uno without the LCD and pushbuttons. This assembly can already perform measurements and store them on an SD card:

Source and libraries

About the programming part, the most difficult is to find correct libraries that allows to communicate with all units. Here is the list:

– Tiny RTC: Adafruit library available here

– SD Breakout: library for SD available within Arduino IDE and proposed by Sparkfun

– DHT22: Adafruit library available here

– BMP085:Adafruit library available here

We realize that high number of components also means large numbers of libraries. This can become difficult as in the number of pins available than available memory to load program and libraries. This is a parameter to take into account as soon as possible in the design.

Then it only remains to initialize the sensors by assigning the right pins, loop through the measurement and writing to the SD card. As soon as the measurement is done, ATMEGA is idle for a minute. Since we do not wake the ATMEGA via an external interrupt, we can allow only 8 seconds sleeps.We do them until a minute. The loop starts again for the next measurement. Here is the complete code that is loaded directly on the ATMEGA (scroll down to see the full code):

Packaging

It is time to make final assembly for outdoor use.

We opted for two hard plastic cases cut using the jigsaw and assembled with glue. We want to make independent the LCD screen, which would not withstand outdoor conditions, and to use it on several weather stations. The code allows to disconnect it without interrupting the measurement. And the Reset button allows to connect it at any time by restarting the ATMEGA.

For mounting sensors, one side of the box is detachable for easy access to the SD card and battery. Finally an window is made to connect the LCD screen via an IDE ribbon cable. Small holes are made on another side to allow the exchange of air between the outside and the pressure, temperature and humidity sensors. The sensors are positioned at the bottom so that the heat generated by the assembly does not interfere with the measurements. Everything is inserted under a aluminum enclosure, also cut using the jigsaw, assembled by rivets and painted white for not keep heat and distort the measurements. All joins are sealed with silicone to make the station resistant to rain.

Assembly is hung in the alu enclosure by a hook system, and the whole stuff on a tree with a strap.

User manual

  1. We insert the SD card before connecting the battery.
  2. After connecting the battery, we connect the screeb using the IDE ribbon cable.
  3. A push on RESET button allow to restart the unit and to make the screen work.
  4. A long push (> 8 sec) on SET button allows to enter setup mode.
  5. We can then set date and hour with + and – buttons.
  6. After checking all data on screen, we hot-unplugged it and we hang everything within the aluminium enclosure.
  7. At the end of measurements, we can disconnect the battery and retrieve the SD card
  8. The content of the SD card can be read onto a computer.

IMG_2423

Data are stored onto the SD card under the following format:

We can read the day, hour, temperature and pressure from BMP085, then temperature and humidity from DHT22. We can import them and plot charts automatically using the following Excel sheet : WeatherStationAnalysis.xlsm

Following improvements

The main drawback of this station is power. Many components can be supplied with 3.3V, while we supply 5V, each performing its own conversion, except for the SD card where the conversion is done via resistors. In addition, to get the 5V, we feed the LM075 with 9V. In short, a lot of losses while everythingcan be fed directly with 3.3V. But is it possible to supply a ATMEGA with 3.3V ? This is the question to solve to greatly improve this assembly.

To reduce the impact of this design flaw, we take measurements only once a minute, and during the intermediate time, ATMEGA is in a standby mode, thereby halving the current.

A final improvement would obviously to choose a clock that can wake the ATMEGA every minute, which would allow to turn off all the components for a full minute between two measurements, using the clock to provide an external interrupt.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *