README 2.86 KB
Newer Older
julric's avatar
julric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
AirPi
========

A Raspberry Pi weather station and air quality monitor.

This is the code for the project located at http://airpi.es

Changes to the original code
-----------------------------

* run as a cron-job
* added mysql-support
* added rrd-support



CRON support
-------------

It is important to set the absolute path in airpy_cron.py:

    os.chdir("/path/to/airpi_cron.py/")

To run the script every 2 minutes, you have to add the following 
line to your crontab a root:

    crontab -e

    * * * * * python /path/to/airpi_cron.py >> /path/to/airpi.log 2>&1



MySQL support
--------------

You need to set your MySQL-settings in outputs/sql.py:

    conn = MySQLdb.connect(host= "127.0.0.1", user="airpi", passwd="airpi", db="airpi")

Additionally you have to add the following lines to your outputs.cfg:

    [MySQL]
    filename=sql
    enabled=on

Your database should look like

    CREATE TABLE `obs` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `Station` char(8) COLLATE utf8_bin DEFAULT NULL,
    `Datetime` datetime DEFAULT NULL,
    `Temperature` float DEFAULT NULL,
    `Pressure` float DEFAULT NULL,
    `Relative_Humidity` float DEFAULT NULL,
    `Light_Level` float DEFAULT NULL,
    `Nitrogen_Dioxide` float DEFAULT NULL,
    `Carbon_Monoxide` float DEFAULT NULL,
    `Volume` float DEFAULT NULL,
    `Wind_Direction` float DEFAULT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COLLATE=utf8_bin


RRD support
------------

If you built your AirPi as suggested on http://airpi.es , no customization on outputs/rrd.py is needed.
The only thing you have to do, is adding the rrd output to your outputs.cfg:

    [RRD]
    filename=rrd
    enabled=on
    rrd_file=rrd/data_airpi.rrd

The parameter rrd_file points to your rrd, generated with the following commands:

    rrdtool create /srv/airpi/data_airpi.rrd --step=120 \
    DS:tempbmp:GAUGE:180:-273:5000 \
    DS:tempdht:GAUGE:180:-273:5000 \
    DS:press:GAUGE:180:U:U \
    DS:humi:GAUGE:180:U:U \
    DS:light:GAUGE:180:U:U \
    DS:no2:GAUGE:180:U:U \
    DS:co:GAUGE:180:U:U \
    DS:vol:GAUGE:18:U:U \
    RRA:AVERAGE:0.5:1:3200 \
    RRA:AVERAGE:0.5:6:3200 \
    RRA:AVERAGE:0.5:36:3200 \
    RRA:AVERAGE:0.5:144:3200 \
    RRA:AVERAGE:0.5:1008:3200 \
    RRA:AVERAGE:0.5:4320:3200 \
    RRA:AVERAGE:0.5:52560:3200 \
    RRA:AVERAGE:0.5:525600:3200 \
    RRA:MIN:0.5:1:3200 \
    RRA:MIN:0.5:6:3200 \
    RRA:MIN:0.5:36:3200 \
    RRA:MIN:0.5:144:3200 \
    RRA:MIN:0.5:1008:3200 \
    RRA:MIN:0.5:4320:3200 \
    RRA:MIN:0.5:52560:3200 \
    RRA:MIN:0.5:525600:3200 \
    RRA:MAX:0.5:1:3200 \
    RRA:MAX:0.5:6:3200 \
    RRA:MAX:0.5:36:3200 \
    RRA:MAX:0.5:144:3200 \
    RRA:MAX:0.5:1008:3200 \
    RRA:MAX:0.5:4320:3200 \
    RRA:MAX:0.5:52560:3200 \
    RRA:MAX:0.5:525600:3200

For more information about rrdtool and rrds look at http://oss.oetiker.ch/rrdtool/index.en.html