HC-SR04 Reader Module to Relieve Arduino
by Nikus in Circuits > Arduino
7930 Views, 32 Favorites, 0 Comments
HC-SR04 Reader Module to Relieve Arduino
![mini_instructables.jpg](/proxy/?url=https://content.instructables.com/FOD/K7PF/JLPEFFX7/FODK7PFJLPEFFX7.jpg&filename=mini_instructables.jpg)
![This thing lets you delegate a task of measuring the distance with an ultrasonic sensor from Arduino](/proxy/?url=https://content.instructables.com/FI8/G5F0/JLPEFGLC/FI8G5F0JLPEFGLC.jpg&filename=This thing lets you delegate a task of measuring the distance with an ultrasonic sensor from Arduino)
HC-SR04 ultrasonic distance sensor is very popular in robotics. Basically, any object avoiding robot uses this sensor. And it is great of course, easy to use cheap and accurate but once you start building more complex robots you can start to see a problem and this problem is time. It takes a lot of time to measure distance with this sensor, there are some alternatives like sharp sensors that can detect objects super fast but output of them is binary so you can detect if there is an object within specified range but you don't know how far. For some robots those sensors are perfect but there is another problem - price. They are almost 10 times more expensive than HC-SR04. So here I started thinking about combining those two together. And I come up with an idea for a module that you can plug to the HC-SR04 and delegate the task of reading the distance to the Attiny microcontroller, output can be binary and your main microprocessor is relieved! Simple but beautiful solution and cheap at the same time :) Want to know where you can use such sensor? Keep reading or watch a video.
JLCPCB 10 boards for $2: https://jlcpcb.com
List of Parts
![ultrasonicradar (2).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F7J/4H1Y/JLGV4L62/F7J4H1YJLGV4L62.jpg&filename=ultrasonicradar (2).Movie_Migawka.jpg)
List of parts is not very long, you can find most of them at any local electronic shop, there are also links to online stores if I found something:
- HC-SR04
- Attiny45/85
- Potentiometer
- Breakaway headers Female and Male
- 1206 SMD resistor (better to buy in a kit)
- 1206 LED
You will also need some tools like:
If you want to buy a PCB for this project, check out my Tindie store:
![I sell on Tindie](https://d2ss6ovg47m0r5.cloudfront.net/badges/tindie-larges.png)
PCB, Schematic and Files
![UltraSonicSonar.jpg](/proxy/?url=https://content.instructables.com/FMT/DM87/JLMKJL28/FMTDM87JLMKJL28.jpg&filename=UltraSonicSonar.jpg)
Above you can find all of the files including schematic and PCB design, there are also Gerber files that you can use to manufacture this PCB. Feel free to modify the files for your own needs remember that all of my projects are shared as noncommercial so you can't sell them.
Schematic is super simple, there are just a few components, you can use it to mount everything on PCB properly.
If you don't want to use PCB for this project you can connect all of that on a breadboard, it will be a little bit bigger but if you can't solder that's the easiest way for you!
Soldering
![ultrasonicradar (3).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FML/9RLW/JLGV4L5B/FML9RLWJLGV4L5B.jpg&filename=ultrasonicradar (3).Movie_Migawka.jpg)
![ultrasonicradar (4).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FZL/EJJ4/JLGV4L4S/FZLEJJ4JLGV4L4S.jpg&filename=ultrasonicradar (4).Movie_Migawka.jpg)
![ultrasonicradar (5).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FAO/94K1/JLGV4L4Q/FAO94K1JLGV4L4Q.jpg&filename=ultrasonicradar (5).Movie_Migawka.jpg)
![DSC00004.JPG](/proxy/?url=https://content.instructables.com/FUQ/8BTS/JLPEFDXI/FUQ8BTSJLPEFDXI.jpg&filename=DSC00004.JPG)
![DSC00008.JPG](/proxy/?url=https://content.instructables.com/FMB/53ZT/JLPEFDXM/FMB53ZTJLPEFDXM.jpg&filename=DSC00008.JPG)
Soldering is pretty straightforward. Start with the smallest components (resistor and LED) and then move on to bigger and bigger ones, that way it will be simpler for you to solder all of that. Make sure that polarity is right for all of the components and that there are no any shorts. If you don't want to use PCB for this project and you want to connect all of that on a breadboard just skip this step and follow the schematic from step above.
Upload a Code
![ultrasonicradar (8).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FS5/8HLG/JLGV4L0D/FS58HLGJLGV4L0D.jpg&filename=ultrasonicradar (8).Movie_Migawka.jpg)
![ultrasonicradar (12).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FPJ/SCP8/JLGV4KZD/FPJSCP8JLGV4KZD.jpg&filename=ultrasonicradar (12).Movie_Migawka.jpg)
![ultrasonicradar (7).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FK1/DWRE/JLGV4L0X/FK1DWREJLGV4L0X.jpg&filename=ultrasonicradar (7).Movie_Migawka.jpg)
Once everything is soldered on the PCB we can upload a program to the Attiny. To do so we have to connect USBasp programmer (or any other that works with Arduino IDE) to the microcontroller. Code can be found on my Github. To upload it you need to add Attiny boards to your Arduino IDE, you can find a lot of tutorials online about that, so I wouldn't explain it right there. Of course, you can change values in the code or even it's function to suit your needs.
Test and Adjust
![ultrasonicradar (6).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FEM/IQY4/JLGV4L1H/FEMIQY4JLGV4L1H.jpg&filename=ultrasonicradar (6).Movie_Migawka.jpg)
![ultrasonicradar (13).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FY8/7IMG/JLGV4KZC/FY87IMGJLGV4KZC.jpg&filename=ultrasonicradar (13).Movie_Migawka.jpg)
![ultrasonicradar (9).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FEU/I04X/JLGV4L0C/FEUI04XJLGV4L0C.jpg&filename=ultrasonicradar (9).Movie_Migawka.jpg)
When your program is ready you can plug in HC-SR04 module (take a look at the photos above to plug it correctly, otherwise you can damage the board).
You can power it with the voltage between 4V and 5V. LED on the board will light up when the distance is smaller than the distance that you set with the potentiometer. To change the distance you can use a screwdriver. When everything is working fine you can move on to the next step. If it is not, check your soldering and make sure that your circuit and my schematic matches.
Possible Applications
![ultrasonicradar (10).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F3V/QVMG/JLGV4KZV/F3VQVMGJLGV4KZV.jpg&filename=ultrasonicradar (10).Movie_Migawka.jpg)
![DSC00003.JPG](/proxy/?url=https://content.instructables.com/FFY/09CP/JLPEFDXG/FFY09CPJLPEFDXG.jpg&filename=DSC00003.JPG)
![ultrasonicradar (11).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F8N/HAT5/JLGV4KZE/F8NHAT5JLGV4KZE.jpg&filename=ultrasonicradar (11).Movie_Migawka.jpg)
![DSC00007.JPG](/proxy/?url=https://content.instructables.com/F0F/EH3D/JLPEFDXL/F0FEH3DJLPEFDXL.jpg&filename=DSC00007.JPG)
![2C0BF90F@CDFDC00D.jpg](/proxy/?url=https://content.instructables.com/FEL/A77A/JLQUW4WP/FELA77AJLQUW4WP.jpg&filename=2C0BF90F@CDFDC00D.jpg)
Congrat's that you made it to the last step! To use this module with an Arduino you have to connect VCC of the module to Arduino's 5V, GND of the module to Arduino's GND and out pin of the module to any of the Arduino pins.
How can you use it? Well, the possibilities are endless. You can use it for your robotics project, as I am going to do for my next project, more about that soon :) You can modify the code, connect a servo to it and control the servo directly from this board. You can modify it and use it without any additional, external microcontroller. It is a small board with a lot of potential and it will make my next project a lot easier.
I hope you enjoyed reading this instrucatble :) Don't forget to check out my video about this project and subscribe to my channel! Thanks for reading, happy making!