{"id":24664479,"url":"https://github.com/batyrrasulov/raspberry-pi-hub","last_synced_at":"2026-04-12T19:37:32.634Z","repository":{"id":274103095,"uuid":"921922757","full_name":"batyrrasulov/raspberry-pi-hub","owner":"batyrrasulov","description":"Raspberry Pi home monitoring hub built with C, Python and MariaDB.","archived":false,"fork":false,"pushed_at":"2025-01-24T21:59:18.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T22:28:19.706Z","etag":null,"topics":["apache2","c","iot-application","mariadb","php","python","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C","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/batyrrasulov.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":"2025-01-24T21:55:27.000Z","updated_at":"2025-01-24T22:05:37.000Z","dependencies_parsed_at":"2025-01-24T22:38:21.574Z","dependency_job_id":null,"html_url":"https://github.com/batyrrasulov/raspberry-pi-hub","commit_stats":null,"previous_names":["batyrrasulov/strawbery-pi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batyrrasulov%2Fraspberry-pi-hub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batyrrasulov%2Fraspberry-pi-hub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batyrrasulov%2Fraspberry-pi-hub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batyrrasulov%2Fraspberry-pi-hub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/batyrrasulov","download_url":"https://codeload.github.com/batyrrasulov/raspberry-pi-hub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244776270,"owners_count":20508503,"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":["apache2","c","iot-application","mariadb","php","python","raspberry-pi"],"created_at":"2025-01-26T06:13:13.162Z","updated_at":"2025-12-31T00:03:25.013Z","avatar_url":"https://github.com/batyrrasulov.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RaspberryPi: Home Monitoring Hub for Temperature, Humidity, Light, and Gas Levels\n\nThis project uses a Raspberry Pi 5 to monitor temperature, humidity, light levels, and gas presence (CO and LPG). The gas sensor detects carbon monoxide and LPG, and if gas is detected, the ppm is sent to a MariaDB database. An alert is also displayed on the LCD, indicating gas detection. Data is collected using C, sent to the database via Apache2 and PHP, and displayed on an LCD through a Python frontend. The system shows real-time data along with 7-day trends from the database.\n\n## Demos\n\n*System Demo #1: Display data*\n\n![System Demo #1: Display data](img/ex1.gif)\n\n*System Demo #2: Gas detection*\n\n![System Demo #2: Gas detection](img/ex2.gif)\n\n\n\n## Authors\n|                                                |                                          |\n|:----------------------------------------------:|:----------------------------------------:|\n| ![](https://media.licdn.com/dms/image/v2/D5603AQHnmxmLnIzUTQ/profile-displayphoto-shrink_400_400/B56ZOiFBHpG8Ao-/0/1733591045903?e=1738800000\u0026v=beta\u0026t=KAaZJ0CRwZDZlGCOB7exF26cwWCaZpNZtEIpxAiRO8Y) | ![](https://github.com/user-attachments/assets/90471669-b8bd-407a-bc86-aa347cb3b0ef) |\n| *Alejandro Barranco-Leyte*                    | *Batyr Rasulov*                          |\n\n\n\n\n\n\n\n## Project Overview\n\n- **Hardware**: Raspberry Pi 5, DHT11 Sensor (Temperature and Humidity), Photoresistor (Light Levels), I2C LCD Display, MQ-5 Gas Sensor\n- **Backend**: Data collection and database management in C, sending data to MariaDB using MariaDB C connector.\n- **Frontend**: Real-time display on an I2C LCD with Python via socket communication. It also fetches and displays 7-day trends from the database.\n\n# Setup Instructions\n\n## Hardware Image\n\nThe following image shows the physical setup of the Raspberry Pi and its connected components. This is for display purposes, showing how everything is arranged in the system. For correct wiring, please see next section.\n\n\u003cimg src=\"img/RaspberryPi_Hardware_Setup.jpg\" alt=\"Physical Circuit Diagram\" width=\"500\"/\u003e\n\n## Hardware Configuration\n\nThe following image shows the correct wiring for all the sensors used in the project:\n\n![Circuit Diagram](img/CircuitDiagram.jpg)\n\nThis diagram helps in visualizing the connections between the Raspberry Pi and the connected sensors.\n\n## Database Configuration\n\n1. Install Apache, PHP, MariaDB, and PHPMyAdmin:\n    ```bash\n    sudo apt install apache2 php php-mysql mariadb-server phpmyadmin\n    ```\n2. Include the PHPMyAdmin configuration in Apache, to make PHPMyAdmin accessible through the web browser:\n    ```bash\n    echo 'Include /etc/phpmyadmin/apache.conf' | sudo tee -a /etc/apache2/apache2.conf\n    ```\n3. Set a root password and other configurations as you wish:\n    ```bash\n    sudo mysql_secure_installation\n    ```\n4. Enable PHP MySQL module:\n    ```bash\n    sudo phpenmod mysqli\n    ```\n5. Install MariaDB development libraries:\n    ```bash\n    sudo apt-get install libmariadb-dev\n    ```\n6. Copy MariaDB drivers to your project:\n    ```bash\n    sudo cp -r /usr/include/mariadb /home/{your-username}/{project-directory}\n    ```\n7. Open PHPMyAdmin in your browser:\n    - If you're working directly on the Raspberry Pi, you can use `localhost`:\n      ```bash\n      http://localhost/phpmyadmin\n      ```\n    - If you're accessing the Pi from a different device, use the Pi's IP address:\n      ```bash\n      http://\u003cyour-pi-ip-address\u003e/phpmyadmin\n      ```\n8. In PHPMyAdmin, select your database, then run the SQL script located at `table_creation.sql`:\n    - Log in with the credentials you made in Step 3.\n    - Click on the **SQL** tab in the top menu.\n    - Use the file upload option or copy/paste the contents of `table_creation.sql` into the query box.\n    - Click **Go** to execute the SQL script, which will create the necessary tables in the database.\n\n## C Configuration\n\n1. Install WiringPi (for GPIO access):\n   ```bash\n   sudo apt-get install wiringpi\n   ```\n2. To compile your C file:\n    ```bash\n    gcc main.c dhthw.c adchw.c mq5hw.c -o main -lwiringPi -lmariadb\n    ```\n\n## Python Configuration\n1. Install MySQL connector for Python:\n    ```bash\n    sudo pip3 install mysql-connector-python\n    ```\n    **Note:** You might need to break system packages for this installation. Please refer to the official [MySQL Connector for Python documentation](https://dev.mysql.com/doc/connector-python/en/) for any potential system package conflicts or resolutions.\n2. Clone the LCD driver repository:\n    ```bash\n    cd /home/${USER}/\n    git clone https://github.com/the-raspberry-pi-guy/lcd.git\n    cd lcd/\n    ```\n3. Run the automatic installation script:\n    ```bash\n    sudo ./install.sh\n    ```\n4. Copy the LCD drivers to your project:\n    ```bash\n    sudo cp -r drivers /home/{your-username}/{project-directory}\n    ```\n5. Enable I2C on the Raspberry Pi:\n    ```bash\n    sudo raspi-config\n    ```\n    - Go to \"Interfacing Options\" and enable I2C.\n6. Modify the i2c_dev.py file:\n    - Add the following method to the Lcd class for scrolling text:\n    ```python\n    def scroll_text(self, text, speed, iterations=1):\n    text_len = len(text)\n    display_width = 16  # Width of the LCD display\n    \n    for _ in range(iterations):\n        for i in range(text_len - display_width + 1):\n            self.lcd_clear()\n            display_text = text[i:i + display_width]\n            self.lcd_display_string(display_text, 1)\n\n            if i == 0:\n                sleep(2)  # Hold at the start of the scroll\n            else:\n                sleep(speed)\n    ```\n\n## Running the Project\n1. Start the Python frontend to display real-time data\n    ```bash\n    python display.py\n    ```\n2. Run the main C program:\n    ```bash\n    ./main\n    ```\nThis will start collecting data from the sensors and send it to the database while displaying real-time information and trends on the LCD.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbatyrrasulov%2Fraspberry-pi-hub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbatyrrasulov%2Fraspberry-pi-hub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbatyrrasulov%2Fraspberry-pi-hub/lists"}