Ultrasonic Sensor single pin TR

Hello everyone,

I'v been trying to set up the DYP-ME007TX ultrasonic sensor,which has one pin for Transmit and Recieve, using the Ping example that comes with arduino Duemilanove software. Unfortunately until now i can't make it work. In sensors data sheet says that the triggering pulse should be 8 "highs" and 8 "lows".So ;
Firstly i don't know how to count 8 "highs" because i dont know how to calculate the Tb(bit period).
Secondly i'm getting a return of "1" in Serial.Print (duration)

I have used in the past a similar sensor but with one pin for transmit and one for recieve and it worked perfetcly(the triggering pulse was 10us) so i tried to run this sensor with a 10u triggering.

The code i'm using is the following;

const int pingPin = 7;

void setup() {
Serial.begin(9600);
}

void loop()
{
long duration, inches, cm;

pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);

inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(duration);
Serial.print(", ");
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();

delay(100);
}

long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}

Can you help me find how much is the Tb of the Avr given its cloak is 16MHz.
And suggest another solution to my problem.
By the way in sensors data sheet was saying that it has arduino library. which i never found anyware.

Thank you.

DYP-ME007TX ultrasonic sensor

Do you have a link to the datasheet?

What is the output you get?

This is the link with the data sheet.

I have tried everything.. i really don't know what else to try.

And im getting a constant High "1" i'v even attached a led on the output pin and it just stays lit. Only a fast blink due to the 100ms delay.

Seems to be not so much wrong at first sight. so it might be some critical timing

From the datasheet
A short ultrasonic pulse is transmitted at the time 0, reflected by an object. The senor
receives this signal and converts it to an electric signal. The next pulse can be transmitted
when the echo is faded away. This time period is called cycle period. The recommend
cycle period should be no less than 50ms.
If a 10?s width trigger pulse is sent to the signal pin, the Ultrasonic module will
output eight 40kHz ultrasonic signal and detect the echo back. The measured distance is
proportional to the echo pulse width and can be calculated by the formula above. If no
obstacle is detected, the output pin will give a 38ms high level signal.

so I modded the code a bit , might help (or not :wink:

const int pingPin = 7;

void setup() 
{
  Serial.begin(9600);
}

void loop()
{
  long duration, inches, cm;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delay(60);                                    // Keep it LOW for at least 50 ms

  digitalWrite(pingPin, HIGH);
  delayMicroseconds(10);                   // 10 us is OK
  digitalWrite(pingPin, LOW);

  // max delay of 8 x 25 uSec for the 8 40 Khz pulses
  // you might be listening too fast
  delayMicroseconds(150); 

  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  if (duration > 37500)  // 38000 plus some margin
  {
    Serial.println("no obstacles found");
  }

  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  Serial.print(duration);
  Serial.print(", ");
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  
  delay(100);
}

long microsecondsToInches(long microseconds)
{
  return microseconds / 148;
}

long microsecondsToCentimeters(long microseconds)
{
   return microseconds /58;
}

Nothing has changed..

As a return for the duration im getting a constant high "1" and as a return of in or cm im getting "0"

It's either im doing something wrong in the hardware part like cables etc or the sensor is broken..
But i must plug only 3 cables VCC GND and OUT and have tried em on a new breadboard in different spots with different cables and the sensor was brand new never used before.

Thank you alot for your help. Always electronics will have their ways to frustrate us i reckon..

Any other suggestions guys?

I'v managed to run the sensor in a bx-24 microcontroller..
and i can't run it on arduino?? this is a shame! please help!

the logic is like this

give 10us High as a trigger pulse
make an interrupt and measure the pulseWidth.

Take pulseWidth and print its value..

Where is the black hole here...i can't see it..

Hi
Sorry, this is not a datasheet at all...

But for myself, I ordered same part at HK and can't get a real datasheet.
And sensor didn't work too :frowning:

I guess, all 3-pin sensors working in same way.
But that seems not to be the truth...

Found this:
http://www.satistronics.com/serial-ultrasonic-module-jsme007tx_p2852.html?zenid=4rfcc1eo9ocpvcoq0thhnf73c7

That means: Answer of the sensor is not time delay between trigger and answer.
It means: Answer is a 4-Byte-word

As I have seen on Osci - this is the truth...

But sorry, can't give a solution.
Buying other sensors or change program ?

Peter

Thank you alot Peter.

I will try to build a code with this new perspective.

If i manage to get it work i will post it

Hi,

I had the same problem, but I think that I solve it! :slight_smile:

Basically, this ultrasonic range sensor (DYP-ME007TX) has a unidirectional serial interface, using a baud rate equal to 9600 baud. So, I implemented a simple block of code which uses the software serial library to implement its communication protocol described as:

This module will occupy in the use of a microcontroller IO port, connect the power, the modules within the distance once every 50ms, and from the pin OUT one, with four 8-bit data frame format is: 0XFF + H_DATA + L_DATA + SUM
1. 0XFF: as a starting data for judgments.
2. H_DATA: from the high 8-bit data.
3. L_DATA: from the lower 8 bits of data.
4. SUM: data and, for efficacy. The 0XFF + H_DATA + L_DATA = SUM (lower 8-bit only)
Note: H_DATA and L_DATA synthetic 16-bit data, ie the distance in millimeters values.

You can see next the code. Any error/doubt please ask me!

#include <SoftwareSerial.h>

// TX_PIN is not used by the sensor, since that the it only transmits!
#define PING_RX_PIN 6
#define PING_TX_PIN 7

SoftwareSerial mySerial(PING_RX_PIN, PING_TX_PIN);

long inches = 0, mili = 0;
byte mybuffer[4] = {0};
byte bitpos = 0;

void setup() {
  Serial.begin(9600);

  mySerial.begin(9600);
}


void loop() {
  bitpos = 0;
  while (mySerial.available()) {
    // the first byte is ALWAYS 0xFF and I'm not using the checksum (last byte)
    // if your print the mySerial.read() data as HEX until it is not available, you will get several measures for the distance (FF-XX-XX-XX-FF-YY-YY-YY-FF-...). I think that is some kind of internal buffer, so I'm only considering the first 4 bytes in the sequence (which I hope that are the most recent! :D )
    if (bitpos < 4) {
      mybuffer[bitpos++] = mySerial.read();
    } else break;
  }
  mySerial.flush(); // discard older values in the next read

  mili = mybuffer[1]<<8 | mybuffer[2]; // 0x-- : 0xb3b2 : 0xb1b0 : 0x--
  inches = 0.0393700787 * mili;
  Serial.print("PING: ");
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(mili);
  Serial.print("mili");
  
  delay(100);
}

To be honest, I don't like this sensor very much, because I cannot control when I want to take a measure of distance (send a ping)... and I want to use multiple similar devices, so I need to control when I want to send a ping in each one in order to avoid interference/overlap!

In my opinion, if you want a good Ultrasonic Range Sensor, please check this:
http://www.seeedstudio.com/depot/ultra-sonic-range-measurement-module-p-626.html?cPath=144_149
(good and reliable)

Good luck with your projects! :slight_smile:

data sheet says that the triggering pulse should be 8 "highs" and 8 "lows"

Really?
That sounds more like the main bang transmitted by the sensor.

Edit. Yes, the trigger pulse is 10 us. Re-read the reference on the alibaba page.

I'd get an oscilloscope on it.

robtillaart:

DYP-ME007TX ultrasonic sensor

Do you have a link to the datasheet?

What is the output you get?

I have the same sensors, these work as a serial output device. I've not figured it out either, as all the information on the forum is based on the Paralex device, which simply output a digital high.