Skip to main content

Read and draw barcodes on MQTT

The Barcode connector turns an image on a topic into the text inside the symbol, or turns text into a PNG or PDF you can display and print. Point a camera connector at the decode event when the image is already a frame on MQTT.
Like a checkout scanner. You show it a picture of the code (decode), or you hand it the product number and it prints the label (encode).

When to use this

Use TYPE BARCODE when a camera, file, or upstream system already has the image, or when you need to generate a QR, retail, or 2D symbol from text. Limit SUPPORTED_FORMATS to the families you actually scan so detection stays fast.
Each tab below is a complete connector. Publish an image to the decode topic, or a JSON request to the encode topic.

Quick Start

Read a symbol from a base64 image and publish JSON, plus an annotated copy of the frame:

Configuration

string
Comma-separated format names. Omit it to allow every format in the table below. Names are uppercase (QR_CODE, not qr_code).

Supported formats

Events

Every event sets MODE to DECODE or ENCODE.
string
required
DECODE reads a symbol from an image. ENCODE draws a symbol from JSON.
string
required
Topic that triggers the event. Decode expects an image. Encode expects JSON.
string
required
Topic for the JSON result.

Decode

Publish the image as a raw base64 string. A data-URI prefix such as data:image/jpeg;base64, is accepted. A Video Input frame is already in that form, so you can set the decode SOURCE_TOPIC to the camera’s frame topic.
string
true or false. Default: true. Draws a box around the symbol that was read.
string
Topic for the annotated image. The payload is a raw base64 string, same shape as the input image.
string
Color name, for example Red or Blue. Default: Red.
string
Line thickness as an integer. Default: 5.
A successful decode publishes JSON like this:
When no symbol is found, success is false and error explains why (for example No barcode found in image). Check success before you trust text. Large frames are scaled down before detection. If a sharp 1080p frame still fails, publish a 1280×720 or 640×480 image instead.

Encode

Publish JSON on the encode SOURCE_TOPIC. text is the payload to draw. format must be one of the names in SUPPORTED_FORMATS.
An image result includes image_base64 (data:image/png;base64,…). A PDF result includes pdf_base64 (data:application/pdf;base64,…). Both include success, text, format, output_type, width, height, timestamp, route_name, and event_name.
Set output_type to PDF and add pdf_options. Units are points (A4 is 595 × 842).

Trigger from an action

Publish the image or the encode JSON straight to SOURCE_TOPIC, or hand the payload to a named event:

Best Practices

Use a sharp, evenly lit frame. Blur and glare are the usual reason decode returns No barcode found in image. For retail codes, 640×480 to 1280×720 is enough.
QR for URLs and mixed content. EAN-13 and UPC-A for retail. Code 128 for alphanumeric IDs. List only those names in SUPPORTED_FORMATS.
Branch on success. A false result still arrives on DESTINATION_TOPIC, so a downstream action should not treat every message as a good scan.

Troubleshooting

Confirm the symbol is in frame and the format name is listed in SUPPORTED_FORMATS. Retry with a smaller, sharper image.
Use the uppercase names from the format table, spelled exactly, and include that name in SUPPORTED_FORMATS.
The payload must be the base64 image, with or without a data:image/…;base64, prefix, and with no extra characters around it.

Next Steps

Video Input

Publish camera frames, then point a decode event at that topic.

Media Connectors

Choose barcode, video, or audio.
Last modified on October 21, 2026