Sign inSign up

thawn/pitemplog

By thawn

•Updated over 4 years ago

Online raspberry pi temperature sensors

Image
0

1.2K

thawn/pitemplog repository overview

⁠Online raspberry pi temperature sensors

This web app is a frontend intended to run on a raspberry pi equipped with temperature sensors that are addressed via the 1 wire protocol. The hard-and software setup was inspired by ModMyPi⁠. Thanks a lot for that great tutorial.

Check out the GitLab tags page⁠ for releases and sd-card image download links.

Jump directly to:

⁠Features

  • Data logged in partitioned mysql database -> fast access even if millions of data points are stored
  • Responsive web frontend based on bootstrap and jQuery -> optimized for desktop and mobile clients
  • Adaptive charts powered by amCharts javascript library
  • Export charts as png or svg
  • Download selected (or all) data as CSV
  • Static html pages and javascript generated by jekyll -> good performance because most code is run in client browser not on raspberry pi
  • Easy software setup via ready to go raspbian-lite-based image
  • Simple and expandable hardware setup
  • Low power consumption by raspberry pi
  • Flexible and easy setup of data sharing between several raspi sensor hubs so that all data can be visualized via one web frontend and data is backed up between several raspberry pi systems.
  • Backup of data and configuration via rsync to centralized server possible with minimal configuration effort via backup scripts.

⁠Screen shots

⁠Overview Page for Multiple Sensors

Overview Page for Multiple Sensors

⁠Frontend Desktop

Frontend Desktop

⁠Frontend Mobile

Frontend Mobile

⁠Frontend Tablet

Frontend Tablet

see also the configuration screenshot⁠.

⁠Hardware setup

⁠Material

parts

  • Raspberrypi 2 or 3 Model B
  • SD card with at least 2GB capacity
  • External usb harddisk (or a usb stick that uses wear leveling). If you don't want to use an external harddisk use the "nousb" image.
  • One-wire digital thermometer(s): DS 18B20
  • 4.7K Ohm resistor
  • 3x jumper contacts (or 2x 2W 245 PSK plug)
  • min 2x 3-pin matching plug and socket (you'll need one more set than the number of sensors you want to connect, i.e for two sensors you need three, for three sensors four etc.)
  • Cable with three wires
  • soldering equipment
  • shrink-on tubing
⁠Assembly

All soldering points should be insulated with individual shrink-on tubings. Then add one large shrink-on tubing around to protect and keep the wires together.

  1. Connect one of the 3-pin plugs to the raspi (see picture below⁠):
    1. wire 1 (black) to ground (PIN9 on the Raspi GPIO pins⁠)
    2. wire 2 (brown) to BCM4/GPIO4 (PIN 7)
    3. wire 3 (red) to 3.3V Power (PIN 1)
  2. Add the 4.7K Ohm resistor between 3.3V and BCM4/GPIO4 (PIN1 and PIN7)
  3. Solder the wires of the cable to the thermometer (see picture below⁠ Note: In the front view of the sensor (on the left of the image) the pins are facing towards you). In this example, the cable has white green and red wires. For example:
    1. white to pin 1: GND
    2. green to pin 2: DQ
    3. red to pin 3: VDD
  4. solder the other end of the cable to the 3-pin socket:
    1. White to pin 1 (corresponds to black wire on the plug)
    2. green to pin 2 (corresponds to brown lead on the plug)
    3. red to pin 3 (corresponds to red lead on the plug)
  5. solder the wires of another plug parallel to the socket (see picture below⁠):
    1. black to pin 1
    2. brown to pin 2
    3. red to pin 3

Now you can connect many thermometers to the raspi as each thermometer will add its own plug such that all thermometers are connected in parallel. Theoretically, you can add as many thermometers as you like (at least several tens of thermometers should work) and the cables can be tens or even more than a hundred meters long. In my setup I successfully tested up to 5 thermometers with a total of 50 meters of cable. However, at some point too much cable will deteriorate the signal so much that thermometers are not found any more or randomly disappear. See here for recommendations on setting up large sensor networks⁠. Check out the picture of the final assembly⁠.

⁠Connect to Raspi

connect to raspi

⁠Sensor Pinout

sensor pinout

Note: In the front view of the sensor (left) the pins are facing towards you.

⁠Assembled Sensor

assembled sensor

⁠Final Assembly

final assembly

⁠Configuration

  • In a browser enter the ip address or the hostname of the raspi
  • If this is the first time that you contact the raspi, you will be redirected to the configuration page. If you are not redirected, click on "Configuration" in the top right corner.
⁠Local sensors

If there are sensors attached directly to the raspi, there will be empty configuration fields for each sensor.

Just add a name, a database table and a category to each sensor and hit the save button for each senosr (or just press enter while the cursor is in a configuration field) or hit "Save entire configuration".

Now the raspi will start logging data from each sensor every minute.

⁠Screenshot

Database and Sensor Configuration⁠

⁠External sources/targets

There are three ways to exchange data with external sources/targets:

⁠Fetch data:

The server will actively fetch data from an external source every minute. The external source can be another pitemplog box or any source providing a web interface or api. In the latter case, you need to provide a parser that scrapes the data from the external source. An example parser for mibi sensors (mibi.php) is provided in the parsers directory.

To configure fetching data, enter the URL and a name for the external sensor box. If the external box requires a username and password, you can enter those as well. If the external source is not a pitemplog box, you must choose a parser (a parser for mibi sensors is provided).

⁠Send data:

The server will send temperature data from locally attached sensors to an remote pitemplog server in regular intervals. Before sending data, the remote server needs to be configured in order to be able to receive the data. The configuration happens almost entirely automatically. For security reasons, the only manual step required is to copy the api key generated by the remote server to the configuration here.

To configure sending data, enter the URL and a name for a central server that is running pitemplog. Once the connection is set up, the temperature data of all local sensors will be regularly uploaded to the server.

After you have saved the configuration, you will be redirected to the remote servers config page where you can copy the api key and paste it into the senders push server configuration. Without correct api key, no data will be stored by the central server.

⁠Receive data:

The server will passively wait for input from an external source. In order to be able to receive data, this server must be properly configured. If the external source is a pitemplog box, the configuration is done automatically by the sender (see "Send data" above). If you want to send data to this sever from a different source (i.e. an arduino sensor), then you can configure the sensor id, name, table and category here.

To configure receiving data, configure the source url (or unique id of source), the source name, the sensor id (must be unique and start with "custom-"), name, table and category. Once you are done, an api key will be automatically generated and you need to copy that to the sender in order to prevent anyone from pushing data to the server.

⁠Screenshot:

Receive Push Configuration

The external source must provide the data to "http://pitemplog.domain/data.php⁠" in the following structure (all arrays must be of the same length):

"apikey":
"api key from the server config page"
"sensor":
[array of sensor id strings]
"time":
[array of 10 digit unix timestamps]
"temp":
[array of floating point temperatures in ˚C]
⁠Screenshot

External Source/Target Configuration

⁠Database

In case you would like to change the database configuration: this is done via the environment variables:

  • DB_HOST (hostname of the database server)
  • DB_DB (name of the database)
  • DB_USER (a user that has access to the database)
  • DB_PW (the users database password).

⁠ToDo

  • Write selenium tests.
  • Add support for vibration sensors
  • Add support for LoRaWAN sensors

Tag summary

Content type

Image

Digest

Size

184 MB

Last updated

over 4 years ago

docker pull thawn/pitemplog