GM67 Barcode reader

Hey there,

I'm having some troubles, programming my ESP32 WROOM32, to use it as a barcode scanner for a GM67 module.

I connected the scanner to Ports 16 and 17 and set the reader to 8bit, no parity, 1 stop bit.
The reader works fine when connected to a PC via USB.

Do you think there is an error in the code? Currently I'm not getting any data from the module.

#include <HardwareSerial.h>

HardwareSerial MySerial(2);

void setup() {
    Serial.begin(115200);
    MySerial.begin(9600, SERIAL_8N1, 16, 17);
}

void loop() {
    while (MySerial.available()) {
      Serial.println("Got data");
    }
}

Would be amazing, if somebody could help!

Could you call it "Serial2", because that is what everyone else is using.
Perhaps just a Serial2.begin( 9600) is enough, without the two lines with "HardwareSerial". There has been many improvements for the ESP32 and ESP8266 in the last years.

Can measure the TX and RX of the module when nothing is connected to it. They are idle high. Are they 5V or 3.3V ?
The ESP32 is not 5V tolerant.

Hey,

thanks a lot for your help! I measured the voltages and doublechecked everything and still couldn't find my mistake - until I swapped the TX and RX wires by mistake, which has actually been my mistake.
I connected the TX from the board to the TX to the ESP32, which obviously doesn't make any sense.

So now I connected TX to Rx and vice versa and now everything works perfectly. Sorry for that!

I'm glad you found the problem. Such things happens to all of us.
Can you still try to make it simpler by just using "Serial2" ? The ESP32 code has been improved and is also more compatible with the Arduino code than a few years ago.

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