{"id":19994061,"url":"https://github.com/kapsner/raspi-temperature","last_synced_at":"2026-05-14T02:31:48.432Z","repository":{"id":45623120,"uuid":"497635981","full_name":"kapsner/raspi-temperature","owner":"kapsner","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-14T11:51:09.000Z","size":1503,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T23:36:29.978Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kapsner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-29T15:50:34.000Z","updated_at":"2022-07-14T01:05:42.000Z","dependencies_parsed_at":"2022-07-31T15:39:03.218Z","dependency_job_id":null,"html_url":"https://github.com/kapsner/raspi-temperature","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kapsner/raspi-temperature","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapsner%2Fraspi-temperature","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapsner%2Fraspi-temperature/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapsner%2Fraspi-temperature/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapsner%2Fraspi-temperature/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kapsner","download_url":"https://codeload.github.com/kapsner/raspi-temperature/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapsner%2Fraspi-temperature/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-27T02:00:05.795Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:53:55.860Z","updated_at":"2025-11-27T03:08:07.691Z","avatar_url":"https://github.com/kapsner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# raspi-temperature\n\nThis repo contains instructions and scripts to setup a DS1820 temperature sensor on a Raspberry Pi Model B using docker, influxdb and grafana for visualization.\n\nThe original instructions I followed almost 10 years ago can be found [here](https://www.kompf.de/weather/pionewiremini.html) - some part, especially the python part to read the temperature from the sensor, is still taken from there.\n\nHowever, the setup has been revised in 2022 to A) move the deployment to docker containers and B) to use [InfluxDB](https://www.influxdata.com/) as a time-series database (instead of a round-robin-database) and [Grafana](https://www.influxdata.com/) for visualizing the captured temperature data.\n\nNote: As I found out during this project, the last version of InfluxDB to work with `armv7l` is 1.8. Whereas InfluxDB \u003e= 2 provides a web-interface including visualization of the data, this is not the case so Grafana as a visualization tool is required here.\n\nThe setup consists of three docker container:\n\n* tempmanager: with python 3.6 (miniconda) installed and mounting `/sys/bus/w1/devices` into the container in order to be able to caputure the temperature\n* influxdb: running on port 8086 for storing the time series data\n* grafana: running on port 3000 for visualizing the temperature data\n\nA prerequisite for this instruction is to know how to initially install raspbian and how to connect to your raspberry via ssh - there are lots of tutorials out there in the www covering these aspects. Furthermore, docker is expected to be installed on the raspberry as well. The raspberry pi should also be available in your network.\n\nThese instructions do not cover any aspects of IT security.\n\n## Setup: Temperature Sensor\n\nThe temperatur sensor DS1820 is to be connected as follows:\n\n* green cable: connect DQ of sensor (pin 2) with GPIO4-interface of Raspberry (pin 7)\n* blue cable: connect GND of sensor (pin 1) to GND-interface of Raspberry (pin 9)\n* red cable: connect VDD of sensor (pin 3) to 3V3-interface of Raspberry (pin 1)\n* orange / red cables: connect 4,7 kOhm resistance between 3V3-interface of Raspberry (pin 1) and DQ of sensor (pin 2)\n\n\u003cdiv class=\"row justify-content-center\"\u003e\n\u003cimg src=\"src/rpi_temperature_1.png\" width=\"260\" /\u003e\n\u003cimg src=\"src/rpi_temperature_2.png\" width=\"260\" /\u003e\n\u003cimg src=\"src/rpi_temperature_3.png\" width=\"260\" /\u003e\n\u003c/div\u003e\n\nTo configure the temperature sensor on the raspberry, you can run the script [`setup_raspberry.sh`](setup_raspberry.sh) (be sure to have admin privileges for the user that is running the script):\n\n```bash\n./setup_raspberry.sh\n```\n\nThe script configures the required modules on the raspberry for the temperature sensor and configures everything to be setup when booting the system. The script also triggers a reboot at the end.(This script must be executed only once for the initial setup.)\n\nWhen the system has been rebooted, you read the temperature from the sensor. For our containerized setup, a environment variable `TEMP_SENSOR_ID` is set with the distinct ID of the connected hardware. To do so, you can run the script [`config_sensor.sh`](config_sensor.sh):\n\n```bash\n./config_sensor.sh\n```\n\nIf everything works fine, you should see the ID of your sensor printed to the console as well as the current temperatur. The environment variable `TEMP_SENSOR_ID` with the appropriate value is appended to the file [`.env`](.env). (This script must be executed only once for the initial setup.)\n\nMore detailed instructions on the configuration of the sensor can also be found [here](https://www.kompf.de/weather/pionewiremini.html).\n\n## Setup: Docker\n\nTo create the dockerized framework, run [`setup_docker.sh`](setup_docker.sh):\n\n```bash\n./setup_docker.sh\n```\n\nThis script builds the container `tempmanager`, which is used to execute the python script [`tempmanager/read_temp-sensor.py`](tempmanager/read_temp-sensor.py). This script reads the temperatur from the host system every 60 seconds and writes to the InfluxDB in the database in the influxdb-container. Furthermore, the script also performs the initial setup of the influxdb container.\n\nSet the environment variables `INFLUXDB_ADMIN_USER`, `INFLUXDB_ADMIN_PASSWORD`, `INFLUXDB_USER`, and `INFLUXDB_PASSWORD` in the file [`.env`](.env).\n\n## Usage\n\nFinally, to start the whole container framework, run\n\n```bash\ndocker-compose up -d\n./start.sh\n```\n\nFor the first setup of Grafana, you can access the Grafana web-interface with http://ip-of-your-raspberry:3000. The initial credentials are \"admin:admin\". Upon first login you are asked to change the password.\n\nGo to \"Configurartion \u003e Data Sources\" and add a new data source. Select \"InfluxDB\":\n\n\u003cdiv class=\"row justify-content-center\"\u003e\n\u003cimg src=\"src/grafana_1.png\" width=\"260\" /\u003e\n\u003cimg src=\"src/grafana_2.png\" width=\"260\" /\u003e\n\u003c/div\u003e\n\nThen create an new \"Dashboard \u003e Add new panel\". Select the \"Data Source \u003e InfluxDB\" and switch to the \"raw-query-mode\". Enter the query `SELECT \"pi-temperature\" FROM \"temperature\"` and execute it by refreshing the panel:\n\n\u003cimg src=\"src/grafana_3.png\" width=\"600\" /\u003e\n\nSave the dashboard and you are ready to monitor the temperature, captured by your raspberry pi.\n\n\u003cimg src=\"src/grafana_4.png\" width=\"600\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkapsner%2Fraspi-temperature","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkapsner%2Fraspi-temperature","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkapsner%2Fraspi-temperature/lists"}