A weather station Raspberry Pi with a web interface

When I bought my first Raspberry Pi there it 10 months now, I wanted to use it to make software. By dint of reading on various sites and forum, Electronics has begun to make me want to. Today, We will therefore go together my first project : a weather station with wireless sensors.

weatherSo why a weather station. It is certainly the project the more common and less original that can be found ! Each is in his capture system, its probes, its storage. But the principle remains the same : how it is in your House/apartment or outside.

I've therefore defined my need :

  • Measuring indoor and outdoor temperature
  • The probes must communicate wirelessly. No question for Madame to see wires in all directions just to have shown c.

My research led me on This post, very well done and is used to 90% for my weather station with Raspberry Pi. The components are simple to use, a little pricey but for a ultra novice like me, It helps to reassure in these first not. So here is what I ordered at Ciseco :

  • 3 x XRF wireless RF radio UART RS232 serial data module XBee shape (29.70£ the three)
  • 2 x Sensor – Temperature XRF development sensor – THERMISTOR (14.16£ both)
  • 1 x Slice of pi – Add on for Raspberry PI (3.25£ the unit)

It is therefore a sum of £ 47.11, more £ 10 postage and the bad surprise VAT to add amounting to £ 11.42. A total of £ 68.53 or €80. Ouch. I find it a bit expensive for only two probes but I was almost certain to arrive at the end !

Here is what I wanted to happen :


Once the material received, It took

  • assemble the main Board Slice Of Pi : all the news here
  • Configure each transmitter XRF : all the news here
  • assemble probes and configure them to communicate : all the news here

The first tests showed temperatures. A great success in itself ! 🙂

Premiers essais d'affichage avec la station météo Rapsberry Pi

First trials of display with the weather station Rapsberry Pi

The next step was the automation of the recovery. For this a Python script (a first also) turns loop to scan the arrival of temperatures. The script is available here. It loads all the news (including the level of the battery) in a SQLite database (always a first for me accustomed to Oracle or jBase).

Storage of the data is ongoing, It remains the representation of this information into something not too Dork. Not a lot of choices but I went on a simple web interface with the framework bootstrap and highcharts to make this a little more sexy Raspberry Pi weather station.

The Web server is a classic with NGinx with PHP support (tutorial to install it on this page). The configuration of the site which is on port 80 my home is as follows :

server {
  listen 80;
  root /var/www;
  index index.php;
  server_name localhost;
  location / {
    try_files $uri $uri / index.php;
  location ~ .php$ {
  fastcgi_pass unix:/var/run/PHP5-fpm.sock;
  fastcgi_index index.php;
  include fastcgi_params;

The website it even contains only a single page. Graphics top, the ephemeris and the steps down. I tried to make it generic so the addition of a new probe, as soon as it is inserted into the table transmitters in your database, It should appear under graphics.

Finally the ephemeris. For this I get the weather France home page to retrieve the feast of the day, the hours of sunrise and sunset the Sun and the Moon. All via a Python script run every day at 2 o'clock in the morning via crontab (Download the script)

A possible change would be to add a zone for forecasting but it was not the original purpose.

[EDIT] C’était pas le but initial mais je suis quand même en train d’ajouter les informations de Open Weather sur un nouveau graphique 🙂

[EDIT2] The script to update the ephemeris has been redone thanks Jimmy. The new layout of weather France is now managed. Thanks to him !

Here is the result (current) final :


The entire site is in This archive, including the database, an init script, python scripts and images.

Small notes for the moment :

  • No atmospheric pressure and humidity. It would be nice to have this information and more.
  • Need to connect to have the information. A Madam is having a screen somewhere that displays information on. For the moment I do not know if it will be possible with the Slice Of Pi on the Raspberry card. C’est l’étape suivante 😉

So if you also want to get started, n’hésitez pas 🙂 Pour l’instant c’est satisfaction totale à la maison 🙂

[EDIT] The photos of the probes are here

You may also like...

59 Responses

  1. Yaug says:

    For moisture a probe DHT22, for pressure, a BMP085 probe.
    Easy to mount on the pi raspberry. After, for mounting externally, It's going to ask a bit more tinkering.

    In all cases, Nice project.
    But it lacks photos :p

  2. ss814 says:

    Bravo !
    I am trying to make me sick to do not have the budget to get in to the elec me also, but precisely, with respect to the screen; on a shoestring, Why not take a screen for car like for example : http://www.amazon.com/dp/B0045IIZKU ?
    It remains just to display the web rendering on the screen with a script at startup which would launch an X server then that would load an instance of firefox with the localhost home page.

  3. Sheetal says:

    If you are looking to recover info on weather or forecasts, viewing this side there : http://openweathermap.org/

  4. Blackmam3a says:

    I browsed your script diagonally ! PHP manages very well the dates (http://php.net/manual/fr/function.date.php), What can relieve some of your code, and if you want to have the name of the days in French : setlocale (LC_ALL, “en_US”); (It is necessary to have the FR locals on your raspberry).

    Otherwise great job !

    • chris says:

      I struggled on this point and the solution irritates me because with the local ca would have been simpler. But no way with my installation July is never reflected in July !

      • Blackmam3a says:

        I currently use it on my RPi and it works :).

        First viewing that look back setlocale (LC_ALL, "en_US".), If it is false, is that you have not enabled the local on your RPi.

        Under Arch, We must go to the file /etc/locale.gen and uncomment the fr_FR.* variables and do a local-gen (to download) If my memories are good.

        I don't use debian but it must be pretty much the same thing.

        • chris says:

          Possible actually that ca is not configured. Under Debian there is a dpg - reconfigure or something in the genre to do.
          Watching it tonight. Thanks for the info

          • Blackmam3a says:

            No worries, very few people use setlocale() but rather a table…

            Otherwise to draw graphics, you're full of JS libraries to do including Chart.js (to minimize external queries).

          • chris says:

            I like highcharts which pretty efficient and I think not too heavy to load. And since it is for local use …

  5. Support says:

    “A total of £ 68.53 or €80. Ouch. I find it a bit expensive for only two probes but I was almost certain to arrive at the end !”

    I quite agree, It seems too high bcp. It would be almost more profitable to buy A rasbperry and probes connected to the GPIO. I caricature but I think the parallel is speaking.

    • chris says:

      Yes it is certain that it would be cheaper. The XBee for the without wire will be a little more expensive but via GPIO it should fast save. Only problem is that it is more technical bcp for a beginner to create its own wireless sensor. I found nothing on the internet that is simple and understandable both in French and in English. Hence this solution which for me is very suitable for those who like me do not understand electronics.
      We need to acknowledge that, besides the price and non-scalability, their temperature is top because it has the housing, the food and the card have unen probe 5 minutes.

      • Support says:

        Excuse me I expressed myself badly. The solution seems to me quite well thought-out and viable, but I wanted to especially pointed to the prices of components which seems high compared to components more “complete” a priori.

        Maybe there is a way to find the same for less.

        PS : I think I read all your articles and I appreciate them.

        • chris says:

          There was no worries. I am agree with you. When you you know a little is a way. This is the side wireless which has hot air to achieve.

  6. jed59 says:

    Bravo, beautiful realization.

    Why choosing wireless RF radio place the Transmitter/Receiver 433 Mhz XRF ? (reliability, scope, simplicity of development, …).
    What is the scope of internal and/or external receivers, the duration of battery life !

    J’ai hâte de voir les photos 🙂

    • chris says:

      As I explained in the article I know nothing about electronics so this module is easy to use and manufacture. For the scope I believe it is 30 m indoors and slightly more than 90 outdoor.
      And for the battery is a little more than a year for a measure all the 5 minutes.

  7. m2i says:

    Instead of sqlite, uses rrdtool.
    Your data files do not grossiront in time.
    I have 4 identified on 10 years in 3 MB
    RRDtool exists for multiple languages (python and php) and lets do graphics

  8. Yamdar says:


    Thanks for this article.

    I put in place following this article among other, 2 probes home.

    I have however a concern and is unable to find the solution.

    The 2 probes return me different values. in a room at 24 ° c , one of probe returns me one 24 ° surroundings and the other 27 ° but varies enormously.

    That gives me the 24 ° c answer me once all the 6 values, something more exotic like 27 ° c and then after go down on the 24 ° c.

    am I the only one having this problem ?

    How to standardize these probes ? I try to understand the function “aXXRNOM” that is supposed to define the 25 ° but does not achieve.

    Thanks in advance for your answers.

    • chris says:

      The changes are really weird. The probe has not taken a hit during Assembly ? I've never done the calibration. Can be with the help of the forum at ciseco …

  9. Acilnos says:


    Thanks for this site really very informative and these articles on well-designed Pi.

    I am currently working on a home automation project which aims to replace the thermostat of my heating. I have managed to do by following your tutorials. (recovery temperature a little electronics for triggering or not heaters).

    Wanting a little more push my project I attempted to put a web server (nginx sqlite) to have a chart as your. I have therefore download the archive available on this page but I blocked on the display of the chart that apparently is not in the code of the page index.php.

    Can you help me on this point?

    Thanks in advance

    • chris says:

      Good evening,
      Is there any way to have the errors returned by the web server ? It is true that the sample may be unclear to install.

      • Acilnos says:


        Merci de m’aider 🙂

        I did not error in the browser, well I had the carousel but no graphics inside. I think that the part of code corresponding to the java script to create the graph0 and Chart1 is missing in the archive.

        I have however managed to have a chart by examining the highcharts doc but I have difficulties to operate the data in the table created by the create_graphic function.

        • chris says:

          It is true that the manipulation of data in HighCharts is not obvious but the result is worth the effort ! 🙂

        • Benoit91 says:


          Thanks much for your site, j’ai quasiment terminé le projet 🙂
          the monitor script runs well, I retrieves data in the SQlite Database

          I still have a problem with the website, the framework displays correctly but no data is displayed… someone just help me ?

          merci d’avance pour vos commentaires 😉

          • chris says:

            If you can look in the console of the browser if there is errors ? Otherwise make a beast page that displays the result of a query to test the connection to the db

          • Benoit91 says:

            Hi Chris,

            merci pour ta réponse rapide 🙂
            I found the problem, the connection to the db was ok but I had not changed the id of my transmitters on the transmitters…. suddenly there was nothing to display…
            now it shows well the sensor data, cool !

            I still have a little trouble of differences within hours of capture. An example is better that a long talks :
            It is 12: 00, registered measuring 11 h in the db, the web site displays 13 on the sensor and 2 pm on the graph…

            My ntp is correctly configured, my local linux is configured in Fr

            an idea ?

          • chris says:

            I think that there must be a history of recording format. I just looked and I also have problems of dates … The hour delay of the registration must be compensated at every stage what makes ca moves from hour to hour. Je vais regarder pour enregistrer des heures locales et non UTC ou GMT ou je sais pas quoi 🙂

  10. Van den Bliek Jimmy says:

    I changed the ephemeride.py script to retrieve the values following the change of site Météofrance design. Though it might interest someone, Here are the lines to change. The amendment will first line m = re.search, up to the third line of this kind.

    m = re.search(' Lever : (.+?) Coucher : (.+?) ', line)
    if m:
    SolLever = m.group(1)
    SolCoucher = m.group(2)
    m = re.search(' Lever : (.+?) Coucher : (.+?) ', line)
    if m:
    LuneLever = m.group(1)
    LuneCoucher = m.group(2)
    m = re.search('(.+?)', line)

  11. Van den Bliek Jimmy says:

    Good evening, just a quick question. Not being a pro at using HighCharts, I would like to know if there is a way to stop the automatic carousel. I would like to just let the arrows left and right but no longer have animation. An idea? Thank you.


  12. Darki03 says:

    Good evening,

    First of all thanks for this achievement that have allowed me to not start from scratch. I have adapted the–CI for use with a sensor temperature and pressure BMP085 in I2C on the rPI.

    After having spend a bit of time in the configuration of the site, everything works. However after some time the sql database becomes increasingly voluminous and each access to the web interface crashes python script that runs in the background, I find the error in the nohup.out “Error database is locked”.

    It would seem that, because of the size of the base, the php script put more time to retrieve the data and that the python script accesses write the base during this time where a conflict (the python script connects to the sql database to register a value all the 30 seconds).

    Did not notice you this problem ? have I missed something ?

    Perhaps it provide a cleaning the base script ?

    Thank you in advance.

    • chris says:

      Not this kind of worries me except once when the base was with a lock. The size of the database at the end of 6 month is on the 12 MB I believe

  13. Blabla51 says:


    This is the problem, Indeed, a SQLite database supports only a single connection to the database.

    I'm only passing, but I also developed a unit of home automation with a SQLite database, but I have a different process.
    Let me explain: the base accepting a single connection, to avoid a conflict, I send a http request to the server locally, in order to make the processing of data in php, and send them to the database through the web server (I personally use Lighttpd)

  14. Dalarwin says:

    First of all thank you very much for your articles that have me well helped.

    For the part recovery and storage in base temperature values, I used your python script.
    However I modified to work with python3 and I modified the way to handle dates and times.

    In the console I use localtime() to display the local time, not UTC
    and in the database I stock the value returned by time() (number of seconds since 1970) because I find (This is just my opinion) that is easier to handle then.

    If you are interested, I can send you the code.

    Thanks again

    • chris says:


      Yes I'm interested. I've corrected this problem on the recorder interface but not on the weather. And actually the timestamp storage provides more manipulations (as tris).
      Thank you for your help

  15. Dalarwin says:

    I put the files here:

    Thereafter I try to display everything on a small screen TFT directly connected to Pi.
    I'll keep you informed when I have managed.

  16. Paztrick Prud'homme says:

    I may be a little behind on this project …
    But finally I have some worries surely due to my lack of skills
    My probes work well but the display wonder problem !
    What is the procedure to start the web site from archive ?

    Thank you

    • Chris says:

      It is necessary to have installed Nginx, unpack the archive and its contents to the root defined in your installation of Nginx. With ca there must already be a display. To power the SQlite Database is the python script to the root that will recover the serial port to send in the database.

  17. Paztrick Prud'homme says:

    nginx is installed and running, I put the archive in/var/www the python script works too though I have order a bit abruptly and I have can be rebuild it.
    I have a white screen when I open a window on the raspberry with still a title of the weather raspberry pi genre .

    • Chris says:

      That gives the Nginx log in/var/log/nginx ? What is PHP is properly installed with php5-fpm ?

      • Paztrick Prud'homme says:

        PHP is installed but I have an error log :

        2014/12/06 17:56:56 [error] 5494#0: *60 FastCGI feels in stderr: “PHP message: PH
        P Fatal error: Class ' SQLite3’ not found in /var/ www/index.php on line 235” WHI
        reading response header from upstream, client:, server: localhos
        t, request: “GET / HTTP/1.1”, upstream: “FastCGI://UNIX:/var/run/PHP5-fpm.sock:”
        , host: “pitemp”
        2014/12/06 17:56:56 [error] 5494#0: *60 FastCGI feels in stderr: “PHP message: PH
        P Fatal error: Class ' SQLite3’ not found in /var/ www/index.php on line 235” WHI
        reading response header from upstream, client:, server: localhos
        t, request: “GET /bootstrap/ico/favicon.png HTTP/1.1”, upstream: “FastCGI://UNIX
        :/var/run/PHP5-fpm.sock:”, host: “pitemp”

        • Chris says:

          The sqlite3 package is not installed. Look in the instructions for installing the required packages

          • Paztrick Prud'homme says:

            Still I was able to created a database according to your indications …

          • Chris says:

            Forgiveness, wrong answer : This is php5-sqlite package which must not be installed.

          • Paztrick Prud'homme says:

            Thank you , This time I have a screen , I guess that now it takes the database fills to temperatures that are displayed !!
            Thanks again for this interesting project.
            ( I have not found php5-sqlite in the tutorial however )

          • Paztrick Prud'homme says:

            I tried to run monitor.py manually unfortunately !!!
            Here is the result !
            INSERT INTO Mesures VALUES('YY', 10.66, ' 2014-12-07 12:32:10.000’);
            Traceback (most recent call last):
            File “./monitor.py”, line 48, in
            except lite.Error, e:
            NameError: name ' lite’ is not defined
            I have the impression that nothing is finished !!
            I also tried to fill the bd with what is defined in the tutorial !!
            It also does not work !!

          • Chris says:

            I use it at home so it's ended.
            I've updated the monitor.py script. Replace lite by sqlite3

  18. Paztrick Prud'homme says:

    It's me again :
    Traceback (most recent call last):
    File “./ephemeride.py”, line 38, in
    sql_command = “INSERT INTO ephemeris VALUES(‘”+today ”‘,'”+ Party”‘, ‘”+SolLever ”‘, ‘”+SolCoucher ”‘, ‘”+LuneLever ”‘, ‘”+LuneCoucher ”‘);”
    NameError: name ' feast’ is not defined
    I tried many things like creating in the database an ephemeris record but the I despair to define day and subsequently elsewhere ….;

    Thank you for your enlightened help

    • Chris says:

      Weather France has (yet) changed the format of the index file. I have an error but not on the feast. We must review research in Python in the downloaded file. Regular expressions are not result so the variables are not defined.
      To resolve the errors you can add the block before the opening of the index.html file
      SolLever = ""
      SolCoucher = ""
      LuneLever = ""
      LuneCoucher = ""
      Fete = ""

      But for the values you have to change the script

  19. Jérôme says:

    I'm looking for a few to do the same as you , except that I have a ds18b20 sensor and a sensor dht. I have nginx, PHP and sqlite executed. I have a database that retrieves measures.I wanted a little bit edited your index.php to fit my needs. But I do not know too much what change. Could you help me please. Should I modify other files. Thanks in advance.

    • Chris says:

      I am trying to make a system more “modular” avec des sondes sans fil mais ca n’est pas pour tout de suite qu’il va y avoir tous les articles pour le réaliser 😉
      If you want to use this system, look in the sources, There must be enough comments to understand the outline but be careful, je n’ai pas de formation de développeur donc soyez indulgent 😉

  20. Jérôme says:

    Thanks for your reply. Do you want to talk about the sources of the index.php file ? Thanks in advance

    • Chris says:

      Yes. The file will read the entries in the SQLite database to generate graphics. See if adding “simply” your measurements in the table ' measures’ will this be enough to render level
      But everything is in the index.php file. The other files for the template and a few scripts (memory)

  21. Jerome says:

    I tried to use your ephemeris code by modifying it a little : https://drive.google.com/file/d/0B58x2helAgOdbTNpenBxUGFKcUE/view?usp=sharing

    I get this error:

    File “ephemeride.py”, line 32, in
    sql_command = “INSERT INTO ephemeris VALUES(‘”+today ”‘, ‘”+ Party”‘, ‘”+SolLever ”‘, ‘”+SolCoucher ”‘, ‘”+LuneLever ”‘, ‘”+LuneCoucher ”‘);”
    NameError: name ' SolLever’ is not defined

    would you have an idea ?

    Thanks in advance