{"id":16397512,"url":"https://github.com/marcoradocchia/hc-sr04","last_synced_at":"2025-03-21T02:32:31.667Z","repository":{"id":60015236,"uuid":"539694086","full_name":"marcoradocchia/hc-sr04","owner":"marcoradocchia","description":"Raspberry Pi Rust driver for the HC-SR04 ultrasonic distance sensor.","archived":false,"fork":false,"pushed_at":"2024-07-06T04:55:21.000Z","size":33,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T20:01:46.955Z","etag":null,"topics":["hc-sr04","raspberry-pi","raspberrypi","rust","ultrasonic-distance-sensor","ultrasonic-sensor"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcoradocchia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"marcoradocchia","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-09-21T21:38:22.000Z","updated_at":"2025-02-28T10:53:53.000Z","dependencies_parsed_at":"2024-10-28T09:16:06.447Z","dependency_job_id":"d81c1e87-2ff3-4e5b-8d8b-66d59bc040f4","html_url":"https://github.com/marcoradocchia/hc-sr04","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"62fc5f348f82928e00b466bf2c2f8c40984a4dca"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoradocchia%2Fhc-sr04","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoradocchia%2Fhc-sr04/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoradocchia%2Fhc-sr04/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoradocchia%2Fhc-sr04/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoradocchia","download_url":"https://codeload.github.com/marcoradocchia/hc-sr04/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244725589,"owners_count":20499633,"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":["hc-sr04","raspberry-pi","raspberrypi","rust","ultrasonic-distance-sensor","ultrasonic-sensor"],"created_at":"2024-10-11T05:10:18.101Z","updated_at":"2025-03-21T02:32:31.368Z","avatar_url":"https://github.com/marcoradocchia.png","language":"Rust","funding_links":["https://github.com/sponsors/marcoradocchia"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003eHC-SR04\u003c/h1\u003e\n\n  ![GitHub source size](https://img.shields.io/github/languages/code-size/marcoradocchia/hc-sr04?color=ea6962\u0026logo=github)\n  ![GitHub open issues](https://img.shields.io/github/issues-raw/marcoradocchia/hc-sr04?color=%23d8a657\u0026logo=github)\n  ![GitHub open pull requests](https://img.shields.io/github/issues-pr-raw/marcoradocchia/hc-sr04?color=%2389b482\u0026logo=github)\n  ![GitHub sponsors](https://img.shields.io/github/sponsors/marcoradocchia?color=%23d3869b\u0026logo=github)\n  ![Crates.io downloads](https://img.shields.io/crates/d/hc-sr04?label=crates.io%20downloads\u0026color=%23a9b665\u0026logo=rust)\n  ![Crates.io version](https://img.shields.io/crates/v/hc-sr04?logo=rust\u0026color=%23d8a657)\n  ![GitHub license](https://img.shields.io/github/license/marcoradocchia/hc-sr04?color=%23e78a4e)\n\u003c/div\u003e\n\nThis crate provides a driver for the **HC-SR04**/**HC-SR04P** ultrasonic\ndistance sensor on *Raspberry Pi*, using\n[rppal](https://docs.rs/rppal/0.13.1/rppal/) to access Raspberry Pi's GPIO.\n\n## Examples\n\nUsage examples can be found in the \n[examples](https://github.com/marcoradocchia/hc-sr04/tree/master/examples)\nfolder.\n\n## Measure distance\n```rust\nuse hc_sr04::{HcSr04, Unit};\n\n// Initialize driver.\nlet mut ultrasonic = HcSr04::new(\n    24,          // TRIGGER -\u003e Gpio pin 24\n    23,          // ECHO -\u003e Gpio pin 23\n    Some(23_f32) // Ambient temperature (if `None` defaults to 20.0C)\n).unwrap();\n\n// Perform distance measurement, specifying measuring unit of return value.\nmatch ultrasonic.measure_distance(Unit::Meters).unwrap() {\n    Some(dist) =\u003e println!(\"Distance: {.2}m\", dist),\n    None =\u003e println!(\"Object out of range\"),\n}\n```\n\n## Calibrate measurement\n\nDistance measurement can be calibrated at runtime using the `HcSr04::calibrate`\nmethod that this library exposes, passing the current ambient temperature as\n`f32`.\n\n```rust\nuse hc_sr04::{HcSr04, Unit};\n\n// Initialize driver.\nlet mut ultrasonic = HcSr04::new(24, 23, None).unwrap();\n\n// Calibrate measurement with ambient temperature.\nultrasonic.calibrate(23_f32);\n\n// Perform distance measurement.\nmatch ultrasonic.measure_distance(Unit::Centimeters).unwrap() {\n    Some(dist) =\u003e println!(\"Distance: {.1}cm\", dist),\n    None =\u003e println!(\"Object out of range\"),\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoradocchia%2Fhc-sr04","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoradocchia%2Fhc-sr04","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoradocchia%2Fhc-sr04/lists"}