ArduinoGeneral

URM3.7 V4.0 not detecting randomly

userHead adityaprakash.23.09 2019-01-29 15:58:50 4025 Views5 Replies
Hello There!
I am using a URM3.7 V4.0 Ultrasonic sensor with my arduino mega. I am using it in passive serial mode with the sample code given here https://www.dfrobot.com/wiki/index.php/ ... troduction. When I run the code and put my hand in front of it, I sometimes observe that the hand is not getting detected by the sensor as the sensor values still remain the same even after the hand is in front of it and moves away slowly. Is there a way to do some kind of calibration at intervals so that it keeps working perfectly continuously, solving the detections missed?
2019-02-01 14:48:40 Not quite sure about the freeze problem, what about change the delay time? would that be better? userHeadPic robert.chen
2019-01-31 14:11:37 I have witnessed the same output, but what happens in my case is that I test the sensor by continuously putting my hand in front of the sensor and then removing it. So out of 10 times, 3-4 times the readings use to freeze. I will try ur suggestion of varying the distance of the hand from the sensor when the readings freeze. But do u know why the readings freeze suddenly?
Thanks!
userHeadPic adityaprakash.23.09
2019-01-31 10:10:49 I just used a mega and URM37 v4.0 to test the code, the measurement is good to perform, if you change the distance, is the reading changing? userHeadPic robert.chen
2019-01-30 18:31:29 No I am using the passive serial mode. Here is my code
Code: Select all
uint8_t EnTempCmd[4]={0x22,0x00,0x00,0x22};    // temperature measure command
uint8_t TempData[4];
unsigned int TempValue=0;

void setup()
{
  Serial.begin(9600);
  Serial2.begin(9600);
  delay(100);
  Serial.println("Init the sensor");
}

void loop()
{
  SerialCmd();
  delay(200);
}

void SerialCmd()
{
   int i;
   for(i = 0;i < 4;i++){
      Serial2.write(EnTempCmd[i]);
   }
    while (Serial2.available() > 0)  //if serial receive any data
    {
        for(i = 0;i < 4;i++){
         TempData[i] = Serial2.read();
       }
       TempValue = TempData[1]<<8;
       TempValue =TempValue+TempData[2];
       Serial.print("Distance : "); 
       Serial.println(TempValue,DEC);  
    }
}
BTW, I am using Arduino Mega as the controller. The behavior is like it sometimes detects the obstacle(hand) but randomly sometimes it does not detect anything and looks like the values have frozen or something.
Thanks!
userHeadPic adityaprakash.23.09
2019-01-30 14:29:12 Do you mean the auto measure mode sample code to measure the distance? what if you use a flat paper instead of your hand? userHeadPic robert.chen