{"id":24508552,"url":"https://github.com/adygcode/xxx-iot-server","last_synced_at":"2025-08-09T19:06:59.568Z","repository":{"id":112776462,"uuid":"372402329","full_name":"AdyGCode/xxx-iot-server","owner":"AdyGCode","description":"Base Server Code for an IoT Project","archived":false,"fork":false,"pushed_at":"2021-06-17T03:03:28.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T09:22:58.827Z","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":"osl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdyGCode.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-31T06:18:13.000Z","updated_at":"2021-06-17T03:03:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"9a0bbe20-e96e-4b00-9fef-ef96ee248823","html_url":"https://github.com/AdyGCode/xxx-iot-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AdyGCode/xxx-iot-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdyGCode%2Fxxx-iot-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdyGCode%2Fxxx-iot-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdyGCode%2Fxxx-iot-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdyGCode%2Fxxx-iot-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdyGCode","download_url":"https://codeload.github.com/AdyGCode/xxx-iot-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdyGCode%2Fxxx-iot-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261243140,"owners_count":23129585,"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":[],"created_at":"2025-01-22T00:16:52.190Z","updated_at":"2025-08-09T19:06:59.551Z","avatar_url":"https://github.com/AdyGCode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XXX IoT Server\n\nA core project template for the analysis of current technologies and \ntheir application to industry - specifically within the area of Internet of Things.\n\nThis code base is not complete, but **no** contributions are required.\n\n## General Information\n\n* Free software: Open Software License (\"OSL\") v. 3.0\n* Documentation: To be added\n\n\n## Features\n\n* Listens to an MQTT topic and Receives data\n* Store received sensehat (environment) data to a MySQL database table\n* Store received sensor hardware data to a MySQL database table\n\n\n## Requirements\n\nThis code presumes certain hardware is in use.\n\n#### Hardware:\n\n* Raspberry Pi 3B or later\n\n#### Package Requirements\n\nThis project requires the following package(s):\n\n| Package                   | Purpose                           | Recommended Version |\n|---------------------------|-----------------------------------|---------------------|\n| `paho-mqtt`               | Python MQTT package               | v1.5.1 or later     |\n| `SQLAlchemy`              | Python ORM for SQL databases      | v1.4.17 or later    |\n| `mysql-connector-python`  | MySQL Connector for Python        | v8.0.25 or later    |\n| `psutils`                 | system utilities                  | v5.8.0 or later     |\n| `piview`                  | Raspberry Pi Information package  | v2.0.3 or later     |\n  \n\nRemaining packages are Python 'built-ins'.\n\n### Package Installation\n\nYou may install the required packages using the usual methods:\n\n- pip\n- PyCharm Python Interpreter settings\n\n#### Installation via PIP\n\n```shell\npip3 install PACKAGE_NAME\n```\n\nfor example:\n\n```shell\npip3 install SQLAlchemy\n```\n\n#### Installation via PyCharm\n\n1. Click File\n2. Settings\n3. Project: xxx-iot-server settings\n4. Select Python Interpreter settings page\n5. Click the + to add package\n6. Type in package name in search area (eg `SQLAlchemy`)\n7. Select the correct package,\n8. Click Install package\n9. Repeat 6-8 for each required package\n\n\n## Required Software Installation and Configuration\n\nThere are a number of items required for this stage. This includes MySQL/MariaDB and Mosquitto.\n\n### Install and Configure Mosquitto on Raspberry Pi\n\nTODO: Create these instructions\n\n\n\n### Install MariaDB on Raspberry Pi\n\n```shell\nsudo apt update\nsudo apt-get install mariadb-server\n```\n\nThe process with start with the following text (or similar)...\n\n```text\n    pi@per-pi-000:~ $ sudo apt-get install mariadb-server\n    Reading package lists... Done\n    Building dependency tree       \n    Reading state information... Done\n    \n    The following NEW packages will be installed:\n      mariadb-server\n    0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.\n   ```\n\nWhen it asks if you wish to install press Y then Enter.\n\nWhen installed successfully, run the MySQL/MariaDB shell:\n\n```shell\nsudo mysql -uroot\n```\n\nYou should see a welcome similar to the following:\n```text\n    Welcome to the MariaDB monitor.  Commands end with ; or \\g.\n    Your MariaDB connection id is 39\n    Server version: 10.3.27-MariaDB-0+deb10u1 Raspbian 10\n    \n    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n    \n    Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n    \n    MariaDB [(none)]\u003e \n```\nThe `MariaDB [(none)]\u003e` indicates that you are now in the MySQL/MariaDB command line interface.\n\nNow you create the user and database with required access rights, replacing the `xxx` with \nyour **initials** in this code, and throughout the Python and other source code.\n\nThe easiest way to do this is to **edit the sample code** below first.\n\nThen copy it to the clipboard and return to the terminal. \nIn the terminal press `CTRL`+`SHIFT`+`V` to paste all the code in.\n\n```mysql\nDROP DATABASE IF EXISTS xxx_iot;\nDROP USER IF EXISTS 'xxx_iot'@'localhost';\nFLUSH PRIVILEGES;\n\nCREATE DATABASE IF NOT EXISTS xxx_iot;\n\nCREATE USER 'xxx_iot'@'localhost' IDENTIFIED BY 'Password1';\n\nGRANT USAGE ON *.* TO 'xxx_iot'@'localhost' \n    REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 \n    MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;\n\nGRANT ALL PRIVILEGES ON `xxx_iot`.* TO 'xxx_iot'@'localhost';\n\nFLUSH PRIVILEGES;\n```\n\nIf you edited it all correctly then the commands will be executed, creating a new user, new \npassword and new database ready for the rest of the server (and dashboard).\n\nHere is an example of the output from the commands after successfully running *(note: we used \n`xxx` for our initials)*:\n```text\n    MariaDB [(none)]\u003e DROP DATABASE IF EXISTS xxx_iot;\n    Query OK, 0 rows affected (0.002 sec)\n    \n    MariaDB [(none)]\u003e DROP USER IF EXISTS 'xxx_iot'@'localhost';\n    Query OK, 0 rows affected (0.002 sec)\n    \n    MariaDB [(none)]\u003e FLUSH PRIVILEGES;\n    Query OK, 0 rows affected (0.001 sec)\n    \n    MariaDB [(none)]\u003e CREATE DATABASE IF NOT EXISTS xxx_iot;\n    Query OK, 1 row affected (0.001 sec)\n    \n    MariaDB [(none)]\u003e CREATE USER 'xxx_iot'@'localhost' IDENTIFIED BY 'Password1';\n    Query OK, 0 rows affected (0.002 sec)\n    \n    MariaDB [(none)]\u003e GRANT USAGE ON *.* TO 'xxx_iot'@'localhost' \n        -\u003e     REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 \n        -\u003e     MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;\n    Query OK, 0 rows affected (0.001 sec)\n    \n    MariaDB [(none)]\u003e GRANT ALL PRIVILEGES ON `xxx_iot`.* TO 'xxx_iot'@'localhost';\n    Query OK, 0 rows affected (0.001 sec)\n    \n    MariaDB [(none)]\u003e FLUSH PRIVILEGES;\n    Query OK, 0 rows affected (0.003 sec)\n```\nCheck to see if you got any errors. If you did then the problem is most likely a typo... \nSimply correct the error, copy the whole script again and paste into the CLI.\n\nUse the command:\n```mysql\nSHOW DATABASES;\n```\nThis should show a table similar to this to indicate the database is present:\n```text\n    +--------------------+\n    | Database           |\n    +--------------------+\n    | information_schema |\n    | mysql              |\n    | performance_schema |\n    | xxx_iot            |\n    +--------------------+\n    4 rows in set (0.024 sec)\n```\n\nWhen the final line has run successfully, use `\\q` followed by `ENTER` to quit the MySQL \nCLI.\n\nYou are ready to develop the server code.\n\n\n## Credits\n\n- JetBrains for their wonderful PyCharm editor\n- Raspberry for their superb SoC Pi platform\n\n## Copyright\n\nCopyright Adrian Gould, 2021 onwards. \nLicensed under the Open Software License version 3.0\n\nPlease credit the author whenever this code is used in any capacity.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadygcode%2Fxxx-iot-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadygcode%2Fxxx-iot-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadygcode%2Fxxx-iot-server/lists"}