When your car is turning in a narrow alley, you can hear the parking sensor warning you that there is an obstacle behind you. It recognizes the presence or absence of objects thanks to an ultrasonic distance sensor.
Ultrasound is sound waves that travel through space. What makes ultrasound different from the ordinary sound is the pitch. A person can not perceive the frequency of sound waves over 16-20 kHz, but ultrasound has a range of over 20,000 Hz, so it is beyond audibility.
The module automatically sends eight 40khz square waves to detect whether there is a signal return. Low voltage, low power consumption and strong anti-interference.
The ultrasonic wave is capable of propagating in liquids, solids, and gases. It has the same directionality as shifting small elements of the medium. As the wave passes through, volumes of the medium alternately compress and become discharged, with the distance between areas that are close together being comparable to the wavelength of the ultrasound. How much the medium will be compressed and discharged at a particular amplitude of perturbation depends on its specific acoustic impedance.
This is an ultrasonic distance meter, which operates on the technology of sound echolocation. It has IP66 moisture protection. The rangefinder’s resistance to moisture makes it possible to use it in damp conditions, such as car washes with automation.
Only the sensor itself is protected against moisture. If water gets on the circuit board of the unit, it could be damaged.
Operating principle of JSN-SR04T
The sensor determines the distance to the object by the time interval when the signal was sent, and the echo returned. As soon as the echo is received, a pulse is immediately generated and sent to the controller. It takes only a fraction of a second, so you can quickly detect the presence or absence of an obstacle based on the results. It is important to consider if the object is between 9,84 and 196,85 inches.
Connecting the JSN-SR04T Sensor
Connect the sensor according to the diagram below. To do this, connect 5V and GND power to the corresponding pins of the sensor, Trig to D7, Echo to D6.
Connecting the SR04 Library
To work with the sensor, you don’t need to connect any libraries. You can send a short sound pulse and calculate the distance based on the time you get when the pulse is reflected from the object. The sketch from the article about connecting HC-SR04 will also work with this sensor.
To work with the JSN-SR04T sensor, we add a library to the Arduino IDE. Open the library manager and find the library HCSR04 ultrasonic sensor by gamegine.
HCSR04 hc(13, 12); // Initialize Pin D7, D6
Serial.println(hc.dist()); // Print in centimeters the value from the sensor
Port monitor (Console)
Load the sketch and open the “Port Monitor”.