MH-ET Barcode Scanner v3.0 Problem

I just started studying electronics and how to program an arduino, please consider helping me find a solution.

Hello, I am working on a project that involves the use of a barcode scanner. I am having problems with my module. I am using MH-ET LIVE Scanner v3.0 and when I tested the product via HID connection to see if it works. it works fine when I first got the product. Then I tried to follow instructions on youtube on how to connect it to an arduino. This is what ive watched: https://youtu.be/xX_GDkPJ6x0 he built it using the code from this site

I thought that I could make this work without the need for the additional usb connection connected to the scanner just like the youtube video. I just want the USB serial connection to the arduino alone, then just pins to power up the scanner. This is the ideal result

Unfortunately, I am not able to upload my code to my arduino, here is the error message

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xc2

I don't know if this is a software or a hardware issue

Tried unplugging and replugging, restarting pc, restoring barcode module to factory settings, and nothing works. My connections are fine, my arduino is working well with other devices. I can upload other code to my other sensors.

Now when I tried to check it if it still works on HID connection, it is now not working properly. Scanner beeps which indicates it has read the barcode but not displaying on screen. It did this when I restored the scanner to factory settings. I think the scanner is still working because it can still scan the qr code on the manual when i try to configure it by scanning qr settings. But it no longer puts the text barcode on my computer even though my computer can detect it as an HID keyboard device. I tried following this guide but it didnt work.. [open config mode,scan code in manual]

Here is the code I am trying to test based on the video

// Variable for storing values from the scanner
String inputString = "";

// Variable for storing values in processing
String DataScanner = "";

// Variable to check if data is complete or not
bool stringComplete = false;

void setup() {
  // Pin for triggering the scanner to work
  pinMode(8, OUTPUT);

  // Initialize serial communication
  Serial.begin(9600);

  // Wait for serial port to connect. Needed for native USB port only
  while (!Serial) {
    ;
  }

  // Declare a variable for storing a message with a size of 200 characters
  inputString.reserve(200);
}

void loop() {
  // Send a digital high signal to the pin
  digitalWrite(8, HIGH);
  // Delay for 1 second
  delay(1000);
  // Send a digital low signal to the pin to trigger the scanner
  digitalWrite(8, LOW);
  // Delay for 1 second
  delay(1000);

  // Check if data from the scanner is complete
  if (stringComplete) {
    // If the data matches what is set, display "OK"
    if (DataScanner == "8859411300023\r\n") {
      Serial.println("OK");
      delay(1000); 
    }   
    // If the data does not match what is set, display "No Data"
    else {
      Serial.println("No Data");
    }

    // Clear the variables to wait for new data
    inputString = "";
    DataScanner = "";
    stringComplete = false;
  }
}

/*
  SerialEvent occurs whenever a new data comes in the hardware serial RX. This
  routine is run between each time loop() runs, so using delay inside loop can
  delay response. Multiple bytes of data may be available.
*/

void serialEvent() {
  while (Serial.available()) {
    // Get the new byte
    char inChar = (char)Serial.read();
    // Add it to the inputString
    inputString += inChar;
    // If the incoming character is a newline, set a flag so the main loop can
    // do something about it
    if (inChar == '\n') {
      stringComplete = true;
      // Convert inputString to a string and store in DataScanner
      DataScanner = String(inputString);
    }
  }
}

Here are my connections
scanner - arduino
s-rx - pin 3
s-tx - pin 2
vcc - 5v
gnd - gnd
button - pin 8

Additional note: when i connect the vcc and gnd, my barcode module doesn't turn on, only when i try to connect pin 8 does it lights up, but it still doesnt fully power on the scanner, just the barcode flash blinking. the red light doesnt even turn on

Please help me, I need this project for school. And i've been trying to fix this issue for a month now. Thanks a lot!

Which Arduino are You using?
Some need a USB shield to read the scanner.
Extract the technical information You used in that video. Using videos instead of documentation, posted here, is not accepted by most helpers. We all do this on our free time but we have other interests then watching Y- videos.

I am using arduino uno r3. I just followed what it says in the video so all my wirings and code are copied from that video initially then will be modified later if i could successfully upload the code. I provided my wiring connections and code on this thread

Downloading unknown files or clicking on unknown links is often not done by helpers.
The UNO R3 needs a shield to read the scanner. It's like server - client for USB. The UNO USB port is a client port. You need a server type shield for it.

I'll try this and update you if it works thank you

Did You set the COM port in the IDE tab tools?

Yes, COM port is correctly selected. I can upload other code when i connect my lcd to my arduino. Only when i connect the barcode do problems occur.

Post schematics for the troubeling setup. Pen and paper usually works well.

Here was the schematics I used on my previous code, when I didn't use a USB Host

I am now trying to make it work using a USB Host shield


i soldered the 3.3v and 5v btw

How is the total build powered?

That is worrying. What current does that scanner use? Any datasheet You can link to?

hi, hope this helps https://maxelectronica.cl/index.php?controller=attachment&id_attachment=160

Yes this is the manual

Hello, I tried using the USB host shield, tried different codes from the internet, but I can't make my barcode appear in my serial monitor. here's the one i'm trying to work with now:

#include <usbhid.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hidboot.h>
#include <SPI.h>

class MyParser : public HIDReportParser {
  public:
    MyParser();
    void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
  protected:
    uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
    virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
    virtual void OnScanFinished();
};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
  // If error or empty, return
  if (buf[2] == 1 || buf[2] == 0) return;

  for (uint8_t i = 7; i >= 2; i--) {
    // If empty, skip
    if (buf[i] == 0) continue;

    // If enter signal emitted, scan finished
    if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
      OnScanFinished();
    }

    // If not, continue normally
    else {
      // If bit position not in 2, it's uppercase words
      OnKeyScanned(i > 2, buf, buf[i]);
    }

    return;
  }
}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {
  // Letters
  if (VALUE_WITHIN(key, 0x04, 0x1d)) {
    if (upper) return (key - 4 + 'A');
    else return (key - 4 + 'a');
  }

  // Numbers
  else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
    return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
  }

  return 0;
}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {
  uint8_t ascii = KeyToAscii(upper, mod, key);
  Serial.print((char)ascii);
}

void MyParser::OnScanFinished() {
  Serial.println(" - Finished");
}

USB          Usb;
USBHub       Hub(&Usb);
HIDUniversal Hid(&Usb);
MyParser     Parser;

void setup() {
  Serial.begin( 115200 );
  Serial.println("Start");

  if (Usb.Init() == -1) {
    Serial.println("OSC did not start.");
  }

  delay( 200 );

  Hid.SetReportParser(0, &Parser);
}

void loop() {
  Usb.Task();
}

image

sorry im really new to this

There are lots of crappy code on the "internet". Code from the maker of devices are usually working, provided prescribed circumstances are fullfilled.
I had a half day introduction to C## 1994 and nerver used it. Only C......

Does Your code perform a Serial.print of the received barcode, ordering hex output?
Anyway, different keys should give different results.
We need assistance from more knowing helpers...

Yes

Have you tried these codes?
~M00910001.
~M00510000.
~MA5F0506A.
~M00910000.
After factory resting your scanner.
You should visit the webpage mentioned by buoyant.

MH-ET LIVE Barcode Scanner V3.0 - MH-ET-LIVE-SCANNER.

1 Like

finally solved the problem?