0% found this document useful (0 votes)
542 views

Arduino Based Bar Code Scanner

This document describes a student project to create an Arduino-based barcode and QR code scanner. It includes the names and student IDs of six students working on the project under the supervision of two professors. It presents declarations of originality and acknowledgments. It also includes an abstract describing the goals of replicating a commercial barcode scanner using an embedded system, decoding barcodes in real-time, and connecting to a database online. The objectives are to eliminate human error in reporting, secure data, increase attendance awareness for students, and allow parents to request performance reports for their children via SMS.

Uploaded by

salman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
542 views

Arduino Based Bar Code Scanner

This document describes a student project to create an Arduino-based barcode and QR code scanner. It includes the names and student IDs of six students working on the project under the supervision of two professors. It presents declarations of originality and acknowledgments. It also includes an abstract describing the goals of replicating a commercial barcode scanner using an embedded system, decoding barcodes in real-time, and connecting to a database online. The objectives are to eliminate human error in reporting, secure data, increase attendance awareness for students, and allow parents to request performance reports for their children via SMS.

Uploaded by

salman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

A project on:

Arduino Based Bar Code Scanner


BY

Aurang Zaib Anjum BSM-P-19-14


Maaz Ur Rehman BSM-P-19-16
Jahanzaib Nasir BSM-P-19-57
Malik Sohail Ahmad BSM-P-19-34
Samar Abbas BSM-P-19-75
Nouman Touseef BSM-P-19-74

Supervisors

Prof. Dr. Javed Ahmad


Dr. Nauman Usmani

Department of Physics, Bahauddin Zakariya University, Multan

2019-2023
DECLARATION OF ORIGINALITY

We declare that this report entitled “Arduino Based Bar Code Scanner” is our own work
except as cited in the references. The report has not been accepted for any degree and is not
being submitted concurrently in candidature for any degree or other award.

Aurang Zaib Anjum BSM-P-19-14


Maaz Ur Rehman BSM-P-19-16
Jahanzaib Nasir BSM-P-19-57
Malik Sohail Ahmad BSM-P-19-34
Samar Abbas BSM-P-19-75
Nouman Touseef BSM-P-19-74
ACKNOWLEDGEMENTS

We take great pleasure to express our deep sense of gratitude to our project
guide Dr. Nauman Usmani, Assistant Professor, for his valuable guidance during
the course of our project work.

We would like to thank Prof. Dr. Javed Ahmad, Head of the Department of
Physics for his encouragement.

We would like to express our heart-felt thanks to Mr. Maqsood, for


providing all the facilities for our project.

Our utmost thanks to all the Faculty members and Non-Teaching Staff of the
Department of Physics for their support throughout our project work.

Our Family Members and Friends receive our deepest gratitude and love for
their support throughout the academic year.
Table of Contents
ACKNOWLEDGEMENTS ....................................................................................................... 3

1.2 Introduction .......................................................................................................................... 8

1.3 Objectives ............................................................................................................................ 9

3.2 Power Supply Understanding 7805 IC Voltage Regulator ............................................... 14

Introduction ...................................................................................................................... 15
A Brief Note on 7805 Voltage Regulator ......................................................................... 15
Pin Diagram of 7805 Voltage Regulator IC ..................................................................... 16
Basic Circuit of 7805 ........................................................................................................ 17
How to Get Constant DC Power Supply from AC? ......................................................... 18
Important Points on 7805 Voltage Regulator IC .............................................................. 20
General Pin functions ....................................................................................................... 22
Special Pin Functions ....................................................................................................... 23
3.4 Maikrt Embedded QR Code Barcode Scanning Module............................................ 24
3.5 I2C OLED Display with Arduino ..................................................................................... 26

Introducing the 0.96 inch OLED display ............................................................................. 27


Pin wiring ............................................................................................................................. 28
Libraries ............................................................................................................................... 29
Tips for writing text using these libraries ......................................................................... 30
4.1 Working of the Project ....................................................................................................... 33

Bill of Materials ................................................................ Error! Bookmark not defined.


What is Barcode & how it works? .................................................................................... 34
What is QR Code & how it works? .................................................................................. 36
Interfacing Barcode/QR Code Scanner with Arduino ...................................................... 39
Portable Barcode/QR Code Scanner with Arduino & OLED Display ............................. 42
4.2 Code ................................................................................................................................... 35

4.3 Load Management Circuit Diagram ................................................................................. 54

4.4 Code .................................................................................................................................. 55


Chapter-5
5.1 Conclusion…………………………………..…………………………46
5.2 References……………………………………………………….……..46
ABSTRACT

Modern hand held devices such as smart phones and PDAs have become increasingly powerful
in recent years. Dramatic breakthroughs in processing power along with the number of extra
features included in these devices has opened the doors to a wide range of commercial
possibilities. In particular, most cell phones regularly include cameras, processors comparable
to PCs from only a few years ago, and internet access. However, even with all these added
abilities, there are few applications that allow much passing or decryption of environmental
information. As mobile devices become more like PCs they will come to replace objects we
tend to carry around such as checkbooks, credit cards, cameras, planners, mp3 players, etc. In
short, we will be using them to accomplish our daily tasks. One application that falls into this
category is barcode reading. Current barcode readers often offer decryption of data but few
have been applied to online commerce. Specifically, we will be using an Intel Xscale PXA27x
device to simulate a barcode scanner with the added ability of adding items to a commercial
shopping cart.

Chapter 01

INTRODUCTION
CHAPTER 1
INTRODUCTION

1.1Goals and Objectives


With Posting of internal assessment report through postal method, this may not reach on time,
lot of paper work, manual interaction is more, may lose of data, time consuming, all these can
be avoided with the proposed automated smart system. Objective of the proposed system to
eliminate the possibility of human error, data is secured, and attendance awareness among the
students, backup of total information is done. Auto detailed information of marks, attendance
is sent to Parent/Guardian through email and through the SMS every month. Even if parents
want to know performance of student they can SMS and get reports through SMS. The parents
can request for the report by sending SMS at any time (round the clock) and get performance
of their children. The proposed can be used in such an application. This project implements
automated SMS Response system using global system for mobile application (GSM) modem.
Existing System are like using RFID is harder to
1.2 Introduction
We can understand, it can be less reliable, RFID tags takes more memory than barcode labels
and more than one tag can respond at same time, and expense is one of the most significant
disadvantages of RFID. Other important thing is if we implement with RFID tags, we need to
provide separate RFID tag to each and every individual student, which will increase system
cost. Our project has three main goals. The first goal is to replicate a commercial barcode
scanner on the Intel PXA27x device. Milestones include configuring the on-board camera and
installing image manipulation and barcode decoding libraries. Our second goal is to decode the
barcode images in real-time, quickly and efficiently. This involves improving the image
decoding algorithms and choosing efficient image manipulation and barcode libraries. Our
final goal is to connect to the web to access an online database. Milestones include installing
the browser, configuring proper network settings, and finally creating an online shopping
application and database. Our main use case will involve adding items to a Christmas shopping
list. The user will pick up an item that he desires in the store and then take a picture of its
barcode. Afterwards, the barcode contents will be decoded and the product name is found
within a UPC database. The user will then be redirected to an online shopping list, with the
Page |9

current item added. There are many possibilities for what could be stored in a barcode. We
could denote movie information, website links, a save state or item in a video game, etc.
Whatever the case may be, it can be thought of as linking information using photos taken on a
common handheld device. Thus, we have streamlined the transfer of data in a simple and
elegant manner.

1.3 Objectives
2. In this post, we will learn how to make our own Barcode + QR Code

Reader using Arduino & Embedded QR/Barcode Scanner Module. The DIY QR &

Barcode scanner can scan the Barcode or QR Code and display the read information

on the OLED Display. You can also make a simple ESP32 CAM QR Scanner using

the ESP32 Camera Module but it requires computer screen for visualization.

3. QR codes are frequently used to track information about products in a supply

chain, often used in marketing and advertising campaigns. More recently, they have

played a key role in helping to trace coronavirus exposure and slow the spread of

the virus. Similarly, Barcodes are applied to products as a means of quick

identification. They are used in retail stores as part of the purchase process, in

warehouses to track inventory, and on invoices to assist in accounting.

4. For making Arduino Barcode + QR Code Reader, we will use Maikrt Embedded

QR Code Scanning Module. The module supports both USB and UART Serial

communication. It is a small 1D/2D codes reader that can be embedded in any

device for scanning code to identify other items. It uses the intelligent image

recognition algorithm to identify the Barcode and QR Code data.

5. In this tutorial, we will learn what is QR & Barcode and how the technology works.

Apart from this, we will be going through the details of the Maikrt Embedded QR

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 10

Code Scanning Module. And finally, we will interface the Barcode + QR Code

Scanner with Arduino Board and display the read data on OLED Display.

Department of Physics, Bahauddin Zakariya University, Multan


Chapter 02
Literature Review

Department of Physics, Bahauddin Zakariya University, Multan


CHAPTER 2
LITERATURE REVIEW
2.1 Previous work
Attendance is the act or fact of attending (being present at) school. Also, attendance is used to define
the number of persons present on a particular day at school. An attendance policy provides the
guidelines and expectations for students’ attendance at school as defined, written, disseminated, and
implemented by the school. Attendance can be recorded in many ways such as using web based, RFID,
biometrics and bar code scanner. Since most of the application developed nowadays requires the world
wide accessibility, web based system is the most common attendance system that available. One of the
higher institution in Malaysia have used RFID to record the attendance of their student and the record
sent to online server for an online accessibility [2]. Apart from that, there is plenty of educational
institutions used RFID technology to record their student attendance. Easy connection Attendance is
the act or fact of attending (being present at) school. Attendance can be recorded in many ways such as
using web based, RFID, biometrics and bar code scanner. Since most of the application developed
nowadays requires the world wide accessibility, web based system is the most common attendance
system that available. One of the higher institution in Malaysia have used RFID to record the attendance
of their student and the record sent to online server for an online accessibility [2]. Apart from that, there
is plenty of educational institutions used RFID technology to record their student attendance. Easy
connection Hema Subramaniam, Marina Hassan, Setyawan Widyarto [4] proposed a Barcode Based
Student Attendance System (SAS) in this the data captured using bar code scanner sent to the attendance
system for the purpose of recording and preparing attendance record. Bar code scanner used to scan the
student card which contains the student identification number. The twelve digits then send to the
attendance system and it will remain displaying student record for 5 second before change to the state
to accept another student card number. Each recorded data will be send to the database which developed
using database processing application. Structured query language (SQL) used to query data to produce
various kind of student attendance report. N. M. Z. Hashim, N. A. Ibrahim2, N. M. Saad, F. Sakaguchi,
Z. Zakaria[5] proposed a Barcode Recognition System by using image processing. The system will be
able to read barcode through an image and the system capable to capture the image by using a webcam.
This project will be using MATLAB software program to develop the system and it will integrate with
webcam or digital camera. System will analyze the image and then display on the Graphical User
Interface (GUI) the barcode type, data and size of the image. System is designed to recognize different
types of barcode and display the data once the barcode image is captured. System also is to provide
convenience way of observing data from the barcode with lower costing compared by using the
electronic barcode scanners.

Department of Physics, Bahauddin Zakariya University, Multan


Chapter 03
Hardware and Components

Department of Physics, Bahauddin Zakariya University, Multan


CHAPTER 3

3.1 List of Components

Following is the list of components that are necessary to build the assembly the project.
➢ Arduino Uno Board
➢ Voltage Regulator(LM7805)
➢ 16×2 LCD display
➢ 13V Step Down Transformer
➢ Male and Female Header
➢ Voltage Regulator
➢ Resistors
➢ LED
➢ Potentiometer – 10kΩ
➢ OLED

➢ Bar code scanner


➢ Buzzer
➢ Connecting Wires

➢ Push Button

The system designed was based on fundamental and principles of electromagnetism,


electronic devices, interfacing, intelligent control systems, and software systems.

3.2 Power Supply


Understanding 7805 IC Voltage Regulator

Table of Contents
• Introduction
• A Brief Note on 7805 Voltage Regulator

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 15

• Pin Diagram of 7805 Voltage Regulator IC


• Basic Circuit of 7805
• How to Get Constant DC Power Supply from AC?
o Circuit Diagram
o Components Required
o Working
• Important Points on 7805 Voltage Regulator IC

Introduction

We are going to see about one of the most commonly used regulator IC’s, the 7805 Voltage
Regulator IC. A regulated power supply is very much essential for several electronic devices
due to the semiconductor material employed in them have a fixed rate of current as well as
voltage. The device may get damaged if there is any deviation from the fixed rate.
One of the important sources of DC Supply are Batteries. But using batteries in sensitive
electronic circuits is not a good idea as batteries eventually drain out and lose their potential
over time.
Also, the voltage provided by batteries are typically 1.2V, 3.7V, 9V and 12V. This is good for
circuits whose voltage requirements are in that range. But, most of the TTL IC’s work on 5V
logic and hence we need a mechanism to provide a consistent 5V Supply.
Here comes the 7805 Voltage Regulator IC to the rescue. It is an IC in the 78XX family of
linear voltage regulators that produce a regulated 5V as output.

A Brief Note on 7805 Voltage Regulator


7805 is a three terminal linear voltage regulator IC with a fixed output voltage of 5V which is
useful in a wide range of applications. Currently, the 7805 Voltage Regulator IC is
manufactured by Texas Instruments, ON Semiconductor, STMicroelectronics, Diodes
incorporated, Infineon Technologies, etc.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 16

They are available in several IC Packages like TO-220, SOT-223, TO-263 and TO-3. Out of
these, the TO-220 Package is the most commonly used one (it is the one shown in the above
image).
Some of the important features of the 7805 IC are as follows:
• It can deliver up to 1.5 A of current (with heat sink).
• Has both internal current limiting and thermal shutdown features.
• Requires very minimum external components to fully function.

Pin Diagram of 7805 Voltage Regulator IC


As mentioned earlier, 7805 is a three terminal device with the three pins being 1. INPUT, 2.
GROUND and 3. OUTPUT. The following image shows the pins on a typical 7805 IC in To-
220 Package.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 17

The pin description of the 7805 is described in the following table:

PIN NO. PIN DESCRIPTION

1 INPUT Pin 1 is the INPUT Pin. A positive unregulated voltage is given as


input to this pin.

2 GROUND Pin 2 is the GROUND Pin. It is common to both Input and Output.

3 OUTPUT Pin 3 is the OUTPUT Pin. The output regulated 5V is taken at this
pin of the IC.

Basic Circuit of 7805


As I have previously talked about regulated power supply as a device that works on DC
voltages and it can uphold its output accurately at a fixed voltage all the time even if there is a
significant alteration in the DC input voltage.
As per the datasheets of 7805 IC, the basic circuit required for 7805 to work as a complete
regulator is very simple. In fact, if the input supply is an unregulated DC Voltage, then all you
need are two capacitor (even those are not mandatory depending on the implementation).

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 18

The above circuit shows all the components required for a 7805 IC to work properly. The
0.22μF Capacitor near the input is required only if the distance between the regulator IC and
the power supply filter is high. Also, the 0.1μF Capacitor near the output is optional and if
used, it helps in the transient response.
In this circuit, VIN is the input voltage to the 7805 IC and the source can be from either a
battery of an unregulated DC. VOUT is the output of the 7805 IC, which is a Regulated 5V.

How to Get Constant DC Power Supply from AC?


Although batteries can be used as input to the 7805 Voltage Regulator IC, we face certain
bumps like frequent discharge of batteries and reduction of battery voltage levels over a period
of time.
The best alternative to using Batteries is to provide an unregulated but rectified DC Voltage
from an AC Source. Since AC Source is easily available as mains supply, we can design a
circuit to convert AC Mains to DC and provide it as input to the 7805 Voltage regulator IC.
Circuit Diagram
The following image shows the circuit diagram of producing a regulated 5V from AC Mains
supply.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 19

Components Required
• 230V-12V Step Down Transformer
• Bridge Rectifier (or 4 PN Diodes – 1N4007)
• 1A Fuse
• 1000μF Capacitor
• 7805 Voltage Regulator IC
• 0.22μF Capacitor
• 0.1μF Capacitor
• 1N4007 Diode
Working
The AC power supply from mains first gets converted into and unregulated DC and then into
a constant regulated DC with the help of this circuit. The circuit is made up of transformer,
bridge rectifier made up from diodes, linear voltage regulator 7805 and capacitors.
If you observe, the working of the circuit can be divided into two parts. In the first part, the AC
Mains is converted into unregulated DC and in the second part, this unregulated DC is
converted into regulated 5V DC. So, let us start discussing the working with this in mind.
Initially, a 230V to 12V Step down transformer is taken and its primary is connected to mains
supply. The secondary of the transformer is connected to Bridge rectifier (either a dedicated IC
or a combination of 4 1N4007 Diodes can be used).
A 1A fuse is placed between the transformer and the bridge rectifier. This will limit the current
drawn by the circuit to 1A. The rectified DC from the bridge rectifier is smoothened out with

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 20

the help of 1000μF Capacitor.


So, the output across the 1000μF Capacitor is unregulated 12V DC. This is given as an input
to the 7805 Voltage Regulator IC. 7805 IC then converts this to a regulated 5V DC and the
output can be obtained at its output terminals.

Important Points on 7805 Voltage Regulator IC


• The first important point to note is that the input voltage should always be greater than
the output voltage (atleast by 2.5V).
• The input current and output current are almost identical. This means that when a 7.5V
1A supply is given at input, the output will be 5V 1A.
• The remaining power is dissipated as heat and hence a heat sink like the one shown
below must be used with 7805 IC.

3.3 Arduino Uno

The Arduino UNO is an open-source microcontroller board based on


the Microchip ATmega328P microcontroller and developed by Arduino.cc. The board is
equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits. The board has 14 Digital pins, 6 Analog
pins, and programmable with the Arduino IDE (Integrated Development Environment) via a
type B USB cable.[4] It can be powered by a USB cable or by an external 9 volt battery, though
it accepts voltages between 7 and 20 volts. It is also similar to the Arduino Nano and
Leonardo.The hardware reference design is distributed under a Creative Commons Attribution
Share-Alike 2.5 license and is available on the Arduino website. Layout and production files
for some versions of the hardware are also available. "Uno" means one in Italian and was
chosen to mark the release of Arduino Software (IDE) 1.0.The Uno board and version 1.0 of
Arduino Software (IDE) were the reference versions of Arduino, now evolved to newer
releases. The Uno board is the first in a series of USB Arduino boards, and the reference model
for the Arduino platform. The ATmega328 on the Arduino Uno comes preprogrammed with a
bootloader that allows uploading new code to it without the use of an external hardware
programmer. It communicates using the original STK500 protocol. The Uno also differs from
all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it uses
the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.
’ ‘

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 21

Contents

• 1Background
• 2Technical specifications
• 3Pins
o 3.1General Pin functions
o 3.2Special Pin Functions
• 4Communication
o 4.1Automatic (Software) Reset
• 5See also
• 6References
• 7External links
Background

An early production board

The Arduino project started at the Interaction Design Institute Ivrea (IDII) in Ivrea, Italy. At
that time, the students used a BASIC Stampmicrocontroller at a cost of $100, a considerable
expense for many students. In 2003 Hernando Barragán created the development
platform Wiring as a Master's thesis project at IDII, under the supervision of Massimo Banzi
and Casey Reas, who are known for work on the Processing language. The project goal was to
create simple, low-cost tools for creating digital projects by non-engineers. The Wiring
platform consisted of a printed circuit board (PCB) with an ATmega168 microcontroller, an
IDE based on Processing and library functions to easily program the microcontroller. [8] In
2003, Massimo Banzi, with David Mellis, another IDII student, and David Cuartielles, added
support for the cheaper ATmega8 microcontroller to Wiring. But instead of continuing the
work on Wiring, they forked the project and renamed it Arduino. Early arduino boards used the
FTDI USB-to-serial driver chip and an ATmega168.The Uno differed from all preceding

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 22

boards by featuring the ATmega328P microcontroller and an ATmega16U2 (Atmega8U2 up


to version R2) programmed as a USB-to-serial converter.
Technical Specifications

• Microcontroller: Microchip ATmega328P


• Operating Voltage: 5 Volts
• Input Voltage: 7 to 20 Volts
• Digital I/O Pins: 14 (of which 6 provide PWM output)
• Analog Input Pins: 6
• DC Current per I/O Pin: 20 mA
• DC Current for 3.3V Pin: 50 mA
• Flash Memory: 32 KB of which 0.5 KB used by bootloader
• SRAM: 2 KB
• EEPROM: 1 KB
• Clock Speed: 16 MHz
• Length: 68.6 mm
• Width: 53.4 mm
• Weight: 25 g ’
Pins

Arduino UNO

General Pin functions

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 23

• LED: There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the
LED is on, when the pin is LOW, it's off.
• VIN: The input voltage to the Arduino/Genuine board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated power source).
You can supply voltage through this pin, or, if supplying voltage via the power jack, access
it through this pin.
• 5V: This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 20V), the USB connector (5V), or
the VIN pin of the board (7-20V). Supplying voltage via the 5V or 3.3V pins bypasses the
regulator, and can damage the board.
• 3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50
mA.
• GND: Ground pins.
• IOREF: This pin on the Arduino/Genuino board provides the voltage reference with which
the microcontroller operates. A properly configured shield can read the IOREF pin voltage
and select the appropriate power source or enable voltage translators on the outputs to work
with the 5V or 3.3V.
• Reset: Typically used to add a reset button to shields which block the one on the board.

Special Pin Functions

Each of the 14 digital pins and 6 Analog pins on the Uno can be used as an input or output,
using pinMode(),digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin
can provide or receive 20 mA as recommended operating condition and has an internal pull-up
resistor (disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that must
not be exceeded on any I/O pin to avoid permanent damage to the microcontroller.The Uno has
6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024
different values). By default they measure from ground to 5 volts, though is it possible to
change the upper end of their range using the AREF pin and the analogReference() function.

In addition, some pins have specialized functions:

• Serial / UART: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-
to-TTL Serial chip.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 24

• External Interrupts: pins 2 and 3. These pins can be configured to trigger an interrupt on
a low value, a rising or falling edge, or a change in value.
• PWM (Pulse Width Modulation): 3, 5, 6, 9, 10, and 11 Can provide 8-bit PWM output
with the analogWrite() function.
• SPI (Serial Peripheral Interface): 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins
support SPI communication using the SPI library.
• TWI (Two Wire Interface) / I²C: A4 or SDA pin and A5 or SCL pin. Support TWI
communication using the Wire library.
• AREF (Analog REFerence): Reference voltage for the analog inputs.[

3.4 Maikrt Embedded QR Code Barcode Scanning Module

The Maikrt Embedded QR Code Barcode Scanning Module is a small 1D/2D codes reader. It

can be embedded in any device for scanning code to identify other items. It uses the

intelligent image recognition algorithm for reading QR or Barcode data. It can easily capture

bar codes 1D, 2D on labels, paper, and mobile phone or computer displays. The module has

the best sensitivity and high accuracy.

The module has both USB and TTL interfaces for direct interfacing with a computer or

a microcontroller. It is equipped with 9 pin terminal line and USB cable, which is convenient

for you to convert between the UART TTL serial port and USB interface.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 25

Using the USB interface, the module scans the code directly and sends the result to your host

computer automatically. After receiving the data, the host computer can proceed to the next

step. The default baud rate of this module is set to 9600.

The module has 9-pin 4-wire terminal line for interfacing with a microcontroller. The red wire

is the VCC (+5V) pin, black is the GND. The green and white wires are the Tx and Rx Pins.

The following is the setup code for conversion between TTL & USB interface. You can scan

the QR code of the corresponding interface according to your needs.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 26

Technical Parameters
1. Voltage:5V

2. Power:<0.9w

3. Communication interface: UART TTL\UART RS232\USB

4. Baud Rate: 9600

5. Scanning Mode: Omni-directional Auto Sense Scan Mode

6. Parameter setting method: sweep QR code setting parameter or host command setting

7. Work tips: Buzzer can be connected, LED indicator

8. Scan angle: ±60°, ±40°, ±360° (left-right, front-back, rotation)

9. Scan Distance: 5 to 10cm

10. Working temperature: -25°C~55°C

3.5 I2C OLED Display with Arduino


This article shows how to use the SSD1306 0.96 inch I2C OLED display with the Arduino.
We’ll show you some features of the OLED display, how to connect it to the Arduino board,
and how to write text, draw shapes and display bitmap images. Lastly, we’ll build a project
example that displays temperature and humidity readings.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 27

Introducing the 0.96 inch OLED display

The organic light-emitting diode (OLED) display that we’ll use in this tutorial is the SSD1306
model: a monocolor, 0.96-inch display with 128×64 pixels as shown in the following figure.

The OLED display doesn’t require backlight, which results in a very nice contrast in dark
environments. Additionally, its pixels consume energy only when they are on, so the OLED
display consumes less power when compared with other displays.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 28

The model we’re using here has only four pins and communicates with the Arduino using I2C
communication protocol. There are models that come with an extra RESET pin. There are also
other OLED displays that communicate using SPI communication.

Pin wiring

Because the OLED display uses I2C communication protocol, wiring is very simple. You just
need to connect to the Arduino Uno I2C pins as shown in the table below.

If you’re using a different Arduino board, make sure you check the correct I2C pins:

Pin Wiring to Arduino Uno

Vin 5V

GND GND

SCL A5

SDA A4

▪ Nano: SDA (A4); SCL (A5);


▪ MEGA: SDA (20); SCL (21);
▪ Leonardo: SDA (20); SCL (21);

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 29

Libraries

To control the OLED display you need the adafruit_SSD1306.h and


the adafruit_GFX.h libraries. Follow the next instructions to install those libraries.
1. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The
Library Manager should open.
2. Type “SSD1306” in the search box and install the SSD1306 library from Adafruit.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 30

3. After installing the SSD1306 library from Adafruit, type “GFX” in the search box and install
the library.

4. After installing the libraries, restart your Arduino IDE.

Tips for writing text using these libraries

Here’s some functions that will help you handle the OLED display library to write text or draw
simple graphics.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 31

▪ display.clearDisplay() – all pixels are off


▪ display.drawPixel(x,y, color) – plot a pixel in the x,y coordinates
▪ display.setTextSize(n) – set the font size, supports sizes from 1 to 8
▪ display.setCursor(x,y) – set the coordinates to start writing text
▪ display.print(“message”) – print the characters at location x,y
▪ display.display() – call this method for the changes to make effect

3.6 Pushbutton

A pushbutton really only has two connections, even though it has four legs.

When the button is pressed, there will be a connection between all of the legs. Otherwise, the
two top legs are connected, and the two bottom legs are, but there's no connection between the
top and the bottom.

To see how a pushbutton works, you might want to start by wiring it up to an LED -- just use
the Arduino for power and ground.’

Department of Physics, Bahauddin Zakariya University, Multan


Chapter 4

Setup and Connection


P a g e | 33

4.1 Working of the Project

In this project we will make Barcode + QR Code Reader using Arduino &

Embedded QR/Barcode Scanner Module. The DIY QR & Barcode scanner can scan the

Barcode or QR Code and display the read information on the OLED Display. You can also

make a simple ESP32 CAM QR Scanner using the ESP32 Camera Module but it requires

computer screen for visualization.

QR codes are frequently used to track information about products in a supply chain, often

used in marketing and advertising campaigns. More recently, they have played a key role in

helping to trace coronavirus exposure and slow the spread of the virus. Similarly, Barcodes are

applied to products as a means of quick identification. They are used in retail stores as part of

the purchase process, in warehouses to track inventory, and on invoices to assist in accounting.

For making Arduino Barcode + QR Code Reader, we will use Maikrt Embedded QR Code

Scanning Module. The module supports both USB and UART Serial communication. It is a

small 1D/2D codes reader that can be embedded in any device for scanning code to identify

other items. It uses the intelligent image recognition algorithm to identify the Barcode and

QR Code data.

In this tutorial, we will learn what is QR & Barcode and how the technology works. Apart

from this, we will be going through the details of the Maikrt Embedded QR Code Scanning

Module. And finally, we will interface the Barcode + QR Code Scanner with Arduino Board

and display the read data on OLED Display.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 34

What is Barcode & how it works?


A barcode represents the line of numbers printed underneath it with a pattern

of black and white bars. Barcodes are designed for computers to read quickly by scanning

red LED or laser light across them.

Each digit in a barcode is represented by seven equal-sized vertical blocks. These are colored

in either black or white to represent the decimal numbers 0–9. Every number ultimately

consists of four fat or thin black and white stripes and its pattern is designed so that, even if

you turn it upside down, it can’t be confused with any other number.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 35

How does a barcode scanner work?


A barcode scanner scans digitally convert printed barcodes. It then decodes the data and

sends the data to a computer. It consists of a lens, a source of light, and a light sensor that can

translate optical impulses into electrical signals. A barcode scanner contains a decoder that

analyses the image data provided by the sensor and sends it to the output port. After scanning

an image, it links to a host computer to pass along the captured information.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 36

The decoder recognizes the barcode symbols, translates the bar and space content, and

transmits the data to a computer in such a format that we can read.

What is QR Code & how it works?


A QR code is a scannable barcode encoded with data. Encoded means converted into a

particular form. In the case of QR codes, numeric and alphanumeric characters, bytes, and kanji

convert into a unique two-dimensional arrangement of squares. When an optical scanner

passes over those squares, it translates their arrangement back into that data’s original form.

The most important parts of a QR code are the Data module, Position marker & Quiet zone.

The data module is the standard unit of the QR code. It’s typically a black square set against

a white background. There are three position markers on every QR code. Consisting of an

inner and outer eye, they allow scanners and cameras to quickly and accurately locate the data

modules and the scanning direction. The quiet zone is the blank area on all sides of the data

module matrix that contains all the data modules and position markers. It allows scanners and

readers to optically place where the QR code begins and ends.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 37

How QR Code Scanner work?


The patterns within QR codes represent binary codes that can be interpreted to reveal the

code’s data.

A QR reader can identify a standard QR code based on the three large squares outside the QR

code. Once it has identified these three shapes, it knows that everything contained inside the

square is a QR code.

The QR reader then analyzes the QR code by breaking the whole thing down to a grid. It looks

at the individual grid squares and assigns each one a value based on whether it is black or

white. It then groups grid squares to create larger patterns.

The Maikrt Embedded QR Code Barcode Scanning Module is a small 1D/2D codes reader.

It can be embedded in any device for scanning code to identify other items. It uses the

intelligent image recognition algorithm for reading QR or Barcode data. It can easily capture

bar codes 1D, 2D on labels, paper, and mobile phone or computer displays. The module has

the best sensitivity and high accuracy.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 38

The module has both USB and TTL interfaces for direct interfacing with a computer or

a microcontroller. It is equipped with 9 pin terminal line and USB cable, which is convenient

for you to convert between the UART TTL serial port and USB interface.

Using the USB interface, the module scans the code directly and sends the result to your host

computer automatically. After receiving the data, the host computer can proceed to the next

step. The default baud rate of this module is set to 9600.

The module has 9-pin 4-wire terminal line for interfacing with a microcontroller. The red wire

is the VCC (+5V) pin, black is the GND. The green and white wires are the Tx and Rx Pins.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 39

The following is the setup code for conversion between TTL & USB interface. You can scan

the QR code of the corresponding interface according to your needs.

Technical Parameters
1. Voltage:5V

2. Power:<0.9w

3. Communication interface: UART TTL\UART RS232\USB

4. Baud Rate: 9600

5. Scanning Mode: Omni-directional Auto Sense Scan Mode

6. Parameter setting method: sweep QR code setting parameter or host command setting

7. Work tips: Buzzer can be connected, LED indicator

8. Scan angle: ±60°, ±40°, ±360° (left-right, front-back, rotation)

9. Scan Distance: 5 to 10cm

10. Working temperature: -25°C~55°C

Interfacing Barcode/QR Code Scanner with Arduino


Now let us interface Barcode/QR Code Reader Scanner Module with Arduino. Since the

Module onl requires 4 connection, so its interfacing is fairly simple. The connection diagram

is as follows

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 40

Connect the red wire (VCC) & black wire (GND) of the QR Bar Code Scanner Module to

Arduino 5V & GND pin respectively. Similarly, connect the green wire (Tx) and white wire

(Rx) to D3 & D4 of Arduino.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 41

1 #include <SoftwareSerial.h>
2 SoftwareSerial mySerial(3, 4); // RX, TX
3
4 void setup()
5 {
6 Serial.begin(9600);
7 mySerial.begin(9600); // set the data rate for the SoftwareSerial port
8 }
9
10void loop()
11{
12 if (mySerial.available()) // Check if there is Incoming Data in the Serial Buffer.
13 {
14 while (mySerial.available()) // Keep reading Byte by Byte from the Buffer till the Buffer is
15empty
16 {
17 char input = mySerial.read(); // Read 1 Byte of data and store it in a character variable
18 Serial.print(input); // Print the Byte
19 delay(5); // A small delay
20 }
21 Serial.println();
22 }
}
After the code is uploaded, you can bring any QR Code or Barcode in front of the Module. The

module will identify and ready the data snd display the read data on Serial Monitor.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 42

Portable Barcode/QR Code Scanner with Arduino & OLED Display


The testing of Barcode/QR Code Scanning Module is done using the above code. Now you

can integrate 0.96″ I2C OLED Display with the QR Code Scanner Module and Arduino. This

can be made as a portable device.

The complete circuit diagram along with OLED Display connections is very simple.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 43

The OLED Display is an I2C Module. So it has 4 wires as VCC, GND, SCL & SDA. Connect

the VCC & GND pin to Arduino 5V & GND Pin. Similarly, connect the SCL & SDA Pin to

Arduino A5 & A4 Pin respectively.

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 44

Source Code/Program
The following is the program for portable Arduino Barcode QR Code Scanner. The code

requires two libraries for OLED Display, i.e. Adafruit GFX Library and SSD1306 OLED

Library. First download these libraries from Github link and add it to the Arduino Library

folder.

1 #include <Wire.h>
2 #include <Adafruit_GFX.h>
3 #include <Adafruit_SSD1306.h>
4 #include <SoftwareSerial.h>
5 SoftwareSerial mySerial(3, 4); // RX, TX
6
7 #define SCREEN_WIDTH 128 // OLED display width, in pixels
8 #define SCREEN_HEIGHT 64 // OLED display height, in pixels
9 #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
10
11Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
12
13void setup()

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 45

14{
15 Serial.begin(9600);
16 mySerial.begin(9600); // set the data rate for the SoftwareSerial port
17 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C
18(128x64)
19 display.clearDisplay();
20}
21
22void loop()
23{
24 if (mySerial.available()) // Check if there is Incoming Data in the Serial Buffer.
25 {
26 display.setCursor(0, 0); //oled display
27
28 while (mySerial.available()) // Keep reading Byte by Byte from the Buffer till the Buffer is
29empty
30 {
31 char input = mySerial.read(); // Read 1 Byte of data and store it in a character variable
32 Serial.print(input); // Print the Byte
33
34 display.setTextSize(2);
35 display.setTextColor(WHITE);
36 display.print(input);
37 display.display();
38 delay(5);
39 }
40 Serial.println();
41 display.clearDisplay();
}
}

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 46

Chapter 5
Conclusion and References

Department of Physics, Bahauddin Zakariya University, Multan


P a g e | 47

5.1 CONCLUSION

The barcode scanner works very close to how we expected. Because the provided camera has neither
autofocus nor flash, it was often difficult to determine the exact cause of problems. However, after
extensive testing we were able to produce a working scanner with good results. Thanks to efficient
image conversion and decoding processes, the entire process runs predictably within reasonable time
constraints; roughly a few seconds. As far as resources are concerned, waste is kept low thanks to our
pipelined data processing approach. Although decoding often takes up the majority of the process, the
time it takes is usually constant. Therefore, the network connection can be considered the major
bottleneck since it may produce uncontrollable results. Barcode decoding with mobile devices is
definitely possible with the correct implementation. Yet in practice, results are dependent on the quality
of the camera as well as the speed of the network connection.

5.2 REFERENCES

[1]. S. Subaashri, M. Sowndarya, D.K.S. Sowmiyalaxmi, S.V. Sivassan, C. Rajasekaran


(2017), ‘Automatic Pet Monitoring & Feeding System using IoT, Vol. No. 10, PP 253-258.
[2]. Lewis o Wing (1993), ‘Aytomatic Pet Feeder’.
[3]. Chung-Ming Own, Haw-Yunshin, Chen-Ya Teng (2013), ‘The Study & Application of
the IoT in Pet Systems’ Vol.1, No.3, PP 1-8, http://dx.doi.org.
[4]. Rachel Hail, Kristine McCarthy, Filip Rege, Alexix Rodrigvez Carlson (2008), ‘The Smart
Pet Feeder’.

Department of Physics, Bahauddin Zakariya University, Multan

You might also like