ESP32でTF03の値を読み取る

ここを参考に。
circuits4you.com

#define RXD2 16
#define TXD2 17

void setup() {
  Serial.begin(115200);
  Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2); \
  Serial.println("init done");
}

void loop() {
  int inByte1 = readOneByte();
  if (inByte1 == 0x59) {
    int inByte2 = readOneByte();
    if (inByte2 == 0x59) {
      int DIST_L = readOneByte();
      int DIST_H = readOneByte();
      int distance = (DIST_L + DIST_H * 255);
      Serial.print("distance: ");
      Serial.print(distance);
      Serial.println(" cm");
    }
  }
}

int readOneByte() {
  while (!Serial2.available());
  return Serial2.read();
}