{"id":15163333,"url":"https://github.com/lilanga/aws-iot-dht22-sensor","last_synced_at":"2026-01-20T06:02:11.146Z","repository":{"id":251857491,"uuid":"838368446","full_name":"Lilanga/aws-iot-dht22-sensor","owner":"Lilanga","description":"Sent sensor readings to AWS IoT Core thing","archived":false,"fork":false,"pushed_at":"2024-08-06T04:52:37.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T09:51:21.282Z","etag":null,"topics":["aws","aws-iot-core","balenacloud","golang","mqtt"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lilanga.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-05T13:53:02.000Z","updated_at":"2024-08-06T04:52:40.000Z","dependencies_parsed_at":"2024-08-06T07:13:33.145Z","dependency_job_id":null,"html_url":"https://github.com/Lilanga/aws-iot-dht22-sensor","commit_stats":null,"previous_names":["lilanga/aws-iot-dht22-sensor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Lilanga/aws-iot-dht22-sensor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lilanga%2Faws-iot-dht22-sensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lilanga%2Faws-iot-dht22-sensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lilanga%2Faws-iot-dht22-sensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lilanga%2Faws-iot-dht22-sensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lilanga","download_url":"https://codeload.github.com/Lilanga/aws-iot-dht22-sensor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lilanga%2Faws-iot-dht22-sensor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28597087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aws","aws-iot-core","balenacloud","golang","mqtt"],"created_at":"2024-09-27T02:23:27.750Z","updated_at":"2026-01-20T06:02:11.130Z","avatar_url":"https://github.com/Lilanga.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reading DHT22 Sensor with Raspberry Pi on BalenaOS\r\n\r\nThis repository contains a Go application for reading DHT22 sensor data using a Raspberry Pi Zero running BalenaOS. The application reads temperature, humidity, and pressure data, and publishes it via MQTT.\r\n\r\n## Table of Contents\r\n\r\n- [Reading DHT22 Sensor with Raspberry Pi on BalenaOS](#reading-dht22-sensor-with-raspberry-pi-on-balenaos)\r\n  - [Table of Contents](#table-of-contents)\r\n  - [Requirements](#requirements)\r\n  - [Installation](#installation)\r\n  - [Configuration](#configuration)\r\n  - [Running the Application](#running-the-application)\r\n    - [Using Balena to Run on Raspberry Pi](#using-balena-to-run-on-raspberry-pi)\r\n    - [Running Locally](#running-locally)\r\n  - [Shutdown](#shutdown)\r\n  - [License](#license)\r\n\r\n## Requirements\r\n\r\n- Raspberry Pi with BalenaOS\r\n- DHT22 Module\r\n- Go 1.18+\r\n- Configured AWS IoT Core broker\r\n- `.env` file with necessary configurations\r\n- Docker\r\n\r\n## Installation\r\n\r\n1. **Clone the repository:**\r\n\r\n    ```sh\r\n    git clone https://github.com/lilanga/aws-iot-dht22-sensor.git\r\n    cd aws-iot-dht22-sensor\r\n    ```\r\n\r\n2. **Ensure you have Go installed:**\r\n\r\n    Follow the instructions on the [official Go website](https://golang.org/doc/install) to install Go.\r\n\r\n3. **Install dependencies:**\r\n\r\n    This project uses a `go.mod` file to manage dependencies. Ensure you are in the project directory and run:\r\n\r\n    ```sh\r\n    go mod tidy\r\n    ```\r\n\r\n4. **Create a `.env` file:**\r\n\r\n    ```sh\r\n    touch .env\r\n    ```\r\n\r\n    Populate the `.env` file with the following variables:\r\n\r\n    ```env\r\n    AWS_BROKER=tcps://\u003cYOUR-IOT-CORE-BROKER-URL\u003e:8883/mqtt\r\n    AWS_TOPIC=\u003cYOUR-IOT-TOPIC-ADDED-IN-PERMISSIONS\u003e\r\n    AWS_CLIENT_ID=\u003cYOUR-CLIENT-ADDED-IN-PERMISSIONS\u003e\r\n    REFRESH_INTERVAL=60\r\n    ID=DHT-22-01\r\n    ```\r\n\r\n## Configuration\r\n\r\n- `ID`: A unique ID for your sensor, Can be anything. I am using DHT-22-01 ID to fetch data from lambda.\r\n- `AWS_BROKER`: Configured AWS IoT Core thing MQTT broker.\r\n- `AWS_TOPIC`: The MQTT topic to publish sensor data to. This need to be mapped in your IoT Core permission profile.\r\n- `AWS_CLIENT_ID`: The Client ID of the MQTT client. This also needs to be mentioned in your IoT Core permission profile.\r\n- `REFRESH_INTERVAL`: The interval (in seconds) at which sensor data is read and published.\r\n\r\n## Running the Application\r\n\r\n### Using Balena to Run on Raspberry Pi\r\n\r\n1. **Install Balena CLI:**\r\n\r\n    Follow the instructions on the [official Balena CLI documentation](https://www.balena.io/docs/reference/cli/#installation) to install the Balena CLI.\r\n\r\n2. **Log in to Balena:**\r\n\r\n    ```sh\r\n    balena login\r\n    ```\r\n\r\n3. **Initialize the project:**\r\n\r\n    ```sh\r\n    balena push \u003cyour-app-name\u003e\r\n    ```\r\n\r\n    Replace `\u003cyour-app-name\u003e` with the name of your Balena application. This command will build and deploy the application to your Raspberry Pi.\r\n    You need to have a Balena application set up with a Raspberry Pi device before running this command to deploy the application.\r\n\r\n### Running Locally\r\n\r\n1. **Build and run the application using Docker:**\r\n\r\n    Make sure Docker is installed and running on your machine. Then, from the project directory, run:\r\n\r\n    ```sh\r\n    docker build -t weather-service .\r\n    docker run --env-file .env -p 8080:8080 weather-service\r\n    ```\r\n\r\n2. **Configure Environment Variables:**\r\n\r\n    Set the `AWS_TOPIC` and `AWS_CLIENT_ID` to correct values from your AWS IoT Core configurations. Otherwise you will not be able to establish connection to the broker.\r\n\r\n## Shutdown\r\n\r\nThe application is designed to handle graceful shutdown upon receiving an interrupt signal (e.g., `Ctrl+C` or a termination signal).\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilanga%2Faws-iot-dht22-sensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flilanga%2Faws-iot-dht22-sensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilanga%2Faws-iot-dht22-sensor/lists"}