Introduction: ANALOG ULTRASONIC SENSOR for DISTANCE MEASURMENT
This instructables will deal with how to use an ultrasonic sensor connected to Arduino and to measure accuratly distances from 20cm to 720cm.
Step 1: The GY-US42V2
I used the famous GY-US42V2 which can run under 4 ways:
-pulse output with a special library to install (SR04.h) not tested
-I2C communication with a special library SoftI2Cmaster.h (not tested).
-I2C with no special library with this pin map:
- VCC to VCC,
- A5 (atmega328 SCL) to CR
- A4 (atmega328 SDA) to DT
- GND to GND
Link to the atmega328 with no pull up resistance, not a very good measurment.
-Serial RX TX with a special library SoftwareSerial.h and this pin map:
- VCC to VCC
- GND to GND
- pin D2 to CR
- pin D3 to DT
- VCC to PS
More accurate and the best I think
Some technical specifications:
GY-US42 is low cost, high-quality range range module.
Operating voltage 3-5 V, small power consumption, small size, easy installation.
Its principle of operation is that the probe emits ultrasonic waves irradiated by the measured object, the probe receives return sound waves, uses the time difference, calculates the actual distance. There are three ways to read the module data, i.e., serial UART (TTL level), IIC, pulse mode pwm,
The serial transmission speed is 9600bps and 115200bps, can be configured, there is a continuous, set the output in two ways, you can save the power settings.
IIC can modify the internal address to facilitate the IIC bus at the same time accessing several modules. The pulse pwm output is the same as sr04.
The module can be adapted to another working environment and connected directly to the microcontroller.
When the computer needs USB in the TTL module, a direct connection.
The IIC mode can be directly linked to APM, Pixhawk and other flight control.
Provides Arduino, 51, STM32 communication procedures of the microcontroller, does not provide circuits and internal microcontroller source.
As a result of using the transceiver an ultrasonic probe is built in, the range from the blind area is about 20 cm. Within 20 cm, the range is invalid.
Voltage: 3-5 V
Built-in MCU calculates distance
IIC and serial and pwm
Frequency: 15 Hz (full range)
Current: 9mA (VCC = 5V)
Step 2: The Schematic and the Archive Within Sketch and Libs
I made a clone board of arduino with an atmega328 PU non P, I have got a long time ago. I type 2 sketch called:
- RADARI2C for I2C running without special library
- RADARserial with SoftwareSerial.h
You will also find the original sketch and the libs supplied for this sensor.
Step 3: Conclusion
This kind of sensor will be used as a sort of rear parking sensor but for an outdoor use, this system could be disturbed by the wind which deviates the sound. Be carefull.
Thanks to all website needed to edit this instructable.