Barcode Scanner.jpg

Barcode scanner with Node-RED/PLC via ctrlX CORE using USB port


This How-To explains how to read a 2D barcode with a scanner. The scanner is connected to the ctrlX CORE via the USB-C port. The data can be read in with the PLC or Node-RED application.

  • ctrlX CORE
  • 2D Barcode Scanner (this examples uses the Voyager XP 1470g) with USB to USB-C adapter
  • Pre-installed PLC or Node-RED app
Scanner Configuration

To begin, the ctrlX CORE must be connected to the computer and the scanner to the ctrlX CORE. The scanner is then programmed using a reference code.
The basic configuration described in this point is the same for the Node-RED as well as for the PLC App.



  1. Connect the ctrlX CORE to the computer via the engineering port and open ctrlX WORKS (Quick Start Guide ctrlX CORE).
  2. Connect the Voyager XP 1470g 2D scanner to the USB-C interface of the ctrlX CORE.
  3. To reset the scanner to the factory settings, scan the Activate Custom Defaults barcode below.



  4. Scan the following code to programme the scanner. Scanning this code also adds carriage return and line feed.

    Barcode Reference.jpg

    Note: Depending on the country, port or characters being scanned, a different reference code must be used. Different reference codes are listed in the Voyager User Guide.

Example Barcode

To test the examples below, a test barcode is created with the content "Hello World".

Hello World Bar Code.JPG

Different barcodes can be created with this online configurator.

A) Realisation with Node-RED

With Node-RED, the scanner configuration can be realised graphically in a browser by inserting nodes.

  1. Open the Node-RED App using the ctrlX Works interface.

    Open Node-RED Flow Editor.JPG

  2. In the Node-RED dashboard, the nodes that can be added are visible on the left-hand side.
    For the realisation of the project we need to add a "serial in" and a "debug" node. Then the nodes are connected to each other.

    Insert Nodes.JPG

  3. Then double-click on the "serial in" node and rename it to "Scanner".
    Then define the serial port.

    Edit serial in Node.JPG

  4.  Change the port as follows and accept it:

  5. Check if the "Scanner Node" is connected (when the green light is on). Then execute the Node-RED Flow by pressing the "Deploy" button. From now on, the scanner is online and you can scan.
    Deploy Node-RED.JPG

  6.  Now it is possible to read the barcode using the barcode scanner. To do this, we read in the example barcode "Hello World" from the chapter "Scanner Configuration". It can be seen that the interpretation of the barcode is now displayed in Node-RED:


B) Realisation with PLC
  1. Open the PLC App using the ctrlX Works interface.

    Open PLC App.JPG

  2. When the PLC programme has opened, create a new project. Make sure that the PLC app is connected to the ctrlX CORE.

    New PLC Project.JPG

  3. Download the PRG_Barcode_Scanner.xml file attached to this How-To.

  4. Import the file PRG_Barcode_Scanner.xml into the PLC App.

    Import xml File.JPG

  5. Drag the program "PRG_Barcode_Scanner (PRG)" from "Application" into the "Task Configuration" of the PLC App.

    Task Configuration.jpg

  6. Add the "SysCom" library. To do this, double-click on "Library Manager", then click on "Add Library" and use the search function to find and add the "SysCom" library.

    Add Syscom Library.JPG

  7. Repeat the process and add the library "CmpSettings".

    Add CmpSettings Library.JPG

  8. Generate the code of the programme. Check that there are no error messages. Otherwise, correct the error messages.

    Generate Code.JPG

  9. Press the "Login" button.

    LogIn PLC.JPG

  10. After logging in, check that the "iState" in the programme corresponds to "0". Then press the "Start" button.

    Run, iState equals 0.JPG

    Note: Playing "Case 0" opens/configures the port.

  11. Then save the project and restart the ctrlX CORE (to complete the configuration of the port)

  12. When the restart has been completed, open the PLC project via the ctrlX WORKS interface (make sure that the PLC project is connected to the ctrlX CORE).

  13. Log in to PLC App again (as in step 9)

  14. In the PRG_Barcode_Scanner programme, change the "iState" from 0 to 1. To do this, double-click on the red box next to "iState". Then a new window opens and replace the 0 with a 1. Then accept this with "OK".

    iState equals 1.JPG

  15. Press the key combination "Ctrl" + "F7" to write the values online.


  16.  Press the "Start" button to run the program.

  17. Now it is possible to read the barcode using the barcode scanner. To do this, we read in the example barcode "Hello World" from the chapter "Scanner Configuration".
    It can be seen that it displays the barcode in the PLC as decimal - ASCII:


Hint: If the scanner is reconfigured, the ctrlX CORE must be restarted.


Must Read