{"id":30321250,"url":"https://github.com/sudodevinci/esp-environment-drivers","last_synced_at":"2026-05-17T00:02:28.586Z","repository":{"id":305998315,"uuid":"1024647152","full_name":"sudoDeVinci/ESP-Environment-Drivers","owner":"sudoDeVinci","description":"Centralized repository for i2c drivers for the ESP32 with thread-safety built-in. This would be an alternative to wrapping existing drivers such as BusIO from Adafruit.","archived":false,"fork":false,"pushed_at":"2025-07-23T03:47:11.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-23T05:27:24.240Z","etag":null,"topics":["driver-programming","drivers","esp32","i2c","i2c-bus","rtos","sensors","threading"],"latest_commit_sha":null,"homepage":"https://devinci.space","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/sudoDeVinci.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,"zenodo":null}},"created_at":"2025-07-23T03:32:25.000Z","updated_at":"2025-07-23T04:07:23.000Z","dependencies_parsed_at":"2025-07-23T05:27:27.695Z","dependency_job_id":"e7a95f13-bba4-4027-b7c4-bb655b5ee81b","html_url":"https://github.com/sudoDeVinci/ESP-Environment-Drivers","commit_stats":null,"previous_names":["sudodevinci/esp-environment-drivers"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/sudoDeVinci/ESP-Environment-Drivers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudoDeVinci%2FESP-Environment-Drivers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudoDeVinci%2FESP-Environment-Drivers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudoDeVinci%2FESP-Environment-Drivers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudoDeVinci%2FESP-Environment-Drivers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sudoDeVinci","download_url":"https://codeload.github.com/sudoDeVinci/ESP-Environment-Drivers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudoDeVinci%2FESP-Environment-Drivers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270912572,"owners_count":24666749,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["driver-programming","drivers","esp32","i2c","i2c-bus","rtos","sensors","threading"],"created_at":"2025-08-17T21:46:31.629Z","updated_at":"2026-05-17T00:02:28.580Z","avatar_url":"https://github.com/sudoDeVinci.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thread-Safe I2C Sensor Drivers for ESP32\n\n[![Compile](https://github.com/sudoDeVinci/ESP-Environment-Drivers/actions/workflows/compile.yml/badge.svg?branch=main)](https://github.com/sudoDeVinci/ESP-Environment-Drivers/actions/workflows/compile.yml)\n[![Unit Tests](https://github.com/sudoDeVinci/ESP-Environment-Drivers/actions/workflows/testing.yml/badge.svg?branch=main)](https://github.com/sudoDeVinci/ESP-Environment-Drivers/actions/workflows/testing.yml)\n![Doxygen](/assets/doxygen_badge.svg)\n\n\nWhile creating the [ESP-Sky-imager](\"(https://github.com/sudoDeVinci/ESP-Sky-Imager\") and [Esp-QuadCopter](\"(https://github.com/sudoDeVinci/ESP-QuadCopter\") projects, I ended up needing to also create a thread-safe alternative to the Adafruit BusIO drivers for my various sensors. \nThis repository is a collection of those drivers and any updates I make to them.\n\n## Features\n\n- **Thread-safe I2C communication** using timed mutexes\n- **Automatic I2C bus management** with clock speed negotiation\n- **Address conflict detection** and pin validation\n- **Statistical processing utilities** for sensor data filtering\n- **Comprehensive unit testing** with AUnit framework\n- **ESP platform focus** The only target board type\n\n## Supported Sensors\n\n- **MPU6050** - 6-axis gyroscope and accelerometer\n- **SHT31D** - Temperature and humidity sensor\n- **BMP3xx** - Barometric pressure sensor *COMING SOON*\n\n## Architecture\n\nThe library is built around two core components:\n\n- [`I2CManager`](I2CManager.hpp) - Singleton that manages I2C buses, handles sensor registration, and negotiates clock speeds\n- [`I2CSensor`](I2CSensor.hpp) - Base class providing common I2C functionality and statistical utilities\n\n### I2C Bus Management\n\nThe manager automatically handles:\n- Clock speed negotiation between multiple sensors on the same bus\n- Address conflict detection\n- Pin configuration validation\n- Bus initialization and cleanup\n\n### Statistical Processing\n\nThe base sensor class includes utilities for:\n- Mean and standard deviation calculations\n- Quartile computation and outlier removal using IQR method\n- CRC8 checksum validation\n\n## Usage\n\n```cpp\n#include \"MPU6050.hpp\"\n#include \"SHT31D.hpp\"\n\n#define I2C_SDA 21\n#define I2C_SCL 22\n\nMPU6050 gyro(0, I2C_SDA, I2C_SCL);\nSHT31 tempSensor(0, I2C_SDA, I2C_SCL);\n\nvoid setup() {\n    Serial.begin(115200);\n    \n    if (!gyro.init()) {\n        Serial.println(\"MPU6050 initialization failed\");\n        return;\n    }\n    \n    if (!tempSensor.init()) {\n        Serial.println(\"SHT31D initialization failed\");\n        return;\n    }\n}\n\nvoid loop() {\n    MPU_XYZ gyroData = gyro.readGyro();\n    \n    if (tempSensor.update()) {\n        float temperature = tempSensor.getTemperature();\n        float humidity = tempSensor.getHumidity();\n    }\n    \n    delay(100);\n}\n```\n\n## Thread Safety\n\nAll I2C communication is protected by timed mutexes with configurable timeouts. The library ensures safe concurrent access to I2C buses when used in multi-threaded environments.\n\n## Building and Testing\n\nThe project includes automated testing using the AUnit framework and EpoxyDuino for cross-platform compatibility.\n\n### Running Tests\n\n```bash\ncd tests\nmake EPOXY_DUINO_DIR=../EpoxyDuino AUNIT_DIR=../AUnit\n./tests.out\n```\n\n### Dependencies for Testing\n\n- [AUnit](https://github.com/bxparks/AUnit) - Unit testing framework\n- [EpoxyDuino](https://github.com/bxparks/EpoxyDuino) - Arduino emulation for native testing\n\n\n## Ideas / TODOs\n- [ ] An 'updateTimespan' attr within the sensors which update internal values. If the timespan has passed, grab new values. If the value hasn't passed, read the same. This would be good for sensors which we use the average of a range of readings, potentially saving a large number of calculations.\n\n\n## License\n\nThis project is licensed under the Business Source License. See [LICENSE](LICENSE) for details.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudodevinci%2Fesp-environment-drivers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsudodevinci%2Fesp-environment-drivers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudodevinci%2Fesp-environment-drivers/lists"}