{"id":13750555,"url":"https://github.com/automaticdai/rpi-environmental-sensing","last_synced_at":"2026-05-02T04:36:38.225Z","repository":{"id":70789060,"uuid":"74073573","full_name":"automaticdai/rpi-environmental-sensing","owner":"automaticdai","description":"An open-source domestic environment sensing system built with Raspberry Pi Zero W + HTU21D + AM2306 + PMS7003. Supports report to MySQL and MQTT broker.","archived":false,"fork":false,"pushed_at":"2020-04-01T22:33:07.000Z","size":2857,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-06T20:08:06.035Z","etag":null,"topics":["raspberry-pi"],"latest_commit_sha":null,"homepage":"","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/automaticdai.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}},"created_at":"2016-11-17T22:37:35.000Z","updated_at":"2023-07-05T08:34:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"c493ec4a-c6e9-4275-b021-957ba3cf9a8c","html_url":"https://github.com/automaticdai/rpi-environmental-sensing","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/automaticdai%2Frpi-environmental-sensing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automaticdai%2Frpi-environmental-sensing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automaticdai%2Frpi-environmental-sensing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automaticdai%2Frpi-environmental-sensing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/automaticdai","download_url":"https://codeload.github.com/automaticdai/rpi-environmental-sensing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353751,"owners_count":20925329,"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":["raspberry-pi"],"created_at":"2024-08-03T08:00:37.996Z","updated_at":"2026-05-02T04:36:33.182Z","avatar_url":"https://github.com/automaticdai.png","language":"Python","funding_links":[],"categories":["2. 嵌入式系统项目 | Embedded System"],"sub_categories":[],"readme":"# Raspberry Pi Environmental Sensing\n\nThis project is a personal sensing station that uses Raspberry Pi, HTU21D (indoor temperature/humidity), AM2306 (outdoor temperature/humidity) and PMS7003 (particle matter level). It supports logging measured sensory data locally and submit to a MQTT broker and/or a MySQL database.\n\n- Raspberry Pi is a popular open-source hardware. This program is tested on RPi Zero W, but should support all versions of RPi.\n- HTU21D is a high precision temperature + humidity sensor and it is connected to RPi via I2C_1.\n- AM2306 is an outdoor temperature + humidity sensor, which uses the DHT22 chip. It is connected to RPi via Pin 7.\n- PMS7003 is a laser particle matter sensor. It connects to the RPi using the serial port.\n- MQTT is a subscribe/publish message protocol designed for light-weight IoT devices.\n- MySQL is a relational SQL database.\n\n![](./demo_tiny.jpg)\n\n\n## 1. Requirements\n\n- Python \u003e= 3.5\n- To use AM2306/DHT22:\n  - Install RPi.GPIO: `sudo apt-get install python-rpi.gpio`\n  - Install the Adafruit driver: https://github.com/adafruit/Adafruit_Python_DHT\n- To report to a MQTT broker: https://pypi.org/project/paho-mqtt/\n- To report to a MySQL server: `sudo apt-get install python3-pymysql`\n\n\n## 2. Usage\n\n1. Change to home directory: `cd ~`\n2. Clone the project: `git clone https://github.com/automaticdai/rpi-environmental-sensing`\n3. Edit the configuration file `rpi-weather-config.json` and save\n4. Copy the configuration file to /etc: `sudo cp rpi-weather-config.json /etc/rpi-weather-config.json`\n5. Run the main script: `python3 main.py`\n\nYou can run individual python script to test the sensor driver, e.g., `python3 dht22.py`\n\n\n## 3. System Configuration\n\nFor the configuration file `config.json`:\n\n### Config\n\n- `sensor_id`: assign a sensor ID to the device.\n- `sensor_name`: name of the sensor. Used as the prefix of MQTT publishers.\n- `log_on`: enable writing to a local log.\n- `report_periodic`: run the script periodically/or only once.\n- `report_interval_sec`: set the sampling and report interval (in second). If 'report_periodic' is false, this parameter will be ignored. Should be no less than 10s, otherwise it is difficult to guarantee.\n\n### MQTT\n\n- `enable`: enable report to MQTT.\n- `server`, `port`: MQTT broker IP and port.\n\n### MySQL\n\n- `enable`: enable report to MySQL server.\n- `host`, `port`: database IP and port.\n- `user`, `password`: login user information.\n- `db`, `table`: database and table name (should be an existed database).\n- `charset`: character set\n\n\n## 4. Credit\n\n- Adafruit for the HTU21D and DHT22 drivers.\n- Eclipse Paho project for the MQTT driver.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomaticdai%2Frpi-environmental-sensing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautomaticdai%2Frpi-environmental-sensing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomaticdai%2Frpi-environmental-sensing/lists"}