I would avoid powering the sensor from a different power sources. I believe they would at least need to share the same GND, but better share the whole power supply.
Following this closely, my next project will be using a JSN-SR04T.
I notice that the link you posted (thank you, BTW, I hadn’t seen that) is for a different type of sensor. Are they functionally equivalent? Just thinking of future projects.
I was looking at doing something like what’s described in this link:
I’ve also found this link and this link describing similar projects.
I’ve started experimenting with the JSN-SR04T recently. I got it working without any trouble and i’ve got to say that the sensor is more accurate than i expected (+/- 1cm i would say).
I’ve got everything almost set up in the same way, except i’m using an esp32. Also my JSN-SR04T is powered directly from the ESP32 via the 5v and GND pins.
sensor:
- platform: ultrasonic
trigger_pin: D1
echo_pin: D2
name: "oillevel measured distance"
id: oillevel_measured_distance
update_interval: 5s
please also keep in mind that there are different versions of this sensor. I’m not sure what the differences are, but apparently the 3.0 has “better stability”; whatever that means.
@CaptTom : that’s funny, i’m exactly working on that → a level gauge for my heating oil tank. On my testbench i got everything working fine and even mapped the entire conversion from cm to liters for my oiltank (which isn’t any normal mathematical shape unfortunately). I had read that many people have problems with the wide angle of the ultrasonic signal which is about 75°. So i tested this as well by holding the Sensor in a corner of the room, about 10 cm from both walls in the upward position, towards the ceiling. Surprisingly the sensor still worked fine and gave the right measurements. Encouraged by this i installed it in a free filler cap of my tank and installed it in the tank. Unfortunately it now only reads 0.23m, which basicly means that there is something wrong. The signal is probably bouncing of the tank-walls or perhaps even of the edge of the filler cap. I will do some more testing in the coming days (i’m still determined to get this to work one way or the other), so if you’re intererested i can keep you up to date.
Thanks assembly for posting on your progress!
I wonder if putting the sensor in a cylinder of some sort might direct the beam better and prevent it bouncing off the walls. My tank is metal, although I know many newer ones are plastic. That may make a difference, too.
My two JSN-SR0-4Ts will be arriving tomorrow. If it works in my oil tank at home, I have four fuel tanks, a water tank and two waste tanks on the boat I’d like to adapt this for next. Boat fuel gauges are notoriously inaccurate, when they’re working at all.
ok. happy to say it works!!!
the 4 wires from the sensor is plugged directly to my nodemcu. even though the nodemcu only outputs 3.3v and the sensor requires 5v, everything still works fine. phewww.
thanks for your help everyone!
See this link, there you will have the answer you are looking for.
Hi all,
I have also switched my ultrasonic sensor to a JSN-SR04T and connected it like an HC-SR04 to my ESP32 via the following pins:
trigger_pin: GPIO5
echo_pin: GPIO18
Why so ever, I can only get any values with the sensor max distances between 50-60 cm. On low distances it is working perfectly.
Any idea what can cause such an issue?
Hi @assembly
Did you figure out how to solve it?
I am also getting 0.23m no matter the real distance.
Thanks!
Yeah, I did manage to get it working. I have mine installed in a plastic cap of a fuel tank. There wasn’t enough space around the sensor so the signal would bounce against the side of the cap and therefore return a very short distance. The minimum distance the sensor can measure is approximately 20cm, if below that it will automatically return 23.
I solved it by installing it a bit further down, so it’s just barely no longer in the cap, but rather in the tank. The clearance to al sides must be quite large (depending on some other factors, like materials and depth you are trying to measure). Just try is out by holding it in a corner of a room. At some point if you come too close to the walls it will give you value 23, even though there theoretically still is a clear line of sight to the ceiling.
yes, this video should help you. How to build your own Distance Sensor, via sonar technology - YouTube
Thanks guys.
Does not work for me.
Maybe sensor is broken. I will try another one.
How it goes? No problems with getting proper signals back despite powering sensor from 5v? (are esp32 input pins 5v tolerant?)
Yeah. It has been in the oil tank for a little over a year now and it’s still working perfectly.
I have set the update interval on the sensor to once every hour or so. That’s more than enough for something which drains this slowly
Does anyone knows if there are limitations with a d1 mini. Mine doesn’t seem to work…
Hello @assembly . Mine also has values close to 23. Initially I placed it in position 1 (drawing below) and later, to test it, I placed it in position 2. It still does not give the desired values. Effectively, there is about 0.5m of the electric cable and water pipe from the pump, but the walls are about 1m away.
Unless you’re having trouble, I don’t see why!
Any tips?
Thanks
Sorry to hear you’re having trouble. If you just hold it in your hand in a room, are you then able to measure anything else than 23cm?
Mine is still reporting 23 occasionally but I filter it out in code. So just perhaps you could try to get some more measurements. If you’re able to get one measurement in lets say 20 that’s correct, you can then just ignore the other 19.
Thanks.
Yes, the problem is that I can’t get any measurements greater than 23, not even in open spaces. Everything indicates that you have problems.
In that case it’s probably a faulty sensor.
I was struggling with getting my JSN-SR04T working for a while. And had to pause to move my office… That took the last 3 months, before I finally got a chance to try it again.
A whole day of researching, reading, testing, trying again, checking voltages, replacing power supplies. Changing the ESP-32 for an 8266. Changing the USB supply for a bench supply…
Then I thought, I’ll try the other one (It took me a while to remember that it actually came in a pack of 2).
And lo… The second one has a power LED… I didn’t realise that. Because the first one was DOA and had no LED working… sigh…
I guess the good thing is I am now using the jsn_sr04t sensor platform instead of the raw ultrasonic…
I have a JSN-SR04T (version 2) paired with an esp32 receiving 5v input and gnd from the esp32 only, trigger and echo pin connected with GPIO17 and GPIO18 respectively.
My sensor stops working after running for a few hours and stops returning any value after few hours, even the power led on the JSN-SR04T stops lighting but everything starts working as soon as i restart my esp32 by taking out it’s power and connecting it again or if i disconnect the 5v and gnd from the JSN-SR04T as reconnect those.
I am unable to find the reason for this issue and I have 2 of these same setups and the issue is existent in both the setups.
Also my JSN-SR04T is not giving data in every 1 second as setup in the time interval rather it is giving data randomly and other times it shows Distance measurement timed out!