# Wake up/sleep a barcode scanner using UART command

**URL:** <https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789>\
**Category:** Programming\
**Created:** [April 2, 2025, 12:54pm UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789 "2025-04-02T12:54:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pommerose65](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pommerose65/32/1126890_2.png) [@pommerose65](https://forum.arduino.cc/u/pommerose65)\
**Post date:** [April 2, 2025, 12:54pm UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789/1 "2025-04-02T12:54:24Z")

</div>

Hello,  
I'm an engineering student and i have problems putting a barcode scanner to sleep/wake up. I use a 3,3V arduino MKR WAN 1310, and i need to put a barcode scanner to sleep/wake up. Here is my code so far. The scanning part works fine, but the Serial1.write() does not work at all.

```arduino
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  while (!Serial);
  delay(1000); // Initialisation
}

void loop() {
  if (Serial.available()) {
    String command = Serial.readStringUntil('\n');
    command.trim();
    
    if (command.equalsIgnoreCase("veille")) {
      Serial.println("Mise en veille du scanner...");
      Serial1.write((0xA5); // Envoie de l'octet 0xA5 pour mettre en veille
      delay(100); // Attendre un peu pour permettre au scanner d'entrer en veille
    } else if (command.equalsIgnoreCase("reveille")) {
      Serial.println("Réveil du scanner...");
      Serial1.write(0x00); // Envoie de l'octet 0x00 pour réveiller le scanner
      delay(100); // Attendre un peu pour permettre au scanner de se réveiller
    } else {
      Serial.println("Commande non reconnue");
    }
  }

  lecture();
}

void lecture() {
  if (Serial1.available()) {
    String receivedData = Serial1.readStringUntil('\n');
    Serial.print("Données reçues : ");
    Serial.println(receivedData);
  }

```

and here is a picture of the documentation, and a link. [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)  
I think i have difficulties understanding how to use the Serial1.write() function, what is the adress? what is bit 7-0??.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/0/a/2/0a2f78f8dd75d4e74b19de308b440515624ae3ef.png)  
Thank you so much for your help ! thank you

---

<div class="post-metadata">

**Author:** ![kmin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kmin/32/1147370_2.png) [@kmin](https://forum.arduino.cc/u/kmin)\
**Post date:** [April 2, 2025, 1:03pm UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789/2 "2025-04-02T13:03:38Z")

</div>

Have a look at the write examples on the manual.

---

<div class="post-metadata">

**Author:** ![kmin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kmin/32/1147370_2.png) [@kmin](https://forum.arduino.cc/u/kmin)\
**Post date:** [April 2, 2025, 1:33pm UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789/3 "2025-04-02T13:33:30Z")

</div>

I think this would be command for A5:  
0x7E, 0x00, 0x08, 0x01, 0x00, 0xD9, 0xA5, 0x3E, 0x69

---

<div class="post-metadata">

**Author:** ![pommerose65](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pommerose65/32/1126890_2.png) [@pommerose65](https://forum.arduino.cc/u/pommerose65)\
**Post date:** [April 3, 2025, 11:42am UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789/4 "2025-04-03T11:42:47Z")

</div>

Thank you this byte sequence worked perfectly! I need to spend time on the doc to understand exactly how to create a byte sequence but i am very thankful!

---

<div class="post-metadata">

**Author:** ![kmin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kmin/32/1147370_2.png) [@kmin](https://forum.arduino.cc/u/kmin)\
**Post date:** [April 3, 2025, 12:27pm UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789/5 "2025-04-03T12:27:06Z")

</div>

Wasn't complicated.  
0x7E, 0x00, header  
0x08, write (07 for read)  
0x01, number of bytes  
0x00, 0xD9, address  
0xA5, byte to write  
0x3E, 0x69 checksum (calculated without header)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 30, 2025, 12:27pm UTC](https://forum.arduino.cc/t/wake-up-sleep-a-barcode-scanner-using-uart-command/1369789/6 "2025-09-30T12:27:44Z")

</div>

Closed on September 30, 2025, 12:27pm UTC

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