Hi everyone, I am trying to integrate the GM65 QR code scanner into my Arduino Mega 2560. Of all the scan mode, I am mainly interested in is the command triggered mode. I have done exactly what the manual says, first I scan the Series Communication Interface QR to enable UART communication. Then, I scan the Command Triggered QR to switch to this scan mode. According to the manual, to start scanning under this mode, I need to send the following command code: 7E 00 08 01 00 02 01 AB CD. if successful, the scanner will send back 02 00 00 01 00 33 31 and start scanning. As you can see in this code below, I have done exactly that:
void sendTriggerRaw()
{
Serial.println(F("Sending trigger command..."));
Serial2.write(static_cast<uint8_t>(0x7E));
Serial2.write(static_cast<uint8_t>(0x00));
Serial2.write(static_cast<uint8_t>(0x08));
Serial2.write(static_cast<uint8_t>(0x01));
Serial2.write(static_cast<uint8_t>(0x00));
Serial2.write(static_cast<uint8_t>(0x02));
Serial2.write(static_cast<uint8_t>(0x01));
Serial2.write(static_cast<uint8_t>(0xAB));
Serial2.write(static_cast<uint8_t>(0xCD));
Serial2.flush();
}
void setup() {
Serial.begin(115200);
Serial2.begin(9600); // <-- use the baud that used to work for data
delay(1000);
Serial.println("GM65 command trigger test");
sendTriggerRaw();
}
void loop() {
// 2) Read ANYTHING the scanner returns, in hex
while (Serial2.available()) {
uint8_t b = Serial2.read();
Serial.print("IN : 0x");
Serial.print(b, HEX);
Serial.print("\n");
}
}
For som reason, the arduino receives exactly what it sends:
Sending trigger command...
IN : 0x7E
IN : 0x0
IN : 0x8
IN : 0x1
IN : 0x0
IN : 0x2
IN : 0x1
IN : 0xAB
IN : 0xCD
I have double checked the wiring many times. When I try scanning an actual QR code, the Arduino is able to receive the decoded text just fine. To rule out hardware issue, I have bought a second unit, but the issue still remains. Can you tell me what is wrong?
Thank you very much