Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 119 lines (79 sloc) 3.13 KB


temperature-pi is a simple Raspberry Pi based temperature logger using a DS18B20 1-Wire digital temperature sensor, & a local sqlite database. It's based on the php-gpio PHP library


Installation (hardware)

DS18B20 sensor connection

Read this very easy-reading tutorial on the Cambridge University CompSci Laboratory Raspberry Pi dedicated pages.

Then install the DS18B20 on your bread board, wired to the #4 gpio pin, following the tutorial indications.

Then add a led & a resistor wired to the #17 gpio pin.

Circuit snapshot

Installation (software)

The recommended way to install temperature-pi is through composer.

Just create a composer.json file for your project:

     "require": {
        "php": ">=5.3.0",
        "ronanguilloux/temperature-pi": "master-dev"

And run these two commands to install it:

$ wget
$ php composer.phar install

Oprionnaly, allow the vendor/ronanguilloux/php-gpio/blinker file to be run without sudo: Edit your /etc/sudoers file:

$ sudo visudo

Then add this two lines in your /etc/sudoers file : (replace MyLinuxUser with your login name & change the path to the blinker) This will allow you and Apache2 to run the blinker without sudo

MyLinuxUser ALL=NOPASSWD: /path/to/blinker
www-data ALL=NOPASSWD: /path/to/blinker

Set up the sensor

Using the shell, manually add theses kernel modules:

$ sudo modprobe w1-gpio
$ sudo modprobe w1-therm

To load such kernel modules automatically at boot time, edit the /etc/modules file & add these two lines:


Run a cronjob & log temperatures

Run the executable php file to record temperatures

$ thermometer

To trace temperatures chages, add this into your crontab to log the temperature through the day, each 30 minutes

0,30 * * * * /my/path/to/the/temperature-pi/thermometer >> /my/path/to/the/temperature-pi/resources/log

Get a graph

To get the graph, run this app as a webserver

$ php -S "`hostname -I`:8080" -t web/




temperature-pi is released under the MIT License. See the bundled LICENSE file for details. You can find a copy of this software here: