Remote Meteorological Station with UDOO – pt 2: web server

Discussion in 'Other Projects' started by jey86, Jan 16, 2014.

  1. jey86

    jey86 New Member

    Joined:
    Jan 16, 2014
    Messages:
    4
    Likes Received:
    0
    http://www.youtube.com/watch?v=TzfQEwIftUw

    Hi guys! This is the second part of the tutorial for the development of the Meteo Station based and controlled with UDOO.
    In the first part of the tutorial, we are going to show you how to collect data from Arduino using PHP, then we are going to explain you how to retrive data from Arduino, using Python, allocate them in a database and print them in an HTML page using PHP.
    Ok guys, let’s start!
    All the resources of this tutorial can be downloaded @ http://udoo.org/download/files/Tutorials/meteo/meteo.zip but if you prefer you can create and edit your own files.
    So, open the sketch of the previous tutorial @ http://www.udoo.org/forum/viewtopic.php?f=30&t=818 and edit it as follows.

    Code:
    #include <dht11.h>
    char oldval='y',val='0';
    dht11 DHT11;
    
    #define DHT11PIN 13
    int led_hum = 11;
    int led_temp = 9;
    
    void setup() {
    Serial.begin(9600);
    pinMode(led_hum,OUTPUT);
    pinMode(led_temp,OUTPUT);
    }
    
    void loop() {
    val = Serial.read();
    if(val=='y')
    {
    DHT11.read(DHT11PIN);
    Serial.print(DHT11.humidity);
    Serial.print('#');
    Serial.println(DHT11.temperature);
    if(DHT11.humidity>45)
    {
    digitalWrite(led_hum,HIGH);
    }
    else
    {
    digitalWrite(led_hum,LOW);
    }
    if(DHT11.temperature>23)
    {
    digitalWrite(led_temp,HIGH);
    }
    else
    {
    digitalWrite(led_temp,LOW);
    }
    }
    if(val==oldval)
    val='0';
    }
    We' ve added two new variables for start reading data and removed the serial print that isn’t important for the sketch and insert a new if control for the reading of data:
    if data receiving from serial is “y”, the reading of data will start, else none.

    Now, compile the sketch.

    Download the library from http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html, create a new PHP document and paste the code of data_php.php that you can find in meteo.zip that you have downloaded before.

    Then open the terminal and copy the files in /var/www/METEO

    Code:
    sudo cp data_php.php /var/www/METEO
    Open the web browser and open the page create localhost/METEO/data_php.php, if you press the button refresh you can refresh the page with new data.

    So, for use Python you have to edit again the Arduino sketch:

    - cancel the if control that you have insert before and insert a delay of 5 seconds
    - compile the sketch
    - download the serial libraries for the interaction between Python and Arduino from “http://pyserial.sourceforge.net/“
    - download the MySQLdb library for the interaction between Python and MySQL with

    Code:
    apt-get install python2.7-mysqldb
    - open the Python sketch system.py that you have downloaded before in the meteo.zip file
    - create the Meteo Database from phpMyAdmin using the script table.php that you can find in meteo.zip
    - create a new Python document and paste there the code that you can find in the meteo.zip with the name data_python.php
    - open again the browser and open your data_python.php page and see the result

    Done, our UDOO powered meteo station is pretty a mature project! If you want to further develop it, stay tuned and see you in the next tutorial :)

    What do you guys think?
     
  2. livio.dalvia

    livio.dalvia New Member

    Joined:
    Feb 3, 2014
    Messages:
    3
    Likes Received:
    0
    Re: Remote Meteorological Station with UDOO – pt 2: web serv

    hello
    for this project is needed a Real Time Clock for time-storage or simply use the internet dater?
    I need a data collection each time with the same time reference, for example:
    "03/02/14 21:00:00 T = 25 ° C and HR = 80%",
    then,
    03/02/14 22:00:00 T = 25 ° C and HR = 80%",
    etc.

    Thanks for reading
    Livio
     
  3. I Hate Google!

    I Hate Google! New Member

    Joined:
    Jun 20, 2016
    Messages:
    28
    Likes Received:
    17
    NTP time is received as Lubuntoo starts up - provided it has a network connection.
     

Share This Page