how to read [me007-uls v1] ttl serial hex data?

Hi,

I woud like to read the serial data of my me-007 uls v1
(Datasheet)

The frame format seems very common:
1 start bit, 8 data bits, 1 stop bit at 9600 baud rate.
There are 6 hexadecimal frames. So how could this signal be read?

This code runs quite well for maxbotix-sensors (with ttl output)
[Reading serial data from maxSonar ultrasonic rangefinder - Sensors - Arduino Forum].
I would like to adapt the code for the me007 sensor, would that be possible with just a few changes?
Do you have any ideas which lines should be changed?

Sorry, I am an absolute Arduino beginner, thank's for your help.

/* test function to Parse data from MaxSonar serial data
and return integer */

#include <SoftwareSerial.h>

#define txPin 3                                            //define pins used for software serial for sonar
#define rxPin 2

SoftwareSerial sonarSerial(rxPin, txPin, true);            //define serial port for recieving data, output from maxSonar is inverted requiring true to be set.



boolean stringComplete = false;

void setup()
{
  Serial.begin(9600);                                      //start serial port for display
  sonarSerial.begin(9600);                                 //start serial port for maxSonar
  delay(500);                                              //wait for everything to initialize

}

void loop()
{
  int range = EZread();
  if(stringComplete)
  {
    stringComplete = false;                                //reset sringComplete ready for next reading

    Serial.print("Range ");
    Serial.println(range);
    //delay(500);                                          //delay for debugging
  }
}


int EZread()
{
  int result;
  char inData[4];                                          //char array to read data into
  int index = 0;


  sonarSerial.flush();                                     // Clear cache ready for next reading

  while (stringComplete == false) {
    //Serial.print("reading ");    //debug line

      if (sonarSerial.available())
    {
      char rByte = sonarSerial.read();                     //read serial input for "R" to mark start of data
      if(rByte == 'R')
      {
        //Serial.println("rByte set");
        while (index < 3)                                  //read next three character for range from sensor
        {
          if (sonarSerial.available())
          {
            inData[index] = sonarSerial.read();
            //Serial.println(inData[index]);               //Debug line

            index++;                                       // Increment where to write next
          } 
        }
        inData[index] = 0x00;                              //add a padding byte at end for atoi() function
      }

      rByte = 0;                                           //reset the rByte ready for next reading

      index = 0;                                           // Reset index ready for next reading
      stringComplete = true;                               // Set completion of read to true
      result = atoi(inData);                               // Changes string data into an integer for use
    }
  }

  return result;
}

"Hexadecimal" is just a human readable representation of a binary number.

The device transmits six byte frames, and the data sheet gives you the expected values in hexadecimal notation.

Yes, you can modify the (not very good) code you posted to read those frames. It will take some study, so first spend some time to understand what the posted code does, then study the data sheet and decide how the code has to be modified.

You might find Serial Input Basics helpful, as that may help to understand why some aspects of the posted code are quite poor.

For example, the first byte of the frame has value 255 in decimal or 0xFF in hex, so when you read a byte of that value, you can be fairly sure what will follow. The sixth byte is to check for transmission errors.

Give it a try yourself and if you run into trouble, add to this thread.