Trouble with the JSN SR04T
-
@sundeep-goel Excellent... Tank is typical eastern roof mounted PVC/GRP. That size and shape should give you no side reflections at all but your sensor would be better centralised - If you are using threaded couplers, I suggest a 90 degree under your current entry, a short extension to the centre, then down to just above 200mm from top water level. That way if you need clear access through the hatch, the pipe can be swung to one side.
The inlet is usually direct discharge which will cause ripples, easily solved by attaching a drop pipe to push the discharge under water. In the discharge is flush on the inside, a small drain pipe with a Tee can be tied to it, but may need a brick tied to the bottom to keep it from moving.
Can you confirm the JSN model number does not have 2.0 on the end which would make it 3v compatible. Otherwise you need level converter to 3.3v.
I suggest flush facing the sensor to it's housing.
From what I read the 15 microsecond is important.
I've attached a water tank sketch which you will have to alter for your setup, pins and parameters... My apologies that it's a bit of a mess as it's been through 6 different itterations...#include <T2WhisperNode.h> #include <Wire.h> #include <RTClibExtended.h> // Enable debug prints to serial monitor //#define MY_DEBUG //Comment out once all working saving memory // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_RFM69_FREQUENCY RFM69_433MHZ // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib) #define MY_RFM69_NETWORKID 101 // Default is 100 in lib. Uncomment it and set your preferred network id if needed #define MY_NODE_ID 7 //Manually set the node ID here. Comment out to auto assign //A define should be added to provide minimum power output to provide decent RSSI to the Gateway if ATC not available #include <MyConfig.h> #include <SPI.h> #include <MySensors.h> #define SN "Node7water3vWNfinalRTC" #define SV "6" #define FIRST_CHILD_ID 1 #define SECOND_CHILD_ID 2 #define THIRD_CHILD_ID 3 #define REED_PIN 3 // Arduino Digital I/O pin for button/reed switch #define BatteryOn 14 #define BatteryIn A6 #define Trigpin 17 #define Echopin 16 #define Ultrapin 15 #define flasher 6 int halfday=12; int tankdepth, tankpercent,tankvolume,distance,test,test2,counter; long duration; volatile int ultrasonic; RTC_DS3231 RTC; //we are using the DS3231 RTC // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg1(FIRST_CHILD_ID, V_LEVEL); MyMessage msg2(SECOND_CHILD_ID, V_LEVEL); MyMessage msg3(THIRD_CHILD_ID, V_VOLTAGE); unsigned long SLEEP_TIME = 0;//1800000; Sleep time between reports (in milliseconds) void setup () { pinMode(REED_PIN, INPUT_PULLUP);//Output of DS3231 INT pin is connected to D3 INT1 for RTC wake-up pinMode(BatteryOn, OUTPUT);//WN battery sample activation pinMode(BatteryIn, INPUT);//WN ADC for battery read pinMode(Ultrapin,OUTPUT); pinMode(Trigpin, OUTPUT); pinMode(Echopin,INPUT); pinMode(flasher,OUTPUT); analogReference(INTERNAL);//All voltage reads are to 1.1 internal datum sleep(100);//Allow things to settle was 1000 Wire.begin (); RTC.begin(); RTC.adjust(DateTime(__DATE__, __TIME__)); //set RTC date and time to COMPILE time //clear any pending alarms RTC.armAlarm(1, false); RTC.clearAlarm(1); RTC.alarmInterrupt(1, false); RTC.armAlarm(2, false); RTC.clearAlarm(2); RTC.alarmInterrupt(2, false); //Set SQW pin to OFF RTC.writeSqwPinMode(DS3231_OFF); //Set alarm1 every hour at XX:50 RTC.setAlarm(ALM1_MATCH_MINUTES, 0, 50, 0, 0);//set wake-up time here RTC.alarmInterrupt(1, true);//Alarm on } void presentation(){ // Send the sketch version information to the gateway and Controller sendSketchInfo(SN, SV); // Register binary input sensor to sensor_node (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. present(FIRST_CHILD_ID, S_DUST); present(SECOND_CHILD_ID, S_DUST); present(THIRD_CHILD_ID, S_MULTIMETER); } void loop(){ // Power up US VON(); sleep(100);//Delay to stabilise digitalWrite(Trigpin,HIGH); sleep (100); digitalWrite(Trigpin,LOW); sleep(100);/// Allow decay of pulse int voltread; counter=0; tankdepth=0; while ((tankdepth<350||tankdepth>1130)&&counter<=10){//10 attempts to get proper range, recalibrated 6/7/2019 READULTRASONIC(); counter++; } //Recalibrated 6/7/2019 -Depth to physical cut-off 1112, surface full 380, range 732, metered 1812L, factor 2.475 //Recalculated-Sensor cut-off 1101, surface 362, range 739, metered 1812L, factor 2.45 float tankpercent=100-((1101-tankdepth)/7.39);//750 effective range int tankvolume=(1101-tankdepth)*2.45;//Set to low level cut off Sensor-Recalibrated 6/7/2019 from 2.3727 //Total recalulated volume 1812 litres if(tankdepth>350&&tankdepth<1150){//Don't report if value is outwith known range VOFF(); sleep(100); send(msg1.set(tankvolume));//This is actual volume sleep(100); send(msg2.set(tankpercent,1));//This is remainder to start of 39cm Freeboard sleep(100); } // } VOFF();//If 2nd flash, reading sent, only 1 is fail // Call for battery reading, send in every 12th RTC call? if(halfday==12){ digitalWrite(BatteryOn, HIGH); voltread = analogRead(BatteryIn); float voltage = (7.272 * voltread) / 1024; sleep(5); digitalWrite(BatteryOn, LOW); send(msg3.set(voltage,2)); sleep(50); voltread=0; sleep(50); halfday=0;//Reset for 12 hourly cycle } halfday++;//Increment hourly cycle // Rearm alarm Wire.begin(); RTC.begin(); RTC.alarmInterrupt(1, true); sleep(50); Wire.end(); sleep(50); //Go deep sleep until RTC interrups sleep(digitalPinToInterrupt(REED_PIN),FALLING, SLEEP_TIME); sleep(100);///Time to recover //First clear the alarm Wire.begin(); RTC.begin(); RTC.armAlarm(1, false); RTC.clearAlarm(1); RTC.alarmInterrupt(1, false); } // end of loop void VON(){ digitalWrite(Ultrapin, HIGH); digitalWrite(flasher,HIGH); sleep (6); digitalWrite(flasher,LOW); } void VOFF(){ digitalWrite(Ultrapin, LOW); sleep (10); digitalWrite(flasher,HIGH); sleep (6); digitalWrite(flasher,LOW); } void READULTRASONIC(){//JSN-SR04-2.0 //Main loop checks valid range on a defined number of readings tankdepth=0; duration=0; distance=0; test=1; test2=3; // Normal range should lie between 389 and 989 absolutely empty is 1520 while (test!=test2){// Get two consecutive readings digitalWrite(Trigpin, LOW); delayMicroseconds(50);//Was 100 digitalWrite(Trigpin, HIGH); delayMicroseconds(15);//Was 150 digitalWrite(Trigpin, LOW); duration = pulseIn(Echopin, HIGH); distance = duration/5.82;//This is in mm if (test!=distance){ test=distance; distance=0; } else{ test2=distance; } delay(100); } tankdepth=distance; }@zboblamont said in Trouble with the JSN SR04T:
but your sensor would be better centralised
I thought about this, however, our tanks have a typical float ball which will mess up the reflections from the center. This was one of the major reasons for putting the sensor off-center and also inside a standtube.
![0_1563969848049_ball-float-valve-500x500.jpg]
(/assets/uploads/files/1563969850870-ball-float-valve-500x500.jpg)@zboblamont said in Trouble with the JSN SR04T:
I suggest a 90 degree under your current entry, a short extension to the centre, then down to just above 200mm from top water level
Can you please elaborate on this? do you mean something like?

if yes, wont there be reflections from the elbow ?
@zboblamont said in Trouble with the JSN SR04T:
Can you confirm the JSN model number does not have 2.0
the board does not have a number on it. The link to the item is : link text. Seem to be a non 2.0 version. However, since the unit is getting trigged, and also detecting echos - can the operating voltage still be an issue ?
@zboblamont said in Trouble with the JSN SR04T:
From what I read the 15 microsecond is important.
I'll try with 15 us, changing the library is not a big deal.
I'll also try adding a voltage divider across the ECHO output into the GPIO pin to see if that makes a differnce.
-
@zboblamont said in Trouble with the JSN SR04T:
but your sensor would be better centralised
I thought about this, however, our tanks have a typical float ball which will mess up the reflections from the center. This was one of the major reasons for putting the sensor off-center and also inside a standtube.
![0_1563969848049_ball-float-valve-500x500.jpg]
(/assets/uploads/files/1563969850870-ball-float-valve-500x500.jpg)@zboblamont said in Trouble with the JSN SR04T:
I suggest a 90 degree under your current entry, a short extension to the centre, then down to just above 200mm from top water level
Can you please elaborate on this? do you mean something like?

if yes, wont there be reflections from the elbow ?
@zboblamont said in Trouble with the JSN SR04T:
Can you confirm the JSN model number does not have 2.0
the board does not have a number on it. The link to the item is : link text. Seem to be a non 2.0 version. However, since the unit is getting trigged, and also detecting echos - can the operating voltage still be an issue ?
@zboblamont said in Trouble with the JSN SR04T:
From what I read the 15 microsecond is important.
I'll try with 15 us, changing the library is not a big deal.
I'll also try adding a voltage divider across the ECHO output into the GPIO pin to see if that makes a differnce.
@sundeep-goel Looking back at the tank photo your inlet is at the opposite side of the tank and presumably your sensor head is just over 200mm to the top water level when full? There should be no way that head is seeing the float when full even if the float is directly below the hatch.
I'm confused by what you are saying about the board - Accepted it is the 5v version, but you say you are detecting echo away from the tank, but is the distance reliably and consistently correct?
Presumably this is via a 5v-3.3v level converter?You misunderstood the bend suggestion - Ultrasonics don't handle bends well but cables do ;). I was looking at the possibility of extending the cable pipe with the sensor on the end pointing down nearer centre. Unfortunately that will be very close to the float if it's a long arm.
What you could try is tying the float up until level drops and hang the sensor through the hatch and to see if it works reliably there.
If it does, you may have to find a source a replacement float valve with a shorter arm, or possibly find a compact version usually marketed as "silent" (The float in these rises up a tube to close the valve, but unlike the arm type they run at full flow longer until the last few cm).
Let's see what your tests reveal.... -
@sundeep-goel Looking back at the tank photo your inlet is at the opposite side of the tank and presumably your sensor head is just over 200mm to the top water level when full? There should be no way that head is seeing the float when full even if the float is directly below the hatch.
I'm confused by what you are saying about the board - Accepted it is the 5v version, but you say you are detecting echo away from the tank, but is the distance reliably and consistently correct?
Presumably this is via a 5v-3.3v level converter?You misunderstood the bend suggestion - Ultrasonics don't handle bends well but cables do ;). I was looking at the possibility of extending the cable pipe with the sensor on the end pointing down nearer centre. Unfortunately that will be very close to the float if it's a long arm.
What you could try is tying the float up until level drops and hang the sensor through the hatch and to see if it works reliably there.
If it does, you may have to find a source a replacement float valve with a shorter arm, or possibly find a compact version usually marketed as "silent" (The float in these rises up a tube to close the valve, but unlike the arm type they run at full flow longer until the last few cm).
Let's see what your tests reveal....@zboblamont said in Trouble with the JSN SR04T:
hang the sensor through the hatch and to see if it works reliably there
Got you, will try this and a couple of others. Will post back the results.
On a related topic, is this sensor good sensing water level [link text](GY-VL53L0XV2 Laser Distance Module I2C IIC 3.3V/5V
https://s.click.aliexpress.com/e/73Fe2bm) -
@zboblamont said in Trouble with the JSN SR04T:
hang the sensor through the hatch and to see if it works reliably there
Got you, will try this and a couple of others. Will post back the results.
On a related topic, is this sensor good sensing water level [link text](GY-VL53L0XV2 Laser Distance Module I2C IIC 3.3V/5V
https://s.click.aliexpress.com/e/73Fe2bm)@sundeep-goel No idea !
-
@sundeep-goel No idea !
@zboblamont said in Trouble with the JSN SR04T:
The sensor is working perfect outside the tank - tested both with 10us and 15us. Also, same with / without a voltage divider.
Saw a possible issue in the code
Ultrasonic ultrasonic1(4, 13); // An ultrasonic sensor HC-04 Ultrasonic ultrasonic2(4, 12); // An ultrasonic sensor HC-04Was using same trigger pins on the esp for both sensor, ideally this should not have been creating a problem. but just to be sure, tried with only one sensor - worked fine outside the tank
Inside the tank in all cases, back to square one i.e. readings between 20-25cm only.
For now , putting this sensor aside and switching to the IR laser sensor VL53L0X. Lets see how that does, will post back the results soon
-
@zboblamont said in Trouble with the JSN SR04T:
The sensor is working perfect outside the tank - tested both with 10us and 15us. Also, same with / without a voltage divider.
Saw a possible issue in the code
Ultrasonic ultrasonic1(4, 13); // An ultrasonic sensor HC-04 Ultrasonic ultrasonic2(4, 12); // An ultrasonic sensor HC-04Was using same trigger pins on the esp for both sensor, ideally this should not have been creating a problem. but just to be sure, tried with only one sensor - worked fine outside the tank
Inside the tank in all cases, back to square one i.e. readings between 20-25cm only.
For now , putting this sensor aside and switching to the IR laser sensor VL53L0X. Lets see how that does, will post back the results soon
@sundeep-goel said in Trouble with the JSN SR04T:
putting this sensor aside and switching to the IR laser sensor VL53L0X.
replaced JSN SR04T with VL53L0X

So far the tests in a experimental setup (i.e. using a mug of water as a reflective surface are good), will install in the tank tomorrow morning, fingers crossed.
-
@sundeep-goel said in Trouble with the JSN SR04T:
putting this sensor aside and switching to the IR laser sensor VL53L0X.
replaced JSN SR04T with VL53L0X

So far the tests in a experimental setup (i.e. using a mug of water as a reflective surface are good), will install in the tank tomorrow morning, fingers crossed.
@sundeep-goel said in Trouble with the JSN SR04T:
will install in the tank tomorrow morning, fingers crossed
Installed under a tank nipple (needed to attach to lower end, was getting issues at the end)

getting steady readings now

in brief, too many issues with the JSN SR04T sensor in my tank, Laser TOF Sensor VL53L0X is better and cheaper in given setup.
-
@sundeep-goel said in Trouble with the JSN SR04T:
will install in the tank tomorrow morning, fingers crossed
Installed under a tank nipple (needed to attach to lower end, was getting issues at the end)

getting steady readings now

in brief, too many issues with the JSN SR04T sensor in my tank, Laser TOF Sensor VL53L0X is better and cheaper in given setup.
@sundeep-goel Glad you found a solution, hopefully it will continue to prove reliable over time in your environment, presumably dust is not a problem from the presence of water, nor condensation through ventilation (loose lid)
Out of curiosity, what the range is that version, I've seen 1m and 2m quoted for the same model number..? -
@sundeep-goel Glad you found a solution, hopefully it will continue to prove reliable over time in your environment, presumably dust is not a problem from the presence of water, nor condensation through ventilation (loose lid)
Out of curiosity, what the range is that version, I've seen 1m and 2m quoted for the same model number..?@zboblamont said in Trouble with the JSN SR04T:
what the range is that version, I've seen 1m and 2m quoted for the same model number..?
I have tested till around 2meters succesfully. I read somewhere that you can also switch to another mode to increase range, haven't tried that though.
Let me know if you need more information, as of now I have added only one sensor, will be adding one more next week, so can run more tests then
-
Hello everyone, I am having problems with the jsn-sr04t V2 sensor and I came to this forum looking for a solution.
In my case I am getting erroneous readings in a cylindrical water tank 3.5 meters high.
I am measuring once a minute (below a sample) and the readings are disparate. Do not match the actual measurement.
109 cm 2019-11-05 21:01:42
141 cm 2019-11-05 21:00:42
90 cm 2019-11-05 20:59:42
168 cm 2019-11-05 20:58:41
170 cm 2019-11-05 20:57:41
111 cm 2019-11-05 20:56:41
143 cm 2019-11-05 20:55:41I am using a 220V switching power source at 5V and 700 mA maximum. From the food source a Wemos D1 mini (with esp8266) and from the 5V and GND pins to the sensor.
In tests outside the tank, I used the USB power of my notebook and the samples were wrong, however when I powered up with an original Motorola fast-charge charger, the samples were perfect.
Is it possible to think that the 700mA source (from china) is not enough? Or that the power source may be putting some noise to the sensor signal?
-
Hello everyone, I am having problems with the jsn-sr04t V2 sensor and I came to this forum looking for a solution.
In my case I am getting erroneous readings in a cylindrical water tank 3.5 meters high.
I am measuring once a minute (below a sample) and the readings are disparate. Do not match the actual measurement.
109 cm 2019-11-05 21:01:42
141 cm 2019-11-05 21:00:42
90 cm 2019-11-05 20:59:42
168 cm 2019-11-05 20:58:41
170 cm 2019-11-05 20:57:41
111 cm 2019-11-05 20:56:41
143 cm 2019-11-05 20:55:41I am using a 220V switching power source at 5V and 700 mA maximum. From the food source a Wemos D1 mini (with esp8266) and from the 5V and GND pins to the sensor.
In tests outside the tank, I used the USB power of my notebook and the samples were wrong, however when I powered up with an original Motorola fast-charge charger, the samples were perfect.
Is it possible to think that the 700mA source (from china) is not enough? Or that the power source may be putting some noise to the sensor signal?
@dmacros My guess would be noise, I had similar problems when I tried using a 5v booster only for the JSN, the boards seem quite "temperamental" over voltage supplies.
I understood the Wemos to be 3.3v logic anyway, so powering the JSN off the 3.3v pin would be normal, and the regulator should kill noise sufficiently to allow the JSN to work reliably.I have two of these installed, one works perfectly on 3.3v to maximum range, the other has problems at maximum unless fed 5vDC from a battery, yet fine for closer range (<1.5m) at 3.3v.
Have ordered another JSN in hopes it is better behaved at 3.3v, it must be a QC issue...Today the second (troublesome) one is working at range on 3.3v, but it is not reliable. I have it try max 10 times (I think) to get a valid reading every hour, so it does not kill the batteries much.
Whether yours will work at 3.5m or not you can only test, but having a mains supply means battery power is no barrier.. -
@zboblamont said in Trouble with the JSN SR04T:
what the range is that version, I've seen 1m and 2m quoted for the same model number..?
I have tested till around 2meters succesfully. I read somewhere that you can also switch to another mode to increase range, haven't tried that though.
Let me know if you need more information, as of now I have added only one sensor, will be adding one more next week, so can run more tests then
@Sundeep-Goel did u face any issues due to water vapours or water in general?