JSN-SR04T : A better Ultrasonic Sensor?
All my content is free.
If you feel that my videos are helping and you would like to contribute, you can toss some coins in the Tip Jar via PayPal.
Select amount then click the “Donate” button.
If you have been experimenting with the Arduino platform, I’m sure you have at some point played around with the HC-SR04 Ultrasonic sensor module.
It’s easy to use, pretty inexpensive and easy to find.
But it does have a downside….. the form factor…
All the components, connections and the ultrasonic sensors (2 of them) are on the same PCB.
That can be an issue in some projects.
You see the ultrasonic sensors need to be positioned in a way that makes sense to calculate the distance, and that means that the whole board itself needs to come along with it.
The board also requires 4 connections to the Arduino, GND, Voltage, Trigger and Echo.
So if you don’t want 4 long wires running from the HS-04 to your Arduino, power supply and any other parts in your project need to tag along as well.
Now… What if I told you that there’s another option that might take care of these problems?
Today we will have a look at the JSN-SR04T (version 2) and see if it’s any good and can replace the HC-SR04.
Quick overview of the JSN-SR04T
The JSN-SR04T is kinda new (to me anyway), and it brings some improvements compared to the HC-SR04.
- First of course is the actual ultrasonic sensor is not soldered onto the PCB, instead it’s connected with a pretty long external cable (2.5 Meters).
- Second instead of having 2 separate sensor (one to send and one the receive) it has only one that includes both. Kinda like the ones you see on car bumpers.
- Third the sensor itself is incased in a waterproof enclosure, which might be useful if you want to locate it outside.
So those are the main advantages, but of course like anything else, it does have some downsides.
- This sensor being fairly new, doesn’t seem to play well with the popular Arduino libraries used for the HC-SR04.
- The quality control, from my research, seems to be hit or miss… Mine does send off some zero readings sometimes?
- The minimum distance this sensor can measure, is 20cm… Compared to the 2cm of the HC-SR04.
- It’s a bit more expensive than the HS-S04 (around 15$ CND).
Now the library problem, is not a big deal, since it’s pretty easy to write some Arduino code to use this thing.
But I will be testing a bunch of libraries in the next tutorial to see if any play nice with this sensor.
The quality control is a little worrying, but like I talked about in another video (here) you should always get two of anything. That way if you do receive a bad one out of two, you can send it back without having to wait to start your project.
Finally, yes it is more expensive, but the reason is obvious why… The sensor has a waterproof case and that long connecting wire.
The fact that you can locate the sensor far away from the rest of your project, might be worth it!
As you can see, the HS-S04 and the JSN-SR04T connections are the same.
Even the order of the pins are shared: V+, TRIGGER, ECHO, GND
I’m using the Arduino NANO for this tutorial but you can use pretty much any standard Arduino (UNO, MEGA, etc…)
Connections for this tutorial:
V+ is connected to the 5V pin of the Arduino
GND is connected to the GND pin of the Arduino
TRIG is connected to pin 9 of the Arduino
ECHO is connected to pin 10 of the Arduino
This will be a simple tutorial on how to create some code to use the sensor and display the results on the Serial Monitor window.
In the next tutorial I will use the sensor in a more involved project, so stay tuned for that one 🙂
Keep in mind that this sensor cannot calculate distance below 20cm or above 600cm.
The seller of this sensor included some code, but with mine I had to change a value to make it work correctly.
Those values are the delay()’s between sending and receiving.
Originally it was delay(2) and delay(10), it wasn’t stable with those, when I changed it to delay(2) and delay(15) the results were much better.
As always please check out the tutorial video for more information.
So what do I think about this sensor?
I believe that for some projects this sensor is much better suited compared to the HC-SR04.
Not having to locate the whole PCB where you want to position the sensor is great!
The waterproof case can open up a lot of possibilities when it comes to placement.
The quality control is a little worrying, but with time that might get better, as well as the library compatibility.
The price, although more expensive, is okay when you think of the extras you are getting.
In conclusion this sensor will not completely replace the HS-S04 in all projects, but it’s great to have options, and the JSN-SR04T has a place for those projects that need the capabilities that it brings to the table.
Hope you found this interesting and stay tuned for a bigger project using this sensor coming soon.
Copy and Paste the above code/sketch in your Arduino IDE software.
No libraries needed.