💬 Distance Sensor
-
I don't quite like the idea of the DYP board being powered full-time...
It "ticks" every one second and i only need a few updates of water level per day.I would like to power it via a transistor (itself being triggered by arduino)
What would be your thoughts on that ?
- powering that board say 4 times a day for 10 seconds would be more deadly than being powered on all the time ?
- looks like the serial "conversation" kicks-in as soon as power is applied to the board... could it damage either board if serial link is cut anytime ?
- DYP board uses on average less than 15mA. What transistor would be a good contender for that job ?
Thanks again for reading and thanks even more for your input :)
@ben999 Finally good news at least on getting the DYP-SR04T-2.0 to behave with the 3.3v Pro Mini, currently arrangement like wire spaghetti. How it all fits in the weatherproof box is another day's work, as is coding it up to send hourly data back to the Gateway.
Earlier trials using the 5v Mini worked perfectly, so ended up with latching relay and booster on separate battery pack, unfortunately I did not realise the complications of using a single coil latching relay on the Arduino.
Needed to get some work done on the house, so delayed getting back to until last week.
So the working hardware is now 10k resistor to DIODES DMG6968U-7 switching a NEC EE2-3TNU double coil relay, a level converter for trig/echo, and a 5v booster to power the ultrasonic. Works fine now even though the first reading is still always a Zero.
Relay switch on and switch off is less than 10ms- Arduino and low current..
![0_1504352019537_WP_20170902_13_56_09_Pro[1].jpg](/assets/uploads/files/1504352036114-wp_20170902_13_56_09_pro-1-resized.jpeg)
-
I don't quite like the idea of the DYP board being powered full-time...
It "ticks" every one second and i only need a few updates of water level per day.I would like to power it via a transistor (itself being triggered by arduino)
What would be your thoughts on that ?
- powering that board say 4 times a day for 10 seconds would be more deadly than being powered on all the time ?
- looks like the serial "conversation" kicks-in as soon as power is applied to the board... could it damage either board if serial link is cut anytime ?
- DYP board uses on average less than 15mA. What transistor would be a good contender for that job ?
Thanks again for reading and thanks even more for your input :)
@ben999 As a postscript to the above, I puzzled over how quickly I could get a valid result before being able to power down the secondary circuit of relay, booster, level converter etc...
I looked at the results coming in (in this case from the JSN sensor) and read up on median analysis and gave up pretty quickly on that level of sophistication, as I realised only the first result was incorrect, that puzzling zero, all the rest were consistent and repetitive.
Inserting a while statement in the Void Setup (instead of the forever version in the Void Loop) checking the time duration < 1, I got a valid result immediately after the first ping, and the secondary circuit could be shut down.
As I only need one valid result to switch the relay off and radio the reading in once and hour, this seems to satisfy my requirements while limiting power drain on the secondary circuit.
-
I had to add some lines to the sample sketch to get console printouts:
#include <SoftwareSerial.h>
and in the void setup():
Serial.begin(115200);Is everybody so specialized that they see immediately this omission? :-)
-
I am using a Nano V3.
Apart from the above lines I didn't change anything in the sketch.
Before the change I only got debug messages and no Serial.print lines!Is the SoftwareSerial.h included in one of the other libraries?
-
Found a new distance sensor HC-SR04P .
De spec shows that the input voltage of this model is 3-5V. So this model can be used with a 3.3V arduino.
https://www.aliexpress.com/snapshot/0.html?spm=a2g0s.9042647.6.2.1AslKf&orderId=89862296499774&productId=32711959780 -
Sorry for bumping up an old question but I’m in the same boat of requirement.
And to my surprise there are quite a few new sensors in town:
This one has 2 transducers instead of 1 therefore has less minimum detection distance as compared to JSN SR04T. It is also completely sealed and waterproof.
Ebay spam link removed by moderator
Before finalizing on this I had bought another one which was a waterproof modified version of HC-SR04 from here
Ebay spam link removed by moderator
The 1st one is much more rugged and waterproof as compared to the latter one
-
Sorry for bumping up an old question but I’m in the same boat of requirement.
And to my surprise there are quite a few new sensors in town:
This one has 2 transducers instead of 1 therefore has less minimum detection distance as compared to JSN SR04T. It is also completely sealed and waterproof.
Ebay spam link removed by moderator
Before finalizing on this I had bought another one which was a waterproof modified version of HC-SR04 from here
Ebay spam link removed by moderator
The 1st one is much more rugged and waterproof as compared to the latter one
@ritesh-t Dual sensor types were the first on the market, send on one sensor receive on the other from memory, but could suffer in high water vapour Zones.
The single sensor types switches between send and receive on the same head, commonly used as car parking sensors.The cheaper one you show has exposed diaphragms and says it is water resistant not waterPROOF ;)
Aside the smaller deadband of 3cm the more expensive one used more robust moulded sensors but steep on price, 3 times the JSN single sensor head device, but 20cm deadband is adequate for my use.
Both need 5v supply same as the JSN single sensor type, for a 3.3v Node this adds complication. -
Actually, even when I use this example without any changes with single sensor, quite often node sends out 0cm. Real distance in my office from table top to ceiling is about 160cm. Maximum distance set to 300.
@apl2017 There are many techniques to get avoid bogus or wrong results, assuming there are no environmental effects (reflective side objects to make readings difficult).
On the setup here the sensor is a single transducer, and the sketch is a basic single pulse, time the echo to calculate the distance, with a sufficient delay to ensure the preceding pulse has decayed (hard surface underground tank) - The sketch tests for two consective results within the expected range, if it does not succeed in X attempts it does not update the Gateway and goes back to sleep for the next event, hence not flattening batteries. -
zboblamont . Thank you, I understand all of this except I really don't see in sketch testing of two consecutive results in X attempts. I see that node will wake up and update the distance if new data is different than old data, but, anyway, question was about something different. Why, single sensor node based on this example periodically generates 0 distance? Are there different models of these sensors, so NewPing library needs to be altered?
-
zboblamont . Thank you, I understand all of this except I really don't see in sketch testing of two consecutive results in X attempts. I see that node will wake up and update the distance if new data is different than old data, but, anyway, question was about something different. Why, single sensor node based on this example periodically generates 0 distance? Are there different models of these sensors, so NewPing library needs to be altered?
@apl2017 Verifying the reading is something you have to write into the sketch yourself, nothing complicated. I didn't use a library so no idea what advantage it brings over the simple timing method. Because I only take readings every hour triggered by an RTC, I don't care if it is the same as previous, only that it is valid in which case it is sent in.
Parts of my sketch follow, all fairly self-explanatory, perhaps they are of some use.
Main loop - Call subroutine and test to ensure it lies between two values, up to 10 attempts allowed to get a proper reading.while ((tankdepth<350||tankdepth>1000)&&counter<=10){//10 attempts to get proper range READULTRASONIC(); counter++; }The READULTRASONIC subroutine uses the simple timing method to get the 2 consecutive readings.
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(100); digitalWrite(Trigpin, HIGH); delayMicroseconds(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);///// 500 originally but why??????? } tankdepth=distance; }There are many version of these sensors, neither of the two I trialled reliably ran unless on 5v, which made it bit more complicated for a 3.3v Node.
One operated on softserial from memory, but I couldn't get it to do what I wanted, I settled on the one which allows straightforward timing.When I was first testing these, the first reading would always be a zero for reasons unknown, then solid readings, but the 2 consecutive readings test worked for me.
-
@zboblamont Thanks, you are proposing to filter out wrong reading, I am trying to understand why system periodically sends out 0.
-
@zboblamont Thanks, you are proposing to filter out wrong reading, I am trying to understand why system periodically sends out 0.
@apl2017 Understood, good luck finding out whether environment, hardware, software, in isolation or combination are the cause.
As said previously, aside the leading zero, the arrangement and technique here returns stable readings, the only critical aspect found was need of a solid 5v.
The only anomaly found were a condensation drip on the sensor face at below -10 outside air temp, hence the 10 attempts limitation.
Good luck -
@APL2017 Did you find the reason for this problem of reading periodically 0cm?
I have the same problem with a Arduino Uno connected to a HC-SR04 sensor. (in reality I made two sensors and both have regularly 0cm as output)
I can blindly adapt the software to filter out these strange values, but like you, I prefer to understand why this behaviour? -
@APL2017 Did you find the reason for this problem of reading periodically 0cm?
I have the same problem with a Arduino Uno connected to a HC-SR04 sensor. (in reality I made two sensors and both have regularly 0cm as output)
I can blindly adapt the software to filter out these strange values, but like you, I prefer to understand why this behaviour?Maybe replying to myself : I read just in the sensor example:
int dist = metric?sonar.ping_cm():sonar.ping_in(); Serial.print("Ping: "); Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range) Serial.println(metric?" cm":" in");0 = outside set distance range
Good chance that this is the reason...