GM67 Bar Code Reader Module


I am trying to read the output of the GM67 barcode reader using uart bus.

I have a NodeMCU ESP8266, which already reads the value of 2 pins for 2 binary sensors.

I’m trying to, at least debug the uart bus, however there is nothing in the logs. The config looks like this:

  tx_pin: D1
  rx_pin: D2
  id: uart_bus
  baud_rate: 9600
    direction: BOTH
    dummy_receiver: false
      delimiter: "\n"
      - lambda: UARTDebug::log_string(direction, bytes);
  baud_rate: 0
  hardware_uart: UART1

I tried adding this: Custom UART Text Sensor — ESPHome but with no luck, still nothing in the logs (VERY_VERBOSE level).

I tried switching pins to TX and RX, manually telling the logger to use UART1, but I still have nothing on the logs.
Am I missing something obvious? (yes, the GM67 Bar Code has been setup to use the TTL 232 Interface… this sets: Serial port related configuration: Baud rate:9600, Data bit:8, Verification: No, Stop bit:1)

Thank you

EDIT: start logs with logger on UART1 and uart pins TX and RX:

[15:32:07][V][wifi:359]:   Priority: 0.0
[15:32:07][C][wifi:361]:   Channel: 6
[15:32:07][C][wifi:362]:   Subnet:
[15:32:07][C][wifi:363]:   Gateway:
[15:32:07][C][wifi:364]:   DNS1:
[15:32:07][C][wifi:365]:   DNS2:
[15:32:07][C][logger:233]: Logger:
[15:32:07][C][logger:234]:   Level: VERY_VERBOSE
[15:32:07][C][logger:235]:   Log Baud Rate: 0
[15:32:07][C][logger:236]:   Hardware UART: UART1
[15:32:07][C][uart.arduino_esp8266:100]: UART Bus:
[15:32:07][C][uart.arduino_esp8266:101]:   TX Pin: GPIO1
[15:32:07][C][uart.arduino_esp8266:102]:   RX Pin: GPIO3
[15:32:07][C][uart.arduino_esp8266:104]:   RX Buffer Size: 256
[15:32:07][C][uart.arduino_esp8266:106]:   Baud Rate: 9600 baud
[15:32:07][C][uart.arduino_esp8266:107]:   Data Bits: 8
[15:32:07][C][uart.arduino_esp8266:108]:   Parity: NONE
[15:32:07][C][uart.arduino_esp8266:109]:   Stop bits: 1
[15:32:07][C][uart.arduino_esp8266:111]:   Using hardware serial interface.
[15:32:07][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Ajouter'
[15:32:07][C][gpio.binary_sensor:016]:   Pin: GPIO0
[15:32:07][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Consommer'
[15:32:07][C][gpio.binary_sensor:016]:   Pin: GPIO2
[15:32:07][C][ota:082]: Over-The-Air Updates:
[15:32:07][C][ota:083]:   Address:
[15:32:07][C][ota:086]:   Using Password.
[15:32:07][C][api:134]: API Server:
[15:32:07][C][api:135]:   Address:
[15:32:07][C][api:139]:   Using noise encryption: NO
[15:32:07][C][mdns:084]: mDNS:
[15:32:07][C][mdns:085]:   Hostname: barcode
[15:32:07][V][mdns:086]:   Services:
[15:32:07][V][mdns:088]:   - _esphomelib, _tcp, 6053
[15:32:07][V][mdns:090]:     TXT: version = 2022.1.2
[15:32:07][V][mdns:090]:     TXT: mac = 40915145fd19
[15:32:07][V][mdns:090]:     TXT: platform = ESP8266
[15:32:07][V][mdns:090]:     TXT: board = nodemcuv2

My working config:

  - source:
      type: git
    components: [ serial ]

  - platform: serial
    name: ${description} Bar Code

    baud_rate: 9600
      direction: BOTH
      dummy_receiver: false
        delimiter: "\n"
        - lambda: UARTDebug::log_string(direction, bytes);
    tx_pin: GPIO17
    rx_pin: GPIO16


1 Like

I tried using your working config for my bar code scanner. The scanner is a different model, but I don’t think that is an issue as I can see the bar codes I scan show up in the logs. What I am not seeing is the scanned code in home assistant. The text sensor just stays at unknown all the time in Home Assistant. It seems like I am close to having it working I just don’t know esphome well enough to figure out what to adjust. I tried changing the delimiter in the uart section to \r as that shows up in the logs, but it didn’t help.

My log shows:

[11:37:10][D][uart_debug:158]: <<< "850020433223\r"

Which is the correct bar code I am testing with. Any Ideas how to make the text sensor update?

Hi @Lakefire,

did you have any success and can share your solution with us?

Thanks in advance!

@Lakefire @boardnick0815

Not sure it this is still relevant to you, but I had the same problem: values weren’t sent to Home Assistant. I created the lambda code myself. So no need for the external component. This is my working code:

Edit: added a character count to avoid misscans. Bar code is 13 characters, but 14 are read from the uart including the r.

  id: uart_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
    direction: BOTH
    dummy_receiver: true
      delimiter: "\n"
      - lambda: |-
          UARTDebug::log_string(direction, bytes);
          std::string str(bytes.begin(), bytes.end());
          int nuberCount=strlen(str.c_str());
          if (nuberCount==14) { id(barcode).publish_state(str.c_str()); }

  - platform: template
    id: barcode
    name: Barcode