{"id":27425772,"url":"https://github.com/scar027/mpu-2-mqtt","last_synced_at":"2026-05-08T17:38:50.850Z","repository":{"id":287765872,"uuid":"965655658","full_name":"scar027/mpu-2-mqtt","owner":"scar027","description":"ESP-IDF implementation of reading and publishing sensor data via 2 MPU6050s connected to an ESP32 over MQTT TLS(MQTTS).","archived":false,"fork":false,"pushed_at":"2025-04-13T19:14:02.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T20:25:58.711Z","etag":null,"topics":["c","esp-idf","esp32","freertos","mpu6050","mqtt","mqtts"],"latest_commit_sha":null,"homepage":"","language":"C","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/scar027.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,"zenodo":null}},"created_at":"2025-04-13T16:29:33.000Z","updated_at":"2025-04-13T19:20:50.000Z","dependencies_parsed_at":"2025-04-13T20:36:33.006Z","dependency_job_id":null,"html_url":"https://github.com/scar027/mpu-2-mqtt","commit_stats":null,"previous_names":["scar027/mpu-2-mqtt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scar027%2Fmpu-2-mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scar027%2Fmpu-2-mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scar027%2Fmpu-2-mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scar027%2Fmpu-2-mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scar027","download_url":"https://codeload.github.com/scar027/mpu-2-mqtt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248880775,"owners_count":21176730,"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":["c","esp-idf","esp32","freertos","mpu6050","mqtt","mqtts"],"created_at":"2025-04-14T12:28:53.022Z","updated_at":"2026-05-08T17:38:45.795Z","avatar_url":"https://github.com/scar027.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mpu-2-mqtt\nESP-IDF implementation of reading and publishing sensor data via 2 MPU6050s connected to an ESP32 over MQTT TLS(MQTTS).\n- Built referring [Espressif MQTT SSL implementation example](https://github.com/espressif/esp-idf/tree/v5.4.1/examples/protocols/mqtt/ssl) and [Espressif MPU6050 sensor implementation example](https://github.com/espressif/esp-bsp/blob/master/examples/display_sensors/main/sensors_example.c).\n- Modifies the original [MPU6050 component](https://components.espressif.com/components/espressif/mpu6050/versions/1.2.0) present in ESP component registry to provide a library to support a dual MPU6050 configuration.\n- Integrates the newer \"driver/i2c_master.h\" driver in the original MPU6050 component source code.\n- Provides easy Broker Configuration and WiFi SSID and Password configuration via menuconfig.\n\n## Get MQTT Certificates for TLS\n1. Navigate to the main/cert/ folder and run the following commands(requires openssl installed):\n    ```bash\n    cd main/cert/\n    # Generate private key(client key)\n    openssl genrsa -out client.key\n    # Generate client certificate signing request(client.csr) based on the private key\n    # Enter the country, organization, and name when prompted. Leave fields blank by typing a dot (.) if you don’t want to fill them.\n    openssl req -out client.csr -key client.key -new\n    ```\n1. Now generate the client certificate(client.crt) at \u003chttps://test.mosquitto.org/ssl/\u003e by pasting the contents of client.csr there. You can get the contents from the terminal itself using:\n    ```bash\n    more client.csr\n    ```\n1. Store the generated client.crt file in the main/cert/ folder as well.\n1. Fetch the mosquitto.org CA(Certificate Authority) certificate (mosquitto.org.pem). You can also do this directly from the website as well and then storing the downloaded file in the main/cert/ folder.\n    ```bash\n    curl -o mosquitto.org.crt https://test.mosquitto.org/ssl/mosquitto.org.crt\n    ```\n1. Install Eclipse Mosquitto on your desktop from \u003chttps://mosquitto.org/download/\u003e\n- Tip: For Ubuntu use the ppa instead of snap. Here's [why](https://stackoverflow.com/questions/67262895/mosquitto-sub-fails-with-error-problem-setting-tls-options-file-not-found-w).\n1. Test by subscribing to a secure server on a different terminal(in the same folder):\n    ```bash\n    mosquitto_sub -h test.mosquitto.org -t \"testcert\" -p 8884 --cafile mosquitto.org.crt --key client.key --cert client.crt -d\n    ```\n1. Publish to the topic to test:\n    ```bash\n    mosquitto_pub --cafile mosquitto.org.crt --key client.key --cert client.crt -h test.mosquitto.org -m \"Hello World!\" -t \"testcert\" -p 8884 -d\n    ```\n1. Once you have verified that it works create a new file with the name mqtt_eclipseprojects_io.pem and copy the contents of the client.key, the client.crt and the mosquitto.org.crt in it(in the same order). You can do this by running this command from the main/ directory:\n    ```bash\n    cat cert/client.key cert/client.crt cert/mosquitto.org.crt \u003e mqtt_eclipseprojects_io.pem\n    ```\n\n## Set Target\n1. After cloning the repository, set the intended target. For an ESP32 this can be done:\n```bash\nidf.py set-target esp32\n```\n\n## Build the project\n1. This will help add the additionally defined options for Broker configuration and WiFi configuration in the default menuconfig.\n```bash\nidf.py build\n```\n\n## Configure MQTT Broker and WiFi SSID and Password\n```bash\nidf.py menuconfig\n```\n\n1. Navigate to Broker Configuration and change the Broker URL if required. Use enter to enter and esc to exit. \n1. Navigate to WiFi Configuration and enter the SSID and Password for your network.\n1. Enter 'S' to save the configuration.\n1. Rebuild:\n```bash\nidf.py build\n```\n\n## Flash and Monitor\n1. Connect the ESP32 via USB and upload the code and monitor using:\n```bash\nidf.py flash monitor\n```\n\n## Verify by receiving\n1. Open a new terminal window and check that data is being received by subscribing to the MQTTS topic. Make sure you are in the directory containing mosquitto.org.crt (main/cert/ in this repository)before running this.\n```bash\nmosquitto_sub -h test.mosquitto.org -p 8883 --cafile mosquitto.org.crt -t \"sensors1635/mpu6050\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscar027%2Fmpu-2-mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscar027%2Fmpu-2-mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscar027%2Fmpu-2-mqtt/lists"}