💬 Distance Sensor
-
@zboblamont Still no luck with the JSN unit I see. Hope the DYP unit will bring better results.
@Boots33 Now I am flummoxed.... Got the DYP unit and yet, no difference in responses.... I can only conclude this has to be a hardware or device issue, as I checked all wiring (unless I missed something really stupid), tried the same 6 sketches even on a spare 3v3 device with the same result. Now ordered up a couple of Pro-Mini 5v to check out whether this is a 5v related issue since I cannot create a timed response otherwise, nothing makes sense with respect to the ultrasonic units now otherwise unless my earlier information that 3v3 was sufficient to trigger the device was wrong... Time for a slow drink, a long smoke, and shout abuse at passing dogs.... Nice weather, 26c, Friday, what's not to smile about.... Ah, Port..
-
@zboblamont It will be good to see the final results of both yours and @jjk
@Boots33 Well, finally I got some positive results, but not quite as expected...
The JSN-SR04T-2.0 nor the DYP-ME007Y I could get to work on all six variations of sketches tried. Still not sure why neither would work using this 3v3 board even with 5v to the ultrasonic board and dropper resistors on the echo. Allegedly the ping from 3.3v should work.So, bought and finished today trialling a 5v/16MHz Pro-Mini ;
The JSN version 2.0 nor the DYP would not respond to NewPing, simply churning out zeroes.
Other sketches would turn out fixed numbers and zeroes which did not alter irrespective of the transducer/object distance.
The JSN finally got working with a simple PulseIn calculation loop with a 500 delay. First reading was always Zero, all the rest consistent and rock solid.
The DYP unexpectedly responded only to the SoftwareSerial method originally found to work from a Russian site. The readings are spot on from the start.Now that they work, I need to figure out if there is a workaround for the 3.3v transceiver node....
Phew.... -
@Boots33 Well, finally I got some positive results, but not quite as expected...
The JSN-SR04T-2.0 nor the DYP-ME007Y I could get to work on all six variations of sketches tried. Still not sure why neither would work using this 3v3 board even with 5v to the ultrasonic board and dropper resistors on the echo. Allegedly the ping from 3.3v should work.So, bought and finished today trialling a 5v/16MHz Pro-Mini ;
The JSN version 2.0 nor the DYP would not respond to NewPing, simply churning out zeroes.
Other sketches would turn out fixed numbers and zeroes which did not alter irrespective of the transducer/object distance.
The JSN finally got working with a simple PulseIn calculation loop with a 500 delay. First reading was always Zero, all the rest consistent and rock solid.
The DYP unexpectedly responded only to the SoftwareSerial method originally found to work from a Russian site. The readings are spot on from the start.Now that they work, I need to figure out if there is a workaround for the 3.3v transceiver node....
Phew....@zboblamont it certainly has been a bumpy road for you. good to see you making some headway.
-
I've been fighting with DYP-ME007Y myself for the last few days...
Originally i wanted to monitor the level of a water tank with an SR04 ; as it is not waterproof i assumed that it would die fairly quickly.
So i ordered a DYP-ME007... but the last letter ("Y") means that it uses serial communication, so the ping Library doesn't apply.
Bouncing from site to site i found the following code that @zboblamont refers to :#include <SoftwareSerial.h> SoftwareSerial mySerial = SoftwareSerial(10,11); #define echoPin 10 #define trigPin 11 unsigned int reading; byte readByte; byte read_buffer[4]; byte crcCalc; word distance; String outText; void setup() { mySerial.begin (9600); Serial.begin (9600); Serial.println("start"); for (byte loopstep = 0; loopstep <= 3; loopstep++) { read_buffer[loopstep] = 0; } } void loop() { if (mySerial.available() < 1) { return; } readByte = mySerial.read(); for (byte loopstep = 0; loopstep <= 2; loopstep++) { read_buffer[loopstep] = read_buffer[loopstep + 01]; } read_buffer[03] = readByte; if (read_buffer[00] != 0xff) { return; }; crcCalc = read_buffer[00] + read_buffer[01] + read_buffer[02]; if (read_buffer[03] != crcCalc) { return; }; distance = (read_buffer[01] * 0xff) + read_buffer[02]; outText = "bytes: "; outText = String(outText + read_buffer[00]); outText = String(outText + "+"); outText = String(outText + read_buffer[01]); outText = String(outText + "+"); outText = String(outText + read_buffer[02]); outText = String(outText + "+"); outText = String(outText + read_buffer[03]); outText = String(outText + " = "); outText = String(outText + distance); outText = String(outText + " mm"); Serial.println(outText); delay(1000); while (mySerial.available() > 0) { readByte = mySerial.read(); } }Worked first shot
-
I've been fighting with DYP-ME007Y myself for the last few days...
Originally i wanted to monitor the level of a water tank with an SR04 ; as it is not waterproof i assumed that it would die fairly quickly.
So i ordered a DYP-ME007... but the last letter ("Y") means that it uses serial communication, so the ping Library doesn't apply.
Bouncing from site to site i found the following code that @zboblamont refers to :#include <SoftwareSerial.h> SoftwareSerial mySerial = SoftwareSerial(10,11); #define echoPin 10 #define trigPin 11 unsigned int reading; byte readByte; byte read_buffer[4]; byte crcCalc; word distance; String outText; void setup() { mySerial.begin (9600); Serial.begin (9600); Serial.println("start"); for (byte loopstep = 0; loopstep <= 3; loopstep++) { read_buffer[loopstep] = 0; } } void loop() { if (mySerial.available() < 1) { return; } readByte = mySerial.read(); for (byte loopstep = 0; loopstep <= 2; loopstep++) { read_buffer[loopstep] = read_buffer[loopstep + 01]; } read_buffer[03] = readByte; if (read_buffer[00] != 0xff) { return; }; crcCalc = read_buffer[00] + read_buffer[01] + read_buffer[02]; if (read_buffer[03] != crcCalc) { return; }; distance = (read_buffer[01] * 0xff) + read_buffer[02]; outText = "bytes: "; outText = String(outText + read_buffer[00]); outText = String(outText + "+"); outText = String(outText + read_buffer[01]); outText = String(outText + "+"); outText = String(outText + read_buffer[02]); outText = String(outText + "+"); outText = String(outText + read_buffer[03]); outText = String(outText + " = "); outText = String(outText + distance); outText = String(outText + " mm"); Serial.println(outText); delay(1000); while (mySerial.available() > 0) { readByte = mySerial.read(); } }Worked first shot
@ben999 So glad it worked, I tormented myself as a newbie in Arduinoworld. I didn't realise that the 'Y' was significant though, I recall others saying it fitted NewPing like a glove...
I don't think it helps when there are so many conflicting model numbers for completely (physically) different devices...
Hey ho.... -
hi folks, received my DYP-ME007Y finally, tried it and got the same inconsistent readings with the old sketch that @zboblamont and others reported. I was excited to see the code that @ben999 found and tested successfully - but I don't even get past the "start" print out in the serial monitor. the LED on the DYP board is flashing eagerly, but it doesn't look like it gets any readings... Have you guys changed anything else to get it t work?
-
update: we're getting there... after a bit a tweaking and trying different angles, I'm now getting readings. The good news: in one position, when readings come in, they are consistent. The bad news: as soon as I move the sensor head, it's a gamble, in some cases the readings are o.k., in other cases it drops to 0mm... Anybody has seen a similar effect?
-
update: we're getting there... after a bit a tweaking and trying different angles, I'm now getting readings. The good news: in one position, when readings come in, they are consistent. The bad news: as soon as I move the sensor head, it's a gamble, in some cases the readings are o.k., in other cases it drops to 0mm... Anybody has seen a similar effect?
-
update: we're getting there... after a bit a tweaking and trying different angles, I'm now getting readings. The good news: in one position, when readings come in, they are consistent. The bad news: as soon as I move the sensor head, it's a gamble, in some cases the readings are o.k., in other cases it drops to 0mm... Anybody has seen a similar effect?
@jjk If the readings you ARE getting are accurate when moved to new positions, it could as @ben999 said be inaccurate alignment to the reflective surface, or as was commented somewhere else, the plug/socket on the board being loose.
With a 3/4 to 1/2 reducer on a 1/2 pipe ready here for final installation, I sat transducer the socket to take out movement or alignment issues, it drifts off quite readily if angle is wrong. The code Ben refers to for this DYP gave me a slightly lower but not silly first reading then consistent results thereafter, no zeroes.Please note that I had tried all 6 sketch variants on the 3.3v device with a 5v DYP supply and got nonsense. Using the 3.3v Trig with drop resistors on the Echo neither the JSN nor the DYP worked properly despite the 5v power from the separate booster supply to them.
I only found consistency using a 5v pro-mini, with the DYP power supplied from logic pins, which leads me to think Trig and/or Echo are also 5v sensitive, contradicting previous advice and complicating my layout.Have not yet got round to trialling a logic converter from the 3.3v pro-mini for Trig and Echo with the original 5v supply, which is the next step, will report back once I get some time to test.
-
@ben999 and @zboblamont thanks for the swift feedback and advice. I think you are right, the DYP seems to be VERY sensitive to alignment. The tests I did were "handheld" and readings jumped arbitrarily btw zeroes, accurate, and off values. I've done a few tests now with the sensor head fixed and more aligned to the target surface and that seems to work out much better now. I also found that readings get less accurate above 1m, though?!
-
btw. I'm using a pro mini 5V to power and trigger the DYP at the moment. Have played with an external 5V supply, but that didn't seem to make a noticeable difference.
@jjk Sounds like you're getting there, it should be no problem with the 5v pro-mini, the only variables should be alignment and sketches.
To clarify, I only got a 5v pro-mini to figure out whether the DYP and JSN devices would work, which they did after trying different sketches. Those same sketches had retrieved garbage on the 3.3v pro-mini, despite a separate 5v supply to the DYP, running contrary to experience of others. That supply was unnecessary with the 5v pro-mini.
As the 3.3v is the intended battery powered radio node, I need the DYP to work with it, hence the logic level converter being the next attempt to get the DYP to work with the node.
-
DYP measuring range starts at 30cm -ish
When water tank is full-up, water level is near the top of the cistern...
So to achieve the minimum reading distance I used a big PVC pipe placed vertically on top of cistern (about 30cm) through a hole...
I went from 5cm to 8cm but no luck : I guess there must be some "echo" in the pipe that fools the reading...I will end-up with a plastic bucket (dia 30cm height 30cm) on top of cistern opening (not tested yet)
Final word : be aware of confined spaces, that sensor is kind of claustrophobic ;)
-
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 :)
-
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 Surprised if you are getting echoes in a pipe, there are no surfaces to reflect the signal. Both the tanks I am looking to monitor are quite big, I might have to use a pipe in the water tank as it is a plastic moulding which has vertical facing flats on the ribs. Will report back once tested in place.
I looked at transistor switching the device due to RTC and radio occupying all but 4 analogue lines on the node, but there were reportedly some issues with switching ground, so I settled on the latching dpdt relay I posted further up the thread. It needs two pins to open or close by changing outputs from high to low. It opened or closed in less than 30ms, about 33mA from memory, zero consumption once latched.
In my own case the node is 3.3v, the 5v boosted line for the DYP power was originally controlled by the relay.
Having established now that the DYP requires a 5v trig/echo, the relay is being reworked so one contact switches the 3.3v the other the 5v to power both the DYP and the level switcher, hopefully resolving earlier failures. -
Hi Everyone,
Just trying to get everything set back up correctly and I def have something wrong, my distance sensors show Zero.
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=254
15 TSM:FPAR
51 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2059 !TSM:FPAR:NO REPLY
2061 TSM:FPAR
2097 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2615 TSF:MSG:READ,0-0-254,s=255,c=3,t=8,pt=1,l=1,sg=0:0
2620 TSF:MSG:FPAR OK,ID=0,D=1
4105 TSM:FPAR:OK
4106 TSM:ID
4107 TSM:ID:OK
4109 TSM:UPL
4118 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
4128 TSF:MSG:READ,0-0-254,s=255,c=3,t=25,pt=1,l=1,sg=0:1
4133 TSF:MSG:PONG RECV,HP=1
4136 TSM:UPL:OK
4137 TSM:READY:ID=254,PAR=0,DIS=1
4150 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
4157 TSF:MSG:READ,0-0-254,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
4166 TSF:MSG:SEND,254-254-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
4177 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
4211 TSF:MSG:READ,0-0-254,s=255,c=3,t=6,pt=0,l=1,sg=0:M
4234 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=OK:Distance Sensor
4246 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
4265 TSF:MSG:SEND,254-254-0-0,s=1,c=0,t=15,pt=0,l=0,sg=0,ft=0,st=OK:
4272 MCO:REG:REQ
4282 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
4289 TSF:MSG:READ,0-0-254,s=255,c=3,t=27,pt=1,l=1,sg=0:1
4294 MCO:PIM:NODE REG=1
4296 MCO:BGN:STP
4298 MCO:BGN:INIT OK,TSP=1
Ping: 0 cm
4336 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4341 MCO:SLP:TPD
4343 MCO:SLP:WUP=-1
Ping: 0 cm
4380 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4386 MCO:SLP:TPD
4387 MCO:SLP:WUP=-1
Ping: 0 cm
4425 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4430 MCO:SLP:TPDAny idea why? Pins are set correctly 5 and 6.
Thanks
-
Hi Everyone,
Just trying to get everything set back up correctly and I def have something wrong, my distance sensors show Zero.
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=254
15 TSM:FPAR
51 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2059 !TSM:FPAR:NO REPLY
2061 TSM:FPAR
2097 TSF:MSG:SEND,254-254-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2615 TSF:MSG:READ,0-0-254,s=255,c=3,t=8,pt=1,l=1,sg=0:0
2620 TSF:MSG:FPAR OK,ID=0,D=1
4105 TSM:FPAR:OK
4106 TSM:ID
4107 TSM:ID:OK
4109 TSM:UPL
4118 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
4128 TSF:MSG:READ,0-0-254,s=255,c=3,t=25,pt=1,l=1,sg=0:1
4133 TSF:MSG:PONG RECV,HP=1
4136 TSM:UPL:OK
4137 TSM:READY:ID=254,PAR=0,DIS=1
4150 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
4157 TSF:MSG:READ,0-0-254,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
4166 TSF:MSG:SEND,254-254-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
4177 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
4211 TSF:MSG:READ,0-0-254,s=255,c=3,t=6,pt=0,l=1,sg=0:M
4234 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=OK:Distance Sensor
4246 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
4265 TSF:MSG:SEND,254-254-0-0,s=1,c=0,t=15,pt=0,l=0,sg=0,ft=0,st=OK:
4272 MCO:REG:REQ
4282 TSF:MSG:SEND,254-254-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
4289 TSF:MSG:READ,0-0-254,s=255,c=3,t=27,pt=1,l=1,sg=0:1
4294 MCO:PIM:NODE REG=1
4296 MCO:BGN:STP
4298 MCO:BGN:INIT OK,TSP=1
Ping: 0 cm
4336 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4341 MCO:SLP:TPD
4343 MCO:SLP:WUP=-1
Ping: 0 cm
4380 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4386 MCO:SLP:TPD
4387 MCO:SLP:WUP=-1
Ping: 0 cm
4425 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
4430 MCO:SLP:TPDAny idea why? Pins are set correctly 5 and 6.
Thanks
@Newzwaver which sensor are you using? And which library?
-
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)