JSN SR04T - Temperature Influencing Readings
-
I built a water level sensor for my 80,000 litre water tank based on the JSN-SR04T-2.0 ultrasonic sensor about six months ago. It is powered by 3 AA alkalines and therefore relies on being in sleep mode for most of the time.
I have experienced similar problems to many on this forum with the apparent unreliability of this sensor. In general the device spends most of the time reporting the correct water level but then has episodes of spurious reading which normally present as a depth to water level of around 220 mm. I had been thinking that I was plagued with condensation effects and I have been attending to reducing condensation with some limited success. In the last few days I have been seeing a pattern where temperature change might be influencing rogue behaviour.
I have included a thermistor in my water level sensing package so that I can do some temperature compensation of readings. This has the spin-off that I can monitor the air temperature in the tank. I have noticed over the last 5 or so days a distinct pattern where the 220 mm anomalous reading occurs when the temperature is in the range of say 13 degrees to 20 degrees celsius. Looking at the attached chart which superimposes temperature and depth to water readings it can be seen that the correct water level is being reported over night but as the morning warms up it goes bad when the temperature hits 12 to 15 degrees and stays bad until the temperature warms up to about 20 degrees. The reading then stays good during the middle of the day but as the temperature falls below 20 degrees the reading goes bad again and stays bad until the temperature has fallen to below 12 degrees or so.

I would be very interested to learn of anyone else who has observed a similar temperature influence on water level readings.
-
I built a water level sensor for my 80,000 litre water tank based on the JSN-SR04T-2.0 ultrasonic sensor about six months ago. It is powered by 3 AA alkalines and therefore relies on being in sleep mode for most of the time.
I have experienced similar problems to many on this forum with the apparent unreliability of this sensor. In general the device spends most of the time reporting the correct water level but then has episodes of spurious reading which normally present as a depth to water level of around 220 mm. I had been thinking that I was plagued with condensation effects and I have been attending to reducing condensation with some limited success. In the last few days I have been seeing a pattern where temperature change might be influencing rogue behaviour.
I have included a thermistor in my water level sensing package so that I can do some temperature compensation of readings. This has the spin-off that I can monitor the air temperature in the tank. I have noticed over the last 5 or so days a distinct pattern where the 220 mm anomalous reading occurs when the temperature is in the range of say 13 degrees to 20 degrees celsius. Looking at the attached chart which superimposes temperature and depth to water readings it can be seen that the correct water level is being reported over night but as the morning warms up it goes bad when the temperature hits 12 to 15 degrees and stays bad until the temperature warms up to about 20 degrees. The reading then stays good during the middle of the day but as the temperature falls below 20 degrees the reading goes bad again and stays bad until the temperature has fallen to below 12 degrees or so.

I would be very interested to learn of anyone else who has observed a similar temperature influence on water level readings.
@timbergetter A curious one, my guess would be direct sunlight on the diecast box and the copper pipe cooking the US board or the connections?
Both my installs are in plastic boxes and facing north, but air temps vary from 15 to 35 currently and do not affect the board (never measured the case temperature).
The only temp anomaly noted here was condensation drips forming on the heads at below -10 (Heatsinking via the steel conduit mounting), both tanks (Sewage and raw water) are underground so the temperature drift on the actual US head is minimal.
Only the sewage board is giving me false readings when below 50% which I'm convinced from earlier itterations (5v v 3.3v) are down to the lower voltage. Why this anomaly is on one board and not the other is baffling but will experiment in a month when it's emptied again so it can be relied on through winter.Perhaps a polystyrene surround to your box will both shield and protect?
-
Curious is the word. If it were an overheating issue then I wouldn’t have expected a return to stable operation while ever the temperature is above 20 degrees celsius, but I’m not ruling anything out at this stage. I noticed in one of your past sketches that you used 150 microsecond pulse-width ahead of the pulseIn() command. I am using 10 microseconds there and I cannot remember how I settled on that. I think 10 microseconds is the absolute minimum to trigger the jsn. I might play with that next. I am still running with the original set of batteries so the supply may have fallen to low volts by now so I’ll check that too. I thank you for your input.
-
Curious is the word. If it were an overheating issue then I wouldn’t have expected a return to stable operation while ever the temperature is above 20 degrees celsius, but I’m not ruling anything out at this stage. I noticed in one of your past sketches that you used 150 microsecond pulse-width ahead of the pulseIn() command. I am using 10 microseconds there and I cannot remember how I settled on that. I think 10 microseconds is the absolute minimum to trigger the jsn. I might play with that next. I am still running with the original set of batteries so the supply may have fallen to low volts by now so I’ll check that too. I thank you for your input.
@timbergetter I tried all sort of variations to try to get this device to work reliably, the minimum pulse of 10microsecond I found on a pdf and someone on a forum said 15 was found more reliable, think it's now 15.
Your temperature issue piqued my curiosity, since here the annual temperature range is -20 to +45, but with nodes in plastic boxes in the shade they do not suffer the dramatic daily temperature drift you are noting, hence direct sunlight seemed a candidate turning the diecast box into an oven. The temp shift may be affecting the board or a connector, hence the shielding suggestion with some polystyrene blocks.
Mine have reliably operated even when deep snow covered the node (antenna is mounted underside), only the condensation issue for the sensor head below -10 was an unforeseen, a kick to the conduit usually shifts the drip.
I should explain that the first US Node I couldn't get to work reliably with the first JSN at 3.3v which is what set me off on various 5v itterations, then bought the second board and copied the setup. When I tried using one of the boards with the 15microsecond pulse I found it worked reliably at 3.3v, so switched to the same arrangement for the other. This worked fine until the sewage tank was emptied which is when ghost levels began appearing. This was the same behaviour found with a 5v itteration using a booster, and no amount of damping solved it.
My conclusion is that the sewage tank uses the original board which only was reliable at a smooth 5v, hence once the tank is emptied will experiment again, or perhaps indeed buy another board.
It may be a QC issue by the manufacturer for the head or the board itself, and it has only dawned on me in typing this that there is a spare head from another version, so that gives a further aspect to investigate. -
I built a water level sensor for my 80,000 litre water tank based on the JSN-SR04T-2.0 ultrasonic sensor about six months ago. It is powered by 3 AA alkalines and therefore relies on being in sleep mode for most of the time.
I have experienced similar problems to many on this forum with the apparent unreliability of this sensor. In general the device spends most of the time reporting the correct water level but then has episodes of spurious reading which normally present as a depth to water level of around 220 mm. I had been thinking that I was plagued with condensation effects and I have been attending to reducing condensation with some limited success. In the last few days I have been seeing a pattern where temperature change might be influencing rogue behaviour.
I have included a thermistor in my water level sensing package so that I can do some temperature compensation of readings. This has the spin-off that I can monitor the air temperature in the tank. I have noticed over the last 5 or so days a distinct pattern where the 220 mm anomalous reading occurs when the temperature is in the range of say 13 degrees to 20 degrees celsius. Looking at the attached chart which superimposes temperature and depth to water readings it can be seen that the correct water level is being reported over night but as the morning warms up it goes bad when the temperature hits 12 to 15 degrees and stays bad until the temperature warms up to about 20 degrees. The reading then stays good during the middle of the day but as the temperature falls below 20 degrees the reading goes bad again and stays bad until the temperature has fallen to below 12 degrees or so.

I would be very interested to learn of anyone else who has observed a similar temperature influence on water level readings.
@timbergetter I know the frustration when a sensor doesn't behave as expected and you want to find out the root cause, but on the other hand you can suppress these 'jumps' in software pretty easy.
If you know the maximum rate of water level change in between sensor readings you can distinguish between correct and false readings and suppress the false ones. -
@timbergetter I tried all sort of variations to try to get this device to work reliably, the minimum pulse of 10microsecond I found on a pdf and someone on a forum said 15 was found more reliable, think it's now 15.
Your temperature issue piqued my curiosity, since here the annual temperature range is -20 to +45, but with nodes in plastic boxes in the shade they do not suffer the dramatic daily temperature drift you are noting, hence direct sunlight seemed a candidate turning the diecast box into an oven. The temp shift may be affecting the board or a connector, hence the shielding suggestion with some polystyrene blocks.
Mine have reliably operated even when deep snow covered the node (antenna is mounted underside), only the condensation issue for the sensor head below -10 was an unforeseen, a kick to the conduit usually shifts the drip.
I should explain that the first US Node I couldn't get to work reliably with the first JSN at 3.3v which is what set me off on various 5v itterations, then bought the second board and copied the setup. When I tried using one of the boards with the 15microsecond pulse I found it worked reliably at 3.3v, so switched to the same arrangement for the other. This worked fine until the sewage tank was emptied which is when ghost levels began appearing. This was the same behaviour found with a 5v itteration using a booster, and no amount of damping solved it.
My conclusion is that the sewage tank uses the original board which only was reliable at a smooth 5v, hence once the tank is emptied will experiment again, or perhaps indeed buy another board.
It may be a QC issue by the manufacturer for the head or the board itself, and it has only dawned on me in typing this that there is a spare head from another version, so that gives a further aspect to investigate.@zboblamont it is comforting to know that I am not the only person to have issues with this sensor, and I was thinking that was the case until I came across this amazing forum a few days ago. Things started well about 8 months ago during the peak of summer season here in Australia. For 2 to 3 months I saw none of these phantom 220 mm readings. Then as the weather cooled the phantom readings started, but I seemed to resolve the problem then for a few days at a time by drying out the sensor. So condensation seemed to play a role then. The current problem does not seem to be related to condensation, but rather operation in the modest temperature range of 13 to 20 degrees C. Anything higher than 20 degrees and it works fine, (as we head in to the Australian spring). Maybe the “oven-like” temperatures of last summer did some damage to some silicon that has only begun to show up now. I’ll keep chipping away and see what I find around the next corner.
-
@timbergetter I know the frustration when a sensor doesn't behave as expected and you want to find out the root cause, but on the other hand you can suppress these 'jumps' in software pretty easy.
If you know the maximum rate of water level change in between sensor readings you can distinguish between correct and false readings and suppress the false ones.@yveaux One of the objectives here was to detect near-full conditions while filling the tank so I can stop the pumps. I need to be able to rely on readings rather than wondering if it is a software artefact or not.
-
@yveaux One of the objectives here was to detect near-full conditions while filling the tank so I can stop the pumps. I need to be able to rely on readings rather than wondering if it is a software artefact or not.
@timbergetter I would be chary of using a cheap ultrasonic to control pumps unless talking full E&H devices at $000. I use these for monitoring levels, in the case of the raw water tank to verify the borehole topped up the raw water tank at 3am on the timer. Pump actuation is via a standard "Hawker" probe arrangement for raw water, 5 years in this one is reliable and easy to DIY, I only wish they'd use 3 core solid rather than multistrand due to corrosion.
Normally these tanks rely on a float valve and a pressure switch controlling the pump, they are usually bulletproof.. -
@timbergetter I would be chary of using a cheap ultrasonic to control pumps unless talking full E&H devices at $000. I use these for monitoring levels, in the case of the raw water tank to verify the borehole topped up the raw water tank at 3am on the timer. Pump actuation is via a standard "Hawker" probe arrangement for raw water, 5 years in this one is reliable and easy to DIY, I only wish they'd use 3 core solid rather than multistrand due to corrosion.
Normally these tanks rely on a float valve and a pressure switch controlling the pump, they are usually bulletproof..@zboblamont It’s always a human at the pump switch (or at the very least me). He must decide whether to believe the reading broadcast by the JSN or alternatively pack a ladder onto the ute, drive to top of hill, climb onto tank and pop the heavy manhole lid and take a look.
-
@zboblamont It’s always a human at the pump switch (or at the very least me). He must decide whether to believe the reading broadcast by the JSN or alternatively pack a ladder onto the ute, drive to top of hill, climb onto tank and pop the heavy manhole lid and take a look.
@timbergetter Gotcha, but it is still information rather than control, YOU are the control..
Were it a closed system (float valve/ballcock) a standard pressure switch on the pump would handle the auto-cut-off as the pressure ramps up against the closing valve.
Perhaps a further refinement might be a float switch or other high level contact to warn of imminent overflow? That way at least you have a backup indicator should the US go walkabout.
If you are certain the overnight level is correct, thermal insulation on your case might tame the temperature shift and solve your issue without figuring out which part or connection is going wrong. A little puzzled why the reported level barely appears to shift though.
My raw water tank seems fairly reliable on the ultrasonic at 3.3v, reporting every x.55 on RTC. I only monitor it to verify the borehole pump topped up the raw tank overnight after twice running dry due to a faulty pump control timer.

Coincidentally it's a WhisperNode from Oz, staggeringly good performer on 2xAA alkalines... I also built in an X attempts routine to get a reading to limit battery drain after the condensation drip incident.
Hopefully the sewage node issue is resolved in another month, it's more an annoyance than essential info.. -
@Timbergetter I also tried the JSN SR04T sensor and had problems with it. Ended up using the cheap HC-SR04 sensors on my tanks. Have 3 different tank sensors - borehole water tank up the hill, rainwater tank at house and another reverse osmosis filtered water tank. All three going for just over a year now.
Condensation issues / waterproof I resolved by quickly spraying some clear laq spray paint over the sensors. On one tank I also added little standoffs so the sensor is not sealed onto the lid of the tank but rather 5 to 10mm above the lid to let the ambient air pass over and prevent high humidity inside the tank condensing on the sensor.
And then for the code ... I added LM35 temperature sensor and added temp compsensation. Also I do a few readings and average them out.
All-in-all I now get only one or two weird readings on rare occasions - could be a spider !
Here is the last day data of the tank I have up the hill. Its showing pump cycles as well to keep tank topped up - its a weak borehole so i can only pump a little at a time. I have a separate node with relay to turn on/off pump as well as float switch down the hole to detect low water levels in the borehole.

Here is a one week graph of the same tank : temp and distance only shown

Here is one month data

We are just coming out of winter here (in South Africa!) - so temp swings of the air inside the tanks are quite radical between day and night (except the last 2 days its been getting rather warm here !)
Basically - just wanted to let you know/see that the cheap HC-SR04 sensors can do the job - and no more hiking up hills to check tank levels - and also the pumping can be automated too by the controller
-
@Timbergetter I also tried the JSN SR04T sensor and had problems with it. Ended up using the cheap HC-SR04 sensors on my tanks. Have 3 different tank sensors - borehole water tank up the hill, rainwater tank at house and another reverse osmosis filtered water tank. All three going for just over a year now.
Condensation issues / waterproof I resolved by quickly spraying some clear laq spray paint over the sensors. On one tank I also added little standoffs so the sensor is not sealed onto the lid of the tank but rather 5 to 10mm above the lid to let the ambient air pass over and prevent high humidity inside the tank condensing on the sensor.
And then for the code ... I added LM35 temperature sensor and added temp compsensation. Also I do a few readings and average them out.
All-in-all I now get only one or two weird readings on rare occasions - could be a spider !
Here is the last day data of the tank I have up the hill. Its showing pump cycles as well to keep tank topped up - its a weak borehole so i can only pump a little at a time. I have a separate node with relay to turn on/off pump as well as float switch down the hole to detect low water levels in the borehole.

Here is a one week graph of the same tank : temp and distance only shown

Here is one month data

We are just coming out of winter here (in South Africa!) - so temp swings of the air inside the tanks are quite radical between day and night (except the last 2 days its been getting rather warm here !)
Basically - just wanted to let you know/see that the cheap HC-SR04 sensors can do the job - and no more hiking up hills to check tank levels - and also the pumping can be automated too by the controller
@slt1 Out of curiosity was the JSN you trialled the 2.0 version or the original SR04T, ie the purported 3v version or the original 5v ?
Nice that you got a solution with the HC version but your type of winter is a tad different to here :joy: -
@zboblamont I bought this one https://www.hobbytronics.co.za/p/1119/waterproof-ultrasonic-distance-transducer
Looks like its supposed to be the 5V version from those specs.
-
@slt1 Out of curiosity was the JSN you trialled the 2.0 version or the original SR04T, ie the purported 3v version or the original 5v ?
Nice that you got a solution with the HC version but your type of winter is a tad different to here :joy:@zboblamont Oh - and its not really winter anymore here - only goes to last month in the screenshots previously shown. Not sure where you're from - but temp inside tanks here range from 0.69 C to 42.7 C - min / max for last year
Here is the last years graph for interest sake !

Here is my first prototype version installed on the rain tank :

-
There is a lot of very interesting observations and suggestions coming to light here and I thank everyone for their input. No-one seems to have experienced the exact observation that I have made, however I may not have defined this exact issue very well, so I’ll add a bit of clarification with this figure:

You may be wondering why the water level is stuck at 1.1 metres (depth to water) for days on end. This is a relatively large tank at 80,000 litres and outside irrigation season not much water is used. It’s just supplying water to my house at present.
The last few days have been cold with maximum temperatures below 10 º C so no spurious readings and no troubleshooting possible.
-
There is a lot of very interesting observations and suggestions coming to light here and I thank everyone for their input. No-one seems to have experienced the exact observation that I have made, however I may not have defined this exact issue very well, so I’ll add a bit of clarification with this figure:

You may be wondering why the water level is stuck at 1.1 metres (depth to water) for days on end. This is a relatively large tank at 80,000 litres and outside irrigation season not much water is used. It’s just supplying water to my house at present.
The last few days have been cold with maximum temperatures below 10 º C so no spurious readings and no troubleshooting possible.
@timbergetter said in JSN SR04T - Temperature Influencing Readings:
You may be wondering why the water level is stuck at 1.1 metres
The level variation makes sense now.
No clue what is going on with temp electronically, but couple of anomalies on the 1st fall outwith the perceived problem range briefly. Stumped what could be going awry with the board/head short of a dodgy connection.
I run max 10 readings looking for 2 consecutives within a defined range, but in your case you are reporting a value you know is incorrect?
Perhaps you could reference previous reading in the sketch to assess whether to send in the bogus signal? As your decay over time should be predictable (during irrigation season) perhaps not reporting the anomaly might be an option? -
@zboblamont Oh - and its not really winter anymore here - only goes to last month in the screenshots previously shown. Not sure where you're from - but temp inside tanks here range from 0.69 C to 42.7 C - min / max for last year
Here is the last years graph for interest sake !

Here is my first prototype version installed on the rain tank :

@slt1 I'm Scottish but currently live in Romania, very different weather altogether, -20 to +45....
Air temp inside is largely influenced by solar gain on an above ground tank, but the high thermal mass of the water means the fluid temp drift is much slower than those wild swings in air temp, topping up levels having the greater effect.
Good that you found a solution you can have confidence in, if @Timbergetter can't solve his problem, this might be an alternative solution as the climate should be similar.
The high humidity of my underground tanks dictated the button sensor approach, and insertion in a 3/4" collar gave a solid fixing for the head. Only one install is giving me grief, which I note this morning is finally passed the ghost level, another 3 weeks and I can investigate further. -
At the risk of appearing to be labouring the point I’ve just looked a the last few days and once again the JSN is giving good results, but only if (13 > Temperature >20). Strange indeed.

-
@timbergetter Not labouring the point at all, but what have you changed which might help narrow the problem?
1 - Did you review the sketch to verify the reading is double or triple verified and not reported if false compared to expected range or previous reading? Clearly not as you are still reporting incorrect readings.
2 - If the connections are Dupont, have you checked continuity for a dodgy wire, or even better soldering terminations to eliminate thermal expansion of contacts from possibilities?
3 - Have you tried changing the materials used for casing and conduit from thermal conducting metal to insulated material or see if insulating the case made any difference?
As @slt1 kindly chipped in with a climate not unlike your own he couldn't get the 5vJSN to reliably work and elected to go with a modified twin transducer which he found reliable.
Your false readings are uncannily close to the deadband of 20cm on all your failures for what it's worth.
I have one strangely behaving board, and one operating perfectly in stable temperatures but high humidity. I will experiment when the problem arises after the tank is emptied in 3 weeks, but curious what you've tried in the last 4 days? -
@timbergetter Not labouring the point at all, but what have you changed which might help narrow the problem?
1 - Did you review the sketch to verify the reading is double or triple verified and not reported if false compared to expected range or previous reading? Clearly not as you are still reporting incorrect readings.
2 - If the connections are Dupont, have you checked continuity for a dodgy wire, or even better soldering terminations to eliminate thermal expansion of contacts from possibilities?
3 - Have you tried changing the materials used for casing and conduit from thermal conducting metal to insulated material or see if insulating the case made any difference?
As @slt1 kindly chipped in with a climate not unlike your own he couldn't get the 5vJSN to reliably work and elected to go with a modified twin transducer which he found reliable.
Your false readings are uncannily close to the deadband of 20cm on all your failures for what it's worth.
I have one strangely behaving board, and one operating perfectly in stable temperatures but high humidity. I will experiment when the problem arises after the tank is emptied in 3 weeks, but curious what you've tried in the last 4 days?@Timbergetter Can you can post the sketch you are using?