# Sending UART command to barcode scanner

**URL:** https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441
**Category:** General
**Created:** [11 November 2022 11:47 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441 "2022-11-11T11:47:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![fkristofb](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@fkristofb](https://discourse.nodered.org/u/fkristofb)
#### Post date: [11 November 2022 11:47 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/1 "2022-11-11T11:47:17Z")

</div>

Hi all,

I am working on a Raspberry PI and am trying to find a way so that when the end user presses a button a command is executed for the module and and it starts to scan.  
It is a Waveshare barcode scanner module.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0db252322d16d6e7471d0abd09d44d3c71dd79ed.png)

This is the only clue (see image) I have from the manual  
([https://www.waveshare.com/w/upload/d/dd/Barcode\_Scanner\_Module\_Setting\_Manual\_EN.pdf](https://www.waveshare.com/w/upload/d/dd/Barcode_Scanner_Module_Setting_Manual_EN.pdf))  
and as it needs it to be via UART I have to use the GPIO pins.  
The module requires the pins: VCC (5V); TXD; RXD; GND (Ground)

I have found found a kind of solution on the arduino forum ([Sending UART command to barcode scanner - Programming Questions - Arduino Forum](https://forum.arduino.cc/t/sending-uart-command-to-barcode-scanner/628158)) but I don't know how to implement it to node-RED and it's still unclear to me how he managed to do it.

Please note that I am not very familiar with coding and the exec node is kind of a mystery to me so if anyone could be so kind to help me it would be much appreciated.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [11 November 2022 12:29 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/2 "2022-11-11T12:29:33Z")

</div>

Is there a reason why you cannot use the USB interface of the module?

Also note: If the module uses 5V on the TX or RX you will have to use a level converter to connect it to your Pi, **which is strictly 3.3V.**

---

<div class="post-metadata">

### Author: ![fkristofb](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@fkristofb](https://discourse.nodered.org/u/fkristofb)
#### Post date: [11 November 2022 13:03 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/3 "2022-11-11T13:03:58Z")

</div>

Thanks for your reply

Sorry I thougth that UART command can only be sent by the TXD-RXD pins. If it's not the case I suppose I can manage it somehow if it's essentially more simple.

I'm not sure what you mean by needing a level converter  
On the manufacturer's site ([Barcode Scanner Module, 1D/2D Codes Reader](https://www.waveshare.com/barcode-scanner-module.htm)) under specifications they wrote "Operating voltage: 5V" and the PI has a 5V (and a 3.3V) pin.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [11 November 2022 13:08 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/4 "2022-11-11T13:08:26Z")

</div>

> [@fkristofb](#):
>
> I'm not sure what you mean by needing a level converter  
> On the manufacturer's site ([Barcode Scanner Module, 1D/2D Codes Reader](https://www.waveshare.com/barcode-scanner-module.htm)) under specifications they wrote "Operating voltage: 5V" and the PI has a 5V (and a 3.3V) pin.

But does it use 5V on the UART pins? If it does you should not connect it to the Pi GPIO's, as they only tolerate 3.3V.

Much easier to use the USB interface.

---

<div class="post-metadata">

### Author: ![fkristofb](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@fkristofb](https://discourse.nodered.org/u/fkristofb)
#### Post date: [11 November 2022 13:17 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/5 "2022-11-11T13:17:43Z")

</div>

I really don't know as they only wrote

> "Operating voltage: 5V"

But I've connected it to the USB port so it's not a problem.

---

<div class="post-metadata">

### Author: ![Aurgelme](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@Aurgelme](https://discourse.nodered.org/u/Aurgelme)
#### Post date: [13 November 2022 08:20 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/6 "2022-11-13T08:20:43Z")

</div>

As fkristofb writes and it says in the manual it is 5V ttl. You cannot connect 5v ttl to the gpio pins, otherwise you will destroy the raspberry pi.  
I haven't found out what kind of usb adapter comes with your scanner, but it says in the manual that if you want to connect it to a PC, you must use TTL. A usb to ttl adapter gives you a virtual serial port under the pi, but of course it must be a version that supports 5V.  
Check under /dev if the supplied usb adapter creates a serial port, if not get such an adapter.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 January 2023 08:21 UTC](https://discourse.nodered.org/t/sending-uart-command-to-barcode-scanner/70441/7 "2023-01-12T08:21:01Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
