This is a simple project for a weather station.
Initially it reads temperature, pressure and humidity. Next step is to measure wind direction and after that wind speed.
The base of the project is a Raspberry PI A+ which was chosen by its small consumption, since the idea was that the weather station being powered by solar power.
The OS is raspbian distro, with some off the shelve python libraries.
Main program was written in Python.
Weather station uploads all data to www.wunderground.com every 2 minutes.
Step 1: Hardware description
For the completion of the project we will need the following :
Raspberry Pi A+ (It is possible to use any model)
Temp/Pressure sensor Bosch BMP180
Temp/Humidity sensor HTU21D
10W Solar panel
7.2 Ah 12V battery
Generic 12V solar controler/charger
5V regulator 7805
Bits and bogs needed
Step 2: Setting up the basics
I will not waste time explaining how to install raspbian on a Rpi. I assume that whoever wants to build this project is profficient enough in these matters.
Anyways the link for the distributions is http://www.raspberrypi.org/downloads/
Since i own a few Rpi’s , i already have na SD image ready to roll with wireless conectivity, so it was just a question of rewriting it to a new card.
If you do not have such a “backup” it is probably better for you to use a B+ or other model with ethernet, and setup everything using one of many tutorials available.
A good tutorial for setting up Rpi is http://www.raspberrypi.org/help/quick-start-guide/
A good one for wireless is http://www.raspberrypi.org/documentation/configuration/wireless/
If everything went alright you should have now a Rpi with wireless internet access.
You still need to have your Rpi ready to use I2C protocol.
Step 3: Setting up other software
After you set up your Rpi, there are a few pieces of software needed for us to be able to read the used sensors.
I did all using Rpi “Headless” and using command line
I used Adafruit library for the BMP180, just follow the link to install it
We also need Pigpio library for Reading the humidity sensor. You can download from
http://abyz.co.uk/rpi/pigpio/download.html and follow installation instructions
After that you have to make sure that whenever you reboot the Rpi, Pigpio is also loaded. I did this by adding the following line to /etc/rc.local
In my case this is enough but this depends on where you have installed pigpio. If you run into problems, just put the whole path for the file and you should be ok.
The presented tutorials are pretty straightforward but if you need any help i’m here 😀
Step 4: Setting up the sensors
I got both sensors from Ebay, since it’s easier (and cheaper) to get ready made small boards with the sensors already soldered that to do them by yourself. If you search Ebay for BMP180 and HTU21D you will find them for sure.
These are I2C sensors which are very easy to communicate with. The I2C protocol allows you to connect several sensors in paralell and communicate with each of them because each has a unique address.
I got both soldered together with some skill , matching all signals as seen on the pictures.
The sensors will need +3.3V, GND, SDA and SCL signals from the Rpi.
You can use any wiring you like, but a 4 wire cable (telephony) is probably a nice idea.
Step 5: Main program
Main program is temp-monitor.py
You should have python installed , if not, just follow http://raspberry.io/wiki/how-to-get-python-on-your-raspberrypi/
The first part of the program shows the libraries needed.
import Adafruit_BMP.BMP085 as BMP085
Following the program we have 2 functions that will read humidity. Read_temperature is a function that will read the temperature of the HUT21D for compensation when calculating the relative humidity. It is necessary for the following function read_humidity.
There is a few calculations inside these functions, but this is all according to the sensors datasheet. Not importante stuff, but you cam always check them if you like
The cmd variable is responsible for sending the data to www.wundergroud.comusing curl. This website provides some really nice stats and graphs. You need to register (it’s free) an account to upload the data.
After that you will have an ID and a password which you sould change in the cmd variable as shown
cmd = “curl “+”‘http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=&PASSWORD=&dateutc=now&tempf=”+str((temp*1.8)+32)+”&humidity=”+str(round(humidity,2))+”&baromin=”+str((pressure/100)*0.0295299)+”&action=updateraw”+”‘”
You then have to change again /etc/rc.local and insert a line for the program to start when the Rpi is rebooted :
sudo python /usr/lib/cgi-bin/temp-monitor.py &
The & symbol is important because it will put your program into memory and releasing the command line to be used.
Step 6: Building up the solar panel
So if you have all sorted out and working well it’s time to put your weather station outside.
I chose to feed my Rpi using a solar powered system, using 3 3,5W modules bought on Ebay.
The modules output 6V, so 3 modules in series will give us 16V, which is the standard for a 12V solar system.
You can arrange them as i did and you will end up with a pretty nice small panel capable of running the system.
Probably you are thinking that 10W and a 7,2Ah battery is a bit much for the Rpi, but since i am in Ireland, i am expecting to run a few days without sun, so…
Step 7: The solar shield
I have made the solar shield from discardable plastic plates and 2 cm pieces of plastic tube. I will not go much into this since there are many ways to do this. The important thing is that the sensors are protected from wind and direct sunlight.
If you would like more details i can update with more information.
Step 8: Everything connected
With everything in place it’s time to connect things.
If you have a solar charger with a load output, it’s a good idea to use it, since usually there is a way to turn it on/off. Since we are using a 12V battery, we will need a 7805 regulator to reduce to 5V for the Rpi. If you look to the 7805 with the markings facing to you, the left pin is the input(connect it to 12V) , the middle one is GND, and the right one is the output (5V).
You can connect your 5V to the usual Rpi connector or directly to its header, in this case, pin 2 or 4.
The solar charger has connections for the battery and for the solar panel. Make sure that you connect always the battery in the first place.
It’s time to connect the I2C, which are pins 3 and 5 (SDA and SCL) and pins 1 and 9 (+3.3V and GND)
Power up the Rpi, check that everything is running well and close your box 😀
Step 9: Final thoughts
This is my first tutorial so please excuse me for anything that you do not like.
I appreciate comments and improvements.
This is a basic setup and will be improved with a few more sensors
I leave you with the link of my weather station