How to send hexadecimal by serial communication Protocol

I purchased an ozone sensor from Winsen for ozone measurement.
I'm using ESP32-PICO-KIT V4
On datasheet, to use the "Q&A mode", set up command

Send
Start Byte / Address / Demand / Communication Type / -- / -- / -- / -- / Checksum
0XFF 0X01 0x78 0x04 0x00 0x00 0x00 0x00 x83

Receive
Start Byte / Command / Return calibration / -- / -- / -- / -- / -- / Checksum
0XFF 0X78 (Success: 1 Failure: 0) 0x0 0x0 0x0 0x0 0x0 (0x87 0x88)

If use the serial communication terminal program, commands are transmitted, but It is not transferred when using Arduino IDE.
Is my code wrong?

#include<HardwareSerial.h>
HardwareSerial mySerial(2);

byte command[9] = {0xFF, 0x01, 0x78, 0x04, 0x00, 0x00, 0x00, 0x00, 0x83};

void setup() {
  Serial.begin(115200);
  mySerial.begin(9600, SERIAL_8N1, 15, 13);
}

void loop() {
  byte readBuffer[9] = {};
  
  mySerial.write(command, 9);
  mySerial.readBytes(readBuffer, 9);

  for (int i = 0; i < 8; i++) {
    Serial.print(readBuffer[i], HEX); Serial.print(" ");
  }
  Serial.println(readBuffer[8], HEX);
  delay(1000);
}

esp32UART.ino (499 Bytes)

Please use code tags when posting the code.

Wrong checksum:

0XFF 0X01 0x78 0x04 0x00 0x00 0x00 0x00 x84

char command[9] = {0xFF, 0x01, 0x78, 0x04, 0x00, 0x00, 0x00, 0x00, 0x83};

PS: communications are in binary. "Hexadecimal" is a human readable representation of a binary number.

By editing the data in your post, you have made the thread nonsensical.

You are off to a good start on this forum!

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