{"id":15060473,"url":"https://github.com/luigif/hcsr04","last_synced_at":"2025-04-10T05:51:18.710Z","repository":{"id":16617691,"uuid":"19372627","full_name":"luigif/hcsr04","owner":"luigif","description":"Beaglebone Black PRU code for HC-SR04 sonar","archived":false,"fork":false,"pushed_at":"2014-10-26T18:37:45.000Z","size":384,"stargazers_count":26,"open_issues_count":2,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T07:05:09.695Z","etag":null,"topics":["assembly-language","beaglebone","beaglebone-black","c","iot","pru"],"latest_commit_sha":null,"homepage":"","language":"OpenEdge ABL","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/luigif.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}},"created_at":"2014-05-02T10:46:59.000Z","updated_at":"2023-11-20T09:17:44.000Z","dependencies_parsed_at":"2022-09-05T11:01:30.265Z","dependency_job_id":null,"html_url":"https://github.com/luigif/hcsr04","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luigif%2Fhcsr04","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luigif%2Fhcsr04/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luigif%2Fhcsr04/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luigif%2Fhcsr04/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luigif","download_url":"https://codeload.github.com/luigif/hcsr04/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166926,"owners_count":21058480,"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":["assembly-language","beaglebone","beaglebone-black","c","iot","pru"],"created_at":"2024-09-24T22:59:10.558Z","updated_at":"2025-04-10T05:51:18.683Z","avatar_url":"https://github.com/luigif.png","language":"OpenEdge ABL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nBeaglebone Black PRU code to use HC-SR04 proximity sensor.\n===\n\nThere are many examples around with Beaglebone PRU code to use an HC-SR04 sonar sensor, but most are outdated, do not work or require older beagles or older kernels. \nThis repository includes everything needed to obtain a working example and can be used as a template for more complex PRU code.\n\nPrerequisites:\n\n\t* Beaglebone Black with debian 3.8.13 bone47\n\t* HC-SR04 sensor\n\t* Dev tools (gcc, pasm, dtc, etc.) that are already included in BBB latest images.\n\t  (If you miss them, please upgrade from http://beagleboard.org/latest-images/)\n\nHardware configuration:\n\n\t* TRIGGER\t\tP8_12 gpio1[12] GPIO44\tout\tpulldown\t\tMode: 7 \n\t* ECHO\t\t\tP8_11 gpio1[13] GPIO45\tin\tpulldown\t\tMode: 7 *** with R 1KOhm\n\t* GND\t\t\tP9_1 or P9_2\tGND\n\t* VCC\t\t\tP9_5 or P9_6\tVDD_5V\n\t\n\tMake sure there is a 1KOhm resistor between ECHO pin and your beaglebone\n\tas input pins are 3.3V while sensor emits 5V\n\n### Schematic:\n\t\n![Schematic](hc-sr04.png?raw=true)\n\n### To download the complete package to your Beaglebone Black:\n\n\twget --no-check-certificate https://github.com/luigif/hcsr04/archive/master.tar.gz -O - | tar xz\n\n### To build:\n \t\n \tcd hcsr04-master\n\tmake\n\t\n### To install driver:\n\n\tmake install\n\t\n\tIt will copy device tree driver to /lib/firmware and add it to the cape manager\n\t\n### To run:\n\n\t./hcsr04\n\n\tNote: After a first successful \"make install\", before running the hcsr04 program, \n\tyou can load the driver with the install-driver.sh script.\n\tDepending on your needs, you can configure your operating system to run the \n\tinstall-driver.sh script at boot.\n\n### Example build output after running \"make\":\n\n\t\u003e\u003e Compiling Driver\n\tdtc -O dtb -o hcsr04-00A0.dtbo -b 0 -@ hcsr04.dts\n\t\n\t\u003e\u003e Generating PRU binary\n\tpasm -b hcsr04.p\n\tPRU Assembler Version 0.84\n\tCopyright (C) 2005-2013 by Texas Instruments Inc.\n\tPass 2 : 0 Error(s), 0 Warning(s)\n\tWriting Code Image of 43 word(s)\n\t\n\t\u003e\u003e Compiling HC-SR04 example\n\tgcc -Wall -c -o hcsr04.o hcsr04.c\n\tgcc -lpthread -lprussdrv -o hcsr04 hcsr04.o\n\n\n### Example output after running \"./hcsr04\":\n\n\t\u003e\u003e Initializing PRU\n\t\u003e\u003e Executing HCSR-04 code\n\t  1: Distance = 181.52 cm\n\t  2: Distance = 181.50 cm\n\t  3: Distance = 181.50 cm\n\t  4: Distance = 181.52 cm\n\t  5: Distance = 181.93 cm\n\t  6: Distance = 181.52 cm\n\t  7: Distance = 180.64 cm\n\t  8: Distance = 181.50 cm\n\t  9: Distance = 181.06 cm\n\t 10: Distance = 181.49 cm\n\t 11: Distance = 181.04 cm\n\t 12: Distance = 181.93 cm\n\t 13: Distance = 181.47 cm\n\t 14: Distance = 181.47 cm\n\t 15: Distance = 181.91 cm\n\t 16: Distance = 181.91 cm\n\t 17: Distance = 181.47 cm\n\t 18: Distance = 182.35 cm\n\t 19: Distance = 181.49 cm\n\t 20: Distance = 181.06 cm\n\t\u003e\u003e PRU Disabled.\n\n### Reference material:\n\n- [HC-SR04 manual and datasheet](http://www.cytron.com.my/viewProduct.php?pcode=SN-HC-SR04\u0026name=Ultrasonic%20Ranging%20Module)\n- [TI PRU docs](http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Software_Development)\n- [Introduction to the BeagleBone Black Device Tree](https://learn.adafruit.com/introduction-to-the-beaglebone-black-device-tree/overview)\n- [Using a Beaglebone with an HC-SR04 sonar](http://teknoman117.wordpress.com/2013/04/30/using-a-beaglebone-with-an-hc-sr04-sonar/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluigif%2Fhcsr04","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluigif%2Fhcsr04","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluigif%2Fhcsr04/lists"}