{"id":15634513,"url":"https://github.com/ragingroosevelt/rpi_environlogger","last_synced_at":"2026-05-10T09:34:53.637Z","repository":{"id":87171684,"uuid":"458787034","full_name":"RagingRoosevelt/RPi_EnvironLogger","owner":"RagingRoosevelt","description":"Raspberry Pi Environmental Data Logger","archived":false,"fork":false,"pushed_at":"2022-02-17T11:55:57.000Z","size":1543,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T22:48:31.219Z","etag":null,"topics":["adafruit","circuitpython","data-logger","data-logging","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/RagingRoosevelt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-13T11:18:31.000Z","updated_at":"2022-02-13T13:25:27.000Z","dependencies_parsed_at":"2023-03-10T12:15:12.519Z","dependency_job_id":null,"html_url":"https://github.com/RagingRoosevelt/RPi_EnvironLogger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RagingRoosevelt%2FRPi_EnvironLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RagingRoosevelt%2FRPi_EnvironLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RagingRoosevelt%2FRPi_EnvironLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RagingRoosevelt%2FRPi_EnvironLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RagingRoosevelt","download_url":"https://codeload.github.com/RagingRoosevelt/RPi_EnvironLogger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237429,"owners_count":20745348,"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","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":["adafruit","circuitpython","data-logger","data-logging","raspberry-pi"],"created_at":"2024-10-03T10:53:51.758Z","updated_at":"2026-05-10T09:34:53.560Z","avatar_url":"https://github.com/RagingRoosevelt.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi Environmental Data Logger\r\n\r\nThis project sets up a data logging system for my raspberry pi to monitor\r\ntemperature, relative humidity, and CO2 levels.  It presumes you have an\r\navailable postgres database to log to.  It also presumes that your Raspberry Pi\r\nhas an internet connection.\r\n\r\n## Hardware Setup\r\n\r\nAdafruit's i2c sensors are very well set up with excelent python integration.\r\nFor this project, I used\r\n\r\n* [SCD-30](https://www.adafruit.com/product/4867) real CO2 reading which\r\nhandles CO2 PPM, % relative humidity, and temperature\r\n* [DS3231](https://www.adafruit.com/product/5188) Real Time Clock (RTC) and\r\ntemperature source #2\r\n* [TMP117](https://www.adafruit.com/product/4821) temperature source #3\r\n* [MCP9808](https://www.adafruit.com/product/5027) temperature source #4\r\n* [Stemma QT SHIM](https://www.adafruit.com/product/4463) for easy connection\r\nof the sensors\r\n\r\nI opted to use PoE to power my Raspberry Pi since I needed to get a network\r\nconnection to it anyhow.  I'm cheap so I used Adafruit's\r\n[USB C PoE Splitter](https://www.adafruit.com/product/4552) (but you can find\r\nthem on other online stores too) rather than using a PoE hat.  This also\r\nsimplified making the \"case\" for my setup.\r\n\r\nI designed and 3D printed a [\"lid\"](./Case/Lid.stl) and\r\n[mount panel](Case/Mount.stl) that I could use plastic standoffs to attach\r\neveryting with.  I used M2 standoffs so that I'd have a bit more tollerance\r\nin the hole layouts.  I went with\r\n[this set of standoffs](https://www.amazon.com/gp/product/B01DMJVQVC/) which\r\nincludes various lengths of standoffs in addition to M2 plastics screws and M2\r\nnuts.\r\n\r\nI used some Dual Lock velcro to affix the Pi and PoE splitter to a beam in my\r\ncrawl space.  I used a low-voltage in-wall mounting box/bracket and a\r\nkeystone-compatible face plate with some keystone Cat6 female-to-female coupler\r\njacks to pass ethernet through my wall from my network closet into my crawl\r\nspace.\r\n\r\nInstalled, it looks like this:\r\n\r\n![img](./Case/installed_bottom.jpg \"Photo of Raspberry Pi installed in crawl space, from the bottom\")\r\n![img](./Case/installed_side.jpg \"Photo of Raspberry Pi installed in crawl space, from the side\")\r\n\r\n## Database Setup\r\n\r\n1. Make sure an instance of postgres running somewhere\r\n2. If a new database is needed, set that up\r\n3. Use the contents in the [`ddl.sql`][ddl] file to set up a table,\r\nmodify as needed\r\n\r\nNote: I used heroku's postgres hosting. They have a free tier that supports\r\n10,000 rows and 20 connections.  This system only uses 1 or 2 connections\r\nand at 15 minute logging frequency, that's 96 records per day or around 100\r\ndays of logging.  One caviat with using Heroku is that they ocasionally\r\nperform database \"maintaince\" that results in the hostname, database name,\r\nuser name, and password being changed.  They email before this happens but it\r\ncan still be a bit of a hastle.  In the future, I think I'll either install\r\npostgres on the Pi, or once I get my container cluster running, host a\r\ngeneral-purpose postgres database there instead.\r\n\r\n[ddl]: ./ddl.sql\r\n\r\n## Software Setup\r\n\r\nFill out the [`logging_config_template.ini`][template] file with the pertinent\r\ninfo.  A copy of this file is used both on the pi and locally for reporting.\r\n\r\n[template]: ./logging_config_template.ini\r\n\r\n### Logger\r\n\r\n1. Set up a Raspberry Pi, probably with raspbian or debian or a similar OS\r\n2. Make sure there's a running ssh server on the pi\r\n3. Install python 3 if it isn't already installed\r\n4. Copy the [`requirements-pi_logger.txt`][req_pi], [`env_logger.py`][script],\r\nand filled out `logging_config.ini` to the pi and make sure the `.ini` and\r\n`.py` files are in the same directory\r\n5. Install the requirements file with\r\n`python -m pip install -r requirements-pi_logger.txt`\r\n6. Set up the `.py` file to be run automatically when the pi launches, perhaps\r\nby\r\n    * Adding a cron entry\r\n      1. Launch cron editor: `crontab -u pi -e`\r\n      2. Add a line like `@reboot python3 /home/pi/env_logger.py`\r\n      3. Save and exit the editor\r\n      4. Reboot\r\n    * Adding it to `rc.local`\r\n      * Untested, but probably with\r\n`su pi -c 'python3 /home/pi/env_logger.py \u0026'`\r\n    * Adding a script to the `init.d` directory\r\n    * SYSTEMD\r\n\r\n[req_pi]: ./RPi_Logger/requirements-pi_logger.txt\r\n[script]: ./RPi_Logger/env_logger.py\r\n\r\n### Reporting\r\n\r\n1. Make sure you have a python 3 environment\r\n2. Install [library requirements][req_rept] with\r\n`python -m pip install -r requirements-local_reports.txt`\r\n3. Copy the filled out `logging_config.ini` file to where you store the\r\n[`plot.ipynb`][plot] file\r\n4. Launch jupyter lab (or use something like VSC) from the same directory as\r\nthe ploting notebook\r\n6. Run the notebook to see the plots, optionally edit the query or save the\r\nimage\r\n\r\nOutputs should look something like\r\n\r\n![img](./Reporting/env_log_plot.png \"Demo output figure from reporting notebook\")\r\n\r\nNote: I suspect that the erratic data shown in this demo is due to the\r\nproximity of my Pi to my HVAC ducts.  I'm planning to either move the Pi\r\naway from the ducts or distribute the temperature sensors around the crawl\r\nspace rather than having them all mounted together.\r\n\r\n\r\n[req_rept]: ./Reporting/requirements-local_reports.txt\r\n[plot]: ./Reporting/plot.ipynb","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragingroosevelt%2Frpi_environlogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fragingroosevelt%2Frpi_environlogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragingroosevelt%2Frpi_environlogger/lists"}