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.When to use this
UseTYPE 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
- Decode an image
- Encode a symbol
- Line scanner
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 setsMODE 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 asdata: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.
Annotation
Annotation
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 encodeSOURCE_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.
PDF page placement
PDF page placement
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 toSOURCE_TOPIC, or hand the payload to a named event:
Best Practices
Image quality
Image quality
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.Format selection
Format selection
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.Errors
Errors
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
No barcode found in image
No barcode found in image
Confirm the symbol is in frame and the format name is listed in
SUPPORTED_FORMATS. Retry with a smaller, sharper image.Invalid barcode format
Invalid barcode format
Use the uppercase names from the format table, spelled exactly, and include that name in
SUPPORTED_FORMATS.Base64 decode error
Base64 decode error
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.

