DYP-A02YY Waterproof sensor

Hello Kripson, I bought the DYP-A20 Mode Uart Controlled. You have to send something, then wait 70ms (or whatever your sensor spec says) Then if you read.

  mySerialB.write(true);
    delay(75);

if (mySerialB.available() > 0) {
 //  Serial.println("Data available.");

    delay(65);

    // Check for packet header character 0xff
    if (mySerialB.read() == 0xff) {
      // Insert header into array
   //   Serial.println("Data available2.");
      data_bufferB[0] = 0xff;
      // Read remaining 3 characters of data and insert into array
      for (int i = 1; i < 4; i++) {
        data_bufferB[i] = mySerialB.read();
      }

      //Compute checksum
      CSB = (data_bufferB[0] + data_bufferB[1] + data_bufferB[2]) & 0x00ff;
      // If checksum is valid compose distance from data
      if (data_bufferB[3] == CSB) {
        //Serial.println("Data available3.");
        distanceB = (data_bufferB[1] *256) + data_bufferB[2];
        // Print to serial monitor
        if(distanceB){

        Serial.print("b:");
        Serial.println(distanceB);
        //Serial.println(" mm");
        }
      }
    }
   // mySerialB.stopListening();
}

Work for my.
Good Look

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.