ThomasH
Posts: 5
Joined: Wed Mar 06, 2013 9:06 pm

1-Wire Sensor using Database

Wed Mar 06, 2013 9:28 pm

This is my first project on the raspberry and the first one utilizing Python.

Objective is to read multiple 1-wire sensors and store the temperatures in a Database.
As my raspberry is running headless (just power and LAN), the data needs to be presented by a web-server.

People starting with Databases may get some thoughts for their projects.

Prerequisites:

Webserver
PhP5
MySQL Datenbase
phpMyAdmin
For the graphics: JPGRAPH
I am recommending to use MobaXterm for accessing the raspberry from a Windows PC.
much more convenient than putty

1-Wire Sensors

The program was written in Python and does contains the following files:

avrio.py the main program
avrio_database.py a module with all functions for the database
avrio_html.py creating a HTML file out of Python
avr-graph.php this PHP-Script is reading the database and generating a nice graph
avrio-writedb.sh a little shell script which called from cron job

If you execute avrio.py the first time, it ask for the main parameters and create a configuration file (avrio-config.txt), e.g. user/Pw for MySQL and paramters for the database.
Next it will create the database and the table.
If sensors are connected these are listed and added to the configuration file.


Utilizing the an editor like nano you need to assign the sensor to a location.

Starting the main program w/o any parameter will read the sensor and write the temprature into the database
> python avrio.py

Data can be displayed by various ways:
Using the command line and read the last three lines from the database
> python avrio.py -r 3


Calling a web site generated by the program:
> python avrio.py -w
open the html file in the browser http://192.168.178.60/avrweb/avr-single.html

Showing the graphic by opening the php code
http://192.168.178.60/avrweb/avr-graph.php

Hardcopies can be found here: http://www.hoeser-medien.de/?p=291
Attachments
avrio.zip
(7.84 KiB) Downloaded 295 times

migube
Posts: 29
Joined: Tue Jul 17, 2012 7:02 am

Re: 1-Wire Sensor using Database

Sat Aug 24, 2013 8:18 pm

Hi Thomas

would you have a new version, before I dig into it ?:)
tx

stevethelizard
Posts: 4
Joined: Fri Jul 13, 2012 1:02 pm

Re: 1-Wire Sensor using Database

Mon Oct 28, 2013 10:12 pm

Hi thanks for a great script. I’m having problems getting the cronjob to work any ideas where I would start looking for a solution.
thanks
Steve

Tafkas
Posts: 49
Joined: Sun Sep 16, 2012 11:15 pm
Contact: Website

Re: 1-Wire Sensor using Database

Mon Nov 04, 2013 12:49 am

Interesting idea. Instead of a MySQL db i would recommend rrd-tools. I used a similar approach for recording temperatures in my appartment. The charts are generated on the client side using JavaScript. I also wrote a summary of how I did it.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 11 guests