Hi ! I wanted to share with you my app for temperature and humidity web monitoring.
You need reaspberry pi and DHT temperature sensor. Here is the repo https://github.com/hawkerpl/damn_hot_pie.
And the project description continues below (copy from "README.md").
Raspberry Pi DHT sensor website app
This app lets you to view your DHT readouts online in a form of interactive plot.
Sample:

(Viewing this plot may require you to push the autoscale button on plot.)
Setup
- Raspberry PI
- DHT11 sensor (DHT22 and DHT2303 are also supported, see wiringhttp://docs.gadgetkeeper.com/pages/view ... Id=7700673)
- interwebz connection
- Python 2.7
- Flask
- SQLAlchemy
- Adafruit DHT driver
- plotly
Dependencies
For web server and database dependencies requirements run:
Code: Select all
sudo pip install -r requirements.txt
The driver is accessible here:
https://github.com/adafruit/Adafruit_Python_DHT
Follow the installation instructions in the link above.
Installation
This projects runs purely as python app. As long as all the requirements are met, you don't have to install anything.
Running the project
If you are not interested in further options just run:
Code: Select all
python run_app.py
Additional options of running and project files
model.py
This file contains sql model of the database where all sensor data will be saved. Running this script will result in creating file `dht_database.db` in folder where `model.py` is.
record_data.py and recording data to database
Contains class responsible for acquiring data input and saving it in database. Can be runned separately as script. If runned, will loop endlessly and save sensor data to database with given interval.
Code: Select all
Usage: record_data.py [options]
Options:
-h, --help show this help message and exit
-p print every record to STDOUT [default: False]
-t T time interval in minutes to request readout from sensor
[default: 15]
--pin=PIN data pin connected to sensor [default: 4]
-s S number of DHT sensor in use (supported: 11, 22, 2302) [default:
11]
server.py, template/index.html and the web service
`server.py` contains flask server with web-service. The web-service hosts restful api.
Method | Endpoint | Usage | Returns
---------- | ------------- | ------------- | -------------
GET | /data/ | Get last n sensor data rows. Where n is limit given in script. | List of sensor readouts.
GET | /data/{m} | Get last m sensor data rows. Where m is given parameter. If m>n then service will return n data rows. Where n is limit given in script. | List of sensor readouts.
GET | /last | Get last sensor readout. | Sensor readout.
Sensor readout(JSON):
Code: Select all
{"date": "Y-M-D h:m:s.s", "id": id, "temperature": t, "humidity": h}
Code: Select all
{"date": "2015-09-12 11:23:25.126321", "id": 3, "temperature": 20, "humidity": 37}
`server.py` can be runned separately as a script. If so, it will set up web-service defaultly on host `0.0.0.0` and port `8080`.
Code: Select all
Usage: server.py [options]
Options:
-h, --help show this help message and exit
--port=PORT port [default: 8080]
--host=HOST host [default: 0.0.0.0]
-n N max limit of rows available by /data/ [default: 100]
run_app.py
This script combines run of `service.py` and `record_data.py`.
The recording class from `record_data.py` runs as a separate thread.
Code: Select all
Usage: you can find options info in server.py and record_data.py or by calling this script with -h options
Options:
-h, --help show this help message and exit
--port=PORT port [default: 8080]
--host=HOST host [default: 0.0.0.0]
-n N max limit of rows available by /data/ [default: 100]
-p print every record to STDOUT [default: False]
-t T time interval in minutes to request readout from sensor
[default: 15]
--pin=PIN data pin connected to sensor [default: 4]
-s S number of DHT sensor in use (supported: 11, 22, 2302) [default:
11]