Skip to main content

Quick Start

Connect the scanner to a microcontroller over UART, install the library, and print every barcode you scan.

You program the controller connected to this breakout. The breakout itself is not flashed.

Switch the scanner to UART first. The scanner ships in USB mode, and in that mode it does not answer on RX and TX. Scan the POR232 (TTL/RS232) configuration barcode once to switch it to UART. The Arduino library's repository has a file named TTL-Mode.PNG in its barcodes folder.

The header pins use 3.3 V logic. When you power the board from the controller's header instead of USB-C, use the controller's 3.3 V pin and never connect 3V3 to 5 V.

1. Connect the breakout board​

This example is written for an ESP32 board: it talks to the scanner through the ESP32's hardware UART2 (HardwareSerial(2)) on GPIO4 and GPIO5. Cross the data lines: the controller's TX goes to the scanner's RX, and the scanner's TX goes to the controller's RX.

ControllerSoldered Barcode Scanner DE2120
GPIO5 (TX)RX
GPIO4 (RX)TX
3V33V3
GNDGND
Soldered Barcode Scanner DE2120 breakout seen from above
Top down

2. Install the library​

Install Soldered DE2120 from its GitHub repository.

🔗Soldered DE2120 Arduino library

Verified Arduino library at commit 697eb25

→

Tip: downloading from GitHub. On the library's GitHub page, click the green Code button and choose Download ZIP, then add it in Arduino IDE with Sketch → Include Library → Add .ZIP Library....

The library includes SoftwareSerial.h, so a SoftwareSerial library has to be installed even when your sketch uses a hardware UART. The library's examples point to the Arduino Library Manager for it.

3. Run the first example​

Open HardwareScan from the library's examples, select your ESP32 board and port, and upload it. The sketch starts the ESP32's UART2 on GPIO4 (RX) and GPIO5 (TX), finds the scanner, and prints every code it reads.

Select Board
HardwareScan.ino
/**
**************************************************
*
* @file HardwareScan.ino
* @brief Scan and output barcodes using the DE2120 1D/2D barcode
* scanner module over HardwareSerial (UART2) on ESP32.
*
* Unlike SoftwareSerial, HardwareSerial uses a dedicated
* UART peripheral for reliable communication at 115200 bps.
* The library will automatically negotiate the baud rate
* down to 9600 bps on first connect.
*
* Default wiring: GPIO4 = RX (scanner TX),
* GPIO5 = TX (scanner RX). Change the pin arguments in
* scannerSerial.begin() to match your wiring.
*
* The scanner must first be put into TTL/RS232 mode by
* scanning the POR232 barcode from the DYScan settings
* manual before uploading this sketch.
*
* Make sure you have SoftwareSerial library installed. It
* can be found in Arduino library manager.
*
* @authors Fran Fodor @ soldered.com
***************************************************/

#include "HardwareSerial.h"
HardwareSerial scannerSerial(2); // Use UART2

#include "DE2120-SOLDERED.h"
DE2120_Soldered scanner;

#define BUFFER_LEN 40
char scanBuffer[BUFFER_LEN];

void setup()
{
Serial.begin(115200);
Serial.println("DE2120 Scanner Example");

scannerSerial.begin(115200, SERIAL_8N1, 4, 5); // RX=GPIO4, TX=GPIO5
delay(500);

if (scanner.begin(scannerSerial) == false)
{
Serial.println("Scanner did not respond. Please check wiring. Did you scan the POR232 barcode? Freezing...");
while (1);
}
Serial.println("Scanner online!");
}

void loop()
{
if (scanner.readBarcode(scanBuffer, BUFFER_LEN))
{
Serial.print("Code found: ");
for (int i = 0; i < strlen(scanBuffer); i++)
Serial.print(scanBuffer[i]);
Serial.println();
}
delay(200);
}

4. Check the result​

Open the Serial Monitor at 115200 baud. When the scanner answers, you see:

Serial MonitorAutoscrollShow timestampNewline115200 baud
Message (Enter to send message to the board)
DE2120 Scanner Example
Scanner online!

The scanner starts in manual mode, so press the trigger button on the board and point it at a barcode. Each code it reads prints on its own line as Code found: followed by the code's contents.

If you see Scanner did not respond. Please check wiring. Did you scan the POR232 barcode? Freezing... instead, the scanner is still in USB mode or RX and TX are swapped.

5. If it does not work​

Continue with Troubleshooting and retry this smallest example after each change.