Barcode Scanner

Summary of Barcode Scanner


Summary: They built a barcode scanner using an OV7670 CMOS camera, a PIC32MX250F128B microcontroller, and an ESP8266 Wi-Fi module. The system captures black/white bar patterns, compresses pixel data to fit PIC32 memory, decodes bar sequences into binary, displays results on a TFT, and sends decoded data over Wi-Fi to a web page hosted by the ESP8266. Key challenges included SCCB vs I2C configuration differences, pin limitations, PCLK slowing, and aggressive bit-level compression for memory constraints.

Parts used in the Barcode Scanner:

  • OV7670 CMOS camera module
  • PIC32MX250F128B microcontroller (PIC32)
  • ESP8266 Wi-Fi breakout (Adafruit)
  • TFT display
  • Raspberry Pi (used as hotspot)
  • Pull-up resistors (5K) for SIO_C and SIO_D
  • Wiring and connectors (for UART, I2C/SCCB, power, grounds)
  • Power supply (3.0V for camera and appropriate supplies for other parts)
  • Buttons (Decoding/Display button)

Introduction

In our final project, we used CMOS camera to identify interval binary 0 and 1 sequence represented by black and white bars. Then, we used WIFI module to transmit the sequence to personal computer and displayed it on a web page.

In our projects, we chose OV7670 CMOS camera and ESP8266 WIFI module for image capture and WIFI transmission. Since PIC32MX250F128B only has 32K bytes inside memory and a low CPU frequency compared to the large data scale of image, we did data compression and data processing in order to match the PIC32 with OV7670. What is more, we did some adjustment to I2C transmission in order to configure the camera which originally used a SCCB (Serial Camera Control Bus) to set up.

For WIFI part, we used UART to connect the microcontroller and WIFI module. Since Cornell campus WIFI is not proper to use for a WIFI module, we set a raspberry pi as a hotspot.

High Level Design

Rationale and Source of Our Project Idea

What does “microcontroller” mean? It means “control”. The reason we used microcontroller was to control different peripheral devices. OV7670 CMOS camera is a popular CMOS camera and has been widely used. However, there is little information about using OV7670 on PIC. So we thought it would be very cool to build the connection between OV7670 and PIC. What is more, in lab4, we have built the wired connection between the personal computer and PIC by USB wire so we wanted to build the wireless connection by WIFI in our final project.

In addition, nowadays, the barcode is widely used. As is known to all, the barcode consists only black and white bars which can be easily represented by binary 0 and 1. The simple representation of barcode is proper to the PIC32 which only has 32K Bytes memory.

Quick Solutions to Questions related to Barcode Scanner:

  • What camera was used to capture images?
    The OV7670 CMOS camera was used for image capture in RGB444 mode.
  • How did the team connect the camera to the PIC32 given SCCB differences?
    They used I2C but modified it to not wait for an ACK so the SCCB-style writes from the camera would not block transmission.
  • Can the PIC32 store full frames from the OV7670?
    No, the PIC32 32K memory is insufficient, so they compressed image data by packing bits into bytes, reducing storage by 16 times.
  • How did they reduce the number of camera data pins used?
    They only read the top bit of the R parameter in RGB444 (using D3 and D2) since a threshold on one channel was sufficient to distinguish black and white.
  • How is data transmitted from PIC32 to the web page?
    The PIC32 sends decoded binary via UART to the ESP8266, which hosts a server and displays results accessible on the local network.
  • What mode and settings were chosen for the OV7670?
    They chose QVGA output, RGB444 format, PCLK prescaled by 128, and closed AWB.
  • Does the system display images locally?
    Yes, when not in decoding mode the PIC displays the compressed black-and-white image on a TFT for debugging and monitoring.
  • How accurate is the barcode recognition?
    It can accurately identify eight black-and-white bars; overall accuracy is affected by lighting, compression, and image quality limitations.
  • How reliable is the Wi-Fi transmission?
    The Wi-Fi transmission accuracy is reported as 100%; devices on the same local network see exactly the decoded result.
  • Why was a Raspberry Pi used in the setup?
    The Raspberry Pi was used as a hotspot because the campus Wi-Fi was not suitable for the ESP8266 module.

About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.