{"id":16148909,"url":"https://github.com/erriez/erriezhcsr04","last_synced_at":"2026-04-28T18:34:53.276Z","repository":{"id":85067599,"uuid":"294375323","full_name":"Erriez/ErriezHCSR04","owner":"Erriez","description":"HC-SR04 Ultrasonic Distance Sensor library for Arduino","archived":false,"fork":false,"pushed_at":"2020-09-12T12:56:19.000Z","size":488,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T21:44:34.290Z","etag":null,"topics":["arduino","cm","distance","erriez","hc-sr04","library","measure","robotic","sensor","ultrasonic"],"latest_commit_sha":null,"homepage":"https://github.com/Erriez/ErriezArduinoLibraries","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/Erriez.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}},"created_at":"2020-09-10T10:17:35.000Z","updated_at":"2020-09-12T12:49:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea098617-eda2-4f9a-9c9a-dae20acd2f1e","html_url":"https://github.com/Erriez/ErriezHCSR04","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"e54c1bb4a3bd4aac89b8956074b514aa7f0e9950"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Erriez/ErriezHCSR04","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezHCSR04","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezHCSR04/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezHCSR04/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezHCSR04/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Erriez","download_url":"https://codeload.github.com/Erriez/ErriezHCSR04/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erriez%2FErriezHCSR04/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32394465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"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":["arduino","cm","distance","erriez","hc-sr04","library","measure","robotic","sensor","ultrasonic"],"created_at":"2024-10-10T00:35:14.071Z","updated_at":"2026-04-28T18:34:53.246Z","avatar_url":"https://github.com/Erriez.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HC-SR04 Ultrasonic Distance Sensor library for Arduino\n\n[![Build Status](https://travis-ci.org/Erriez/ErriezHCSR04.svg?branch=master)](https://travis-ci.org/Erriez/ErriezHCSR04)\n\nThis is a HC-SR04 I2C RTC library for Arduino.\n\n![HC-SR04 sensor](https://raw.githubusercontent.com/Erriez/ErriezHCSR04/master/extras/HC-SR04.png)\n\n\n## Library features\n\n* Measure distance between 3cm .. 400cm or 1.18\" .. 157.48\"\n* Accuracy around +/-1cm\n* Optimized pin control for AVR\n\n\n## Hardware\n\n**Arduino UNO**\n\n* TRIG pin to Arduino Uno pin 2\n* ECHO pin to Arduino Uno pin 3\n* VCC pin to Arduino Uno pin VCC\n* GND pin to Arduino Uno pin GND\n\n![Arduino Uno HC-SR04](extras/Arduino-Uno-HC-SR04.png)\n\n\n## Examples\n\nArduino IDE | Examples | Erriez HC-SR04:\n\n* [HC-SR04 Centimeter](https://github.com/Erriez/ErriezHCSR04/blob/master/examples/ErriezHCSR04Centimeter/ErriezHCSR04Centimeter.ino)\n* [HC-SR04 Inch](https://github.com/Erriez/ErriezHCSR04/blob/master/examples/ErriezHCSR04Inch/ErriezHCSR04Inch.ino)\n\n\n## Documentation\n\n* [Doxygen online HTML](https://erriez.github.io/ErriezHCSR04)\n* [Doxygen PDF](https://github.com/Erriez/ErriezHCSR04/blob/master/ErriezHCSR04.pdf)\n* [Datsheet](https://www.google.com/search?q=%22hc-sr04%20pdf%22)\n\n\n## Example\n\n```c++\n#include \u003cErriezHCSR04.h\u003e\n\n// Pin defines\n#define TRIG_PIN    2\n#define ECHO_PIN    3\n\n// Create sensor object\nErriezHCSR04 hcsr04(TRIG_PIN, ECHO_PIN);\n\n\nvoid setup()\n{\n    // Initialize serial port\n    delay(500);\n    Serial.begin(115200);\n    while (!Serial) {\n        ;\n    }\n    Serial.println(F(\"\\nErriez HC-SR04 ultrasonic distance sensor example\\n\"));\n\n    // Initialize pins\n    hcsr04.begin();\n}\n\nvoid loop()\n{\n    int16_t distance;\n\n    // Measure distance in centimeter\n    distance = hcsr04.getDistance();\n\n    // Print distance\n    Serial.print(F(\"Distance: \"));\n    if (distance \u003e= 0) {\n        Serial.print(distance);\n        Serial.println(F(\" cm\"));\n    } else {\n        Serial.println(F(\"-\"));\n    }\n\n    // Wait\n    delay(250);\n}\n```\n\n### Measure distance in Inches\n\n```c++\nvoid loop()\n{\n    float distance;\n\n    // Measure distance in Inch\n    distance = hcsr04.getDistanceInch();\n\n    // Print distance\n    Serial.print(F(\"Distance: \"));\n    if (distance \u003e= 0) {\n        Serial.print(distance);\n        Serial.println(F(\"\\\"\"));\n    } else {\n        Serial.println((\"-\"));\n    }\n\n    // Wait\n    delay(250);\n}\n```\n\n\n## Library dependencies\n\n* None\n\n\n## Library installation\n\nPlease refer to the [Wiki](https://github.com/Erriez/ErriezArduinoLibraries/wiki) page.\n\n\n## More Arduino Libraries from Erriez\n\n* [Erriez Libraries](https://github.com/Erriez/ErriezArduinoLibraries)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferriez%2Ferriezhcsr04","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferriez%2Ferriezhcsr04","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferriez%2Ferriezhcsr04/lists"}