{"id":16692620,"url":"https://github.com/platisd/sonicdisc","last_synced_at":"2025-03-21T18:33:44.825Z","repository":{"id":145722438,"uuid":"100971557","full_name":"platisd/sonicdisc","owner":"platisd","description":"A 360° ultrasonic scanner","archived":false,"fork":false,"pushed_at":"2020-05-01T04:45:42.000Z","size":1378,"stargazers_count":43,"open_issues_count":2,"forks_count":13,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-18T04:12:31.831Z","etag":null,"topics":["arduino","atmega328p","automotive","hc-sr04","i2c","interrupts","smartcar","ultrasonic"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/platisd.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}},"created_at":"2017-08-21T16:23:31.000Z","updated_at":"2025-03-04T20:52:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"c85907f6-06a4-4c28-84b4-0badac2b084d","html_url":"https://github.com/platisd/sonicdisc","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/platisd%2Fsonicdisc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Fsonicdisc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Fsonicdisc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Fsonicdisc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/platisd","download_url":"https://codeload.github.com/platisd/sonicdisc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244849833,"owners_count":20520801,"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":["arduino","atmega328p","automotive","hc-sr04","i2c","interrupts","smartcar","ultrasonic"],"created_at":"2024-10-12T16:27:51.548Z","updated_at":"2025-03-21T18:33:44.778Z","avatar_url":"https://github.com/platisd.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SonicDisc\nA 360° ultrasonic scanner that talks over I2C using an Atmega328P and eight HC-SR04 ultrasonic sensors.\n\n![sonicdisc](http://i.imgur.com/tKw5zAx.jpg)\n\n## Overview\nSonicDisc is a sensor that allows you to sense your surroundings. It utilizes 8 ultrasound sensors (HC-SR04) placed at 45° angle from each other, that can measure distances from practically every direction. It can be used in hobby-grade automotive applications, e.g. autonomous driving, obstacle detection etc or wherever quickly determining surrounding distances is relevant.\n\nThe sensor transmits the collected data over I2C and uses a separate line to signal, with a short pulse, the existence of a new set of measurements. It can be mounted on top of an Arduino UNO or used standalone. Due to the nature of the HC-SR04 sensors, the measurements can be noisy, therefore it is suggested that they are filtered. A basic Arduino example that receives and filters the incoming data can be found in [examples/SonicDiscReader](examples/SonicDiscReader).\n\nYou can find the software running on the SonicDisc in [firmware/](firmware/), the PCB design in Eagle CAD format inside [hardware/](hardware/eagle) and more sample applications using the SonicDisc in [examples](examples/).\n\nRead the story behind the module at [platis.solutions](https://platis.solutions/blog/2017/08/27/sonicdisc-360-ultrasonic-scanner/).\n\n## How does it work\nSonicDisc is comprised of an Atmega328P microcontroller that triggers all the ultrasound sensors at the same time, receives the echo pulses via pin change interrupts and then proceeds to calculate the detected distances. The use of interrupts, in contrast to how the HC-SR04 sensors are typically utilized, enable us to conduct all measurements at the \"same\" time which translates into new sets of `8` measurements every `10 milliseconds`.\n\nAs an I2C slave, whenever a new set of measurements is ready to be transmitted, a short pulse is sent over the `INT` pin, prompting the master to request the data. In other words the I2C master reading the data from the SonicDisc, does not have to poll but merely wait for the indicative signal and then make the I2C request. Despite not suggested, it is possible to use SonicDisc without connecting the `INT` pin to an interrupt, however the master will not be able to assure the existence of a new data.\n\n## How to connect\n| SonicDisc | Host MCU  |\n| :----:    |:----:     |\n| VCC       |  5V       |\n| GND       |  GND      |\n| SDA       |  SDA      |\n| SCL       |  SCL      |\n| INT       |  ISR      |\n\nIf you are mounting the SonicDisc on top of an Arduino UNO as a shield, you only have to (optionally but suggested) connect the `INT` signal to an ISR pin.\n\n## I2C protocol\nSonicDisc communicates using the I2C bus as a slave, meaning that it receives data from a master and responds to data requests.\n\n### Address\nSonicDisc's I2C address is currently hardcoded to `0x09`.\n\n### Set operational state\nSonicDisc has two operational states between which you can switch.\n\n| **Action**                    | **Byte to send**  | **Notes**                                   |\n| :-----------:                 |:-------------:    | :----:                                      |\n| Set state to `STANDBY`        | 0x0A              | SonicDisc's initial state                   |\n| Set state to `MEASURING`      | 0x0B              | Set to this state to start the measurements |\n\n**Arduino example:**\n```arduino\nWire.beginTransmission(0x09);\nWire.write(0x0B); // Instruct SonicDisc to start measuring\nWire.endTransmission(0x09);\n```\n### Get data\nSonicDisc responds to I2C requests with packages of `9` bytes that include an error code and sensor measurements. A typical package structure is described below.\n\nRegarding the error codes, when the first byte is a `0` then everything went well and the trailing measurements are valid. If it is `1`, it means that this set of data has already been transmitted and a measurement is currently under way. You will encounter this if you poll the sensor fast enough, without taking into consideration the `INT` signal which indicates SonicDisc is ready to transmit new data. Finally, `2` designates that the module is in standby state and no measurements are being conducted.\n\n| **Byte Index** | **Range** | **Purpose** | **Notes**                                                               |\n| :----:         |:----:   | :----:        | :----:                                                                  |\n| 0              |  0-2    | Error code    | **0**: No error, **1**: Incomplete measurement, **2**: In standby state |\n| 1              |  0-255  | Ultrasonic 0  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 2              |  0-255  | Ultrasonic 1  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 3              |  0-255  | Ultrasonic 2  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 4              |  0-255  | Ultrasonic 3  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 5              |  0-255  | Ultrasonic 4  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 6              |  0-255  | Ultrasonic 5  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 7              |  0-255  | Ultrasonic 6  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n| 8              |  0-255  | Ultrasonic 7  | **0**: Error in measurement, **1**: TBD, **2-255**: Valid distance (cm) |\n\n**Arduino example:**\n\n```arduino\nconst unsigned int PACKET_SIZE = 9;\nunsigned int packet[PACKET_SIZE] = {0};\nunsigned int packetIndex = 0;\nWire.requestFrom(0x09, PACKET_SIZE);\nwhile (Wire.available() \u0026\u0026 packetIndex \u003c PACKET_SIZE) {\n    i2cInput[packetIndex++] = Wire.read();\n}\n// Now the packet[] array holds the incoming data from SonicDisc\n```\n\n## Build one yourself\nBelow you can find the necessary components to build a SonicDisc yourself:\n\n* [SonicDisc PCB](https://www.pcbway.com/project/shareproject/SonicDisc___A_360__ultrasonic_scanner__rev_1_.html)\n* 8 x HC-SR04\n* 1 x Atmega328P-PU\n* 2 x 22pF capacitors\n* 3 x 0.1uF capacitors\n* 1 x 1206 LED\n* 1 x 1206 220Ω resistor\n* 3 x 4.7KΩ resistor\n* 1 x 5-pin header\n* 1 x 4-pin header\n* 1 x tactile switch\n* 1 x 16MHz oscillator\n* 1 x ISCP pin header\n* 1 x 10-pin stackable header\n* 2 x 8-pin stackable header\n* 1 x 6-pin stackable header\n\n## Derivative works\n* [Arduino Pro Mini version with single plane sensors](https://github.com/richardFirth/sonicdisc) by [richardFirth](https://github.com/richardFirth).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatisd%2Fsonicdisc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplatisd%2Fsonicdisc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatisd%2Fsonicdisc/lists"}