Barcode not able to scan, arduino, Adafruit_Thermal library

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using latest Adafruit_Thermal library, arduino mega 2560 & using it to print barcode. Issue is barcode is printed but my mobile app is unable read it. tried multiple apps also, but not reading.

Attached is code & output print.

 

I have tried almost all opotions in adafruit lib like CODE39, CODE93 & others, all gets pritned but not able to scan.

need to print digits only 0 to 9 only. In image attached, top part is removed it had customer info.Text is printed correctly no issues.

 

void print_barcode(uint16_t g_serial_number)
{
    uint8_t temp1;
    uint16_t temp;
    char_t barcode_str[14];
    char_t serial_number_bytes[5] = {' ', ' ', ' ', ' ', ' '};
    
    
    temp = g_serial_number;
    
    temp1 = temp % 10U;
    serial_number_bytes[4] = temp1 | 0x30U;

    temp = temp / 10U;
    temp1 = temp % 10U;
    serial_number_bytes[3] = temp1 | 0x30U;     

    temp = temp / 10U;
    temp1 = temp % 10U;
    serial_number_bytes[2] = temp1 | 0x30U;    

    temp = temp / 10U;
    temp1 = temp % 10U;
    serial_number_bytes[1] = temp1 | 0x30U;    

    temp = temp / 10U;
    temp1 = temp % 10U;
    serial_number_bytes[0] = temp1 | 0x30U;                


    for(cnt = 0; cnt < 8U ; cnt++)   // fill with zeros
    {
        barcode_str[cnt] = '0';
    }
    
    for(cnt = 0; cnt < 5U ; cnt++)
    {
        barcode_str[cnt+8] = serial_number_bytes[cnt];
    }

    barcode_str[13] = '\0';
    printer.setBarcodeHeight(19);
    printer.printBarcode(&barcode_str[0], CODE39); 

     
    Serial1.write(14);  //move to next label
    
}

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are specific requirements for the barcode dimensions. Your one looks very poor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


You can put pictures in your post - no need to attach separately:

You seem to have edited-out some information - could you not also have cropped off the blank space?

 

 

That print does look pretty poor!

As  Kartman suggests, have you tried increasing the size?

Can you improve the resolution?

 

Vindhyachal Takniki wrote:
my mobile app is unable read it. tried multiple apps also, but not reading

Can you read other barcodes?

In particular, can you read other barcodes that size

 

Phone cameras are often not (particularly) good for reading 1D barcodes - have you tried with (a) better phone(s) ?

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Compare your print with an online generated barcode and even accounting for height (which I tried to match) you'll see vast differences.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My phone reads   N.Winterbottom's barcode from the screen in an instant.

It does not read the OP's at all. Even if I enlarge it & enhance the contrast.

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you please specify:
a) Type of barcode used (Code39, Code128 etc)

b) Machine that prints this output?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a suspicion that the OPs printed code isn't all there - has it over-run the edge of the paper?

 

Neil

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

barnacle wrote:
has it over-run the edge of the paper?

Good thought!

 

The print quality is also very poor.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. have tried code93,39, 128 etc all. All types used as specified in adafruit library.

2. i have ordered new printer also to check if printer low quality issue & new sticker also

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I have no experience with Adafruit's library, but i suppose it's well made (and well documented ?)

but for quick results you can try the following:
Try printing Code128 (subset A or B) with few digits (i.e 4 or 5) so to be sure that the printout

does not exceed paper's width and also give the barcode more height to have more chances

of reading in case of some bar (vertical line) has been printed poorly

By a quick look on adafruit's page i found that most of thermal printers used have 203dpi resolution

which is enough for printing 1-D barcodes.

Also search the library (or the thermal printer manual) to find the command that increase the

printing "heat" (or darkness as might be referred) of the printhead, so to have a better print quality.