<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QR-Code Reader - Trigger read from serial port and read code value]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/3919/atomic-qr-code-reader-documentation-trigger-in-host-mode">ATOMIC QR-CODE READER - Documentation - Trigger in Host Mode</a></p>
<p dir="auto">Seems obvious that it should be possible to trigger the reading of a QR code from the serial port and read the code value after that. I have tried but failed. Reading the value works fine fut so far only the button trigger mode works reliably.</p>
<p dir="auto">Has someone made this work that could share what settings are necessary and how the trigger is sent through the serial port?</p>
<p dir="auto">Best regards</p>
]]></description><link>https://community.m5stack.com/topic/6462/qr-code-reader-trigger-read-from-serial-port-and-read-code-value</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 08:43:45 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6462.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 May 2024 08:15:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QR-Code Reader - Trigger read from serial port and read code value on Tue, 28 May 2024 16:45:29 GMT]]></title><description><![CDATA[<p dir="auto">I think I still am doing something wrong. In the example below it seems that the M5 isn't reacting to the commands. Do I have to scan a QR code from the manual first to get it into the proper state?</p>
<p dir="auto">Example 1:</p>
<pre><code>import serial
import time

wakeup_cmd = bytes([0x00])
host_mode_cmd = bytes([0x07, 0xC6, 0x04, 0x08, 0x00, 0x8A, 0x08, 0xFE, 0x95])
start_scan_cmd = bytes([0x04, 0xE4, 0x04, 0x00, 0xFF, 0x14])
stop_scan_cmd = bytes([0x04, 0xE5, 0x04, 0x00, 0xFF, 0x13])

print('Open serial port')
ser = serial.Serial('COM4', 9600, timeout=1)  # Adjust the port name and baud rate as needed

try:
    print('Wake up!')
    ser.write(wakeup_cmd)
    time.sleep(0.05)
    
    print('Host mode')
    ser.write(host_mode_cmd) 
    time.sleep(0.5)
    
    print('Start scan')
    ser.write(start_scan_cmd)
    time.sleep(3)

    print('Stop scan')
    ser.write(stop_scan_cmd)
    time.sleep(1)

    print('Bytes waiting at serial port: ' + str(ser.in_waiting))
    response = ser.read(ser.in_waiting)
    print("Received:", response.decode())

except Exception as e:
    print("Error communicating with serial device: ", e)

finally:
    print("Close serial port")
    ser.close()
</code></pre>
<p dir="auto">The output:</p>
<p dir="auto">Open serial port<br />
Wake up!<br />
Host mode<br />
Start scan<br />
Stop scan<br />
Bytes waiting at serial port: 0<br />
Received:<br />
Close serial port</p>
<p dir="auto">Doing something simpler doesn't work either:</p>
<p dir="auto">Example 2:</p>
<pre><code>software_version_cmd = bytes([0x04, 0xA3, 0x04, 0x00, 0xFF, 0x55])

print('Open serial port')
ser = serial.Serial('COM4', 9600, timeout=1)  # Adjust the port name and baud rate as needed

try:
    print('Wake up!')
    ser.write(wakeup_cmd)
    time.sleep(0.05)
    
    print('Check software version')
    ser.write(software_version_cmd)
    time.sleep(1)

    print('Bytes waiting at serial port: ' + str(ser.in_waiting))
    response = ser.read(ser.in_waiting)
    print("Received:", response.decode())

except Exception as e:
    print("Error communicating with serial device: ", e)

finally:
    print("Close serial port")
    ser.close()
</code></pre>
<p dir="auto">The output:</p>
<p dir="auto">Open serial port<br />
Wake up!<br />
Check software version<br />
Bytes waiting at serial port: 0<br />
Received:<br />
Close serial port</p>
]]></description><link>https://community.m5stack.com/post/25417</link><guid isPermaLink="true">https://community.m5stack.com/post/25417</guid><dc:creator><![CDATA[qrcoder]]></dc:creator><pubDate>Tue, 28 May 2024 16:45:29 GMT</pubDate></item><item><title><![CDATA[Reply to QR-Code Reader - Trigger read from serial port and read code value on Tue, 14 May 2024 12:22:54 GMT]]></title><description><![CDATA[<p dir="auto">From <a href="https://github.com/m5stack/M5Atom/blob/master/examples/ATOM_BASE/ATOM_QRCode/UART_CMD_CONTROL/UART_CMD_CONTROL.ino" target="_blank" rel="noopener noreferrer nofollow ugc">this Arduino example</a> the answer is yes.</p>
<p dir="auto">Note I think there is a typo in line 49.</p>
<p dir="auto">Serial2.write(<strong>start</strong>_scan_cmd, sizeof(stop_scan_cmd));</p>
<p dir="auto">should probably be</p>
<p dir="auto">Serial2.write(<strong>stop</strong>_scan_cmd, sizeof(stop_scan_cmd));</p>
]]></description><link>https://community.m5stack.com/post/25225</link><guid isPermaLink="true">https://community.m5stack.com/post/25225</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Tue, 14 May 2024 12:22:54 GMT</pubDate></item><item><title><![CDATA[Reply to QR-Code Reader - Trigger read from serial port and read code value on Tue, 14 May 2024 11:25:14 GMT]]></title><description><![CDATA[<p dir="auto">Yes, I have seen that document, but it is not clear to me what sequence of commands is necessary to trigger the reading of a QR code from the serial port.<br />
Is the sequence something like:</p>
<ol>
<li>Send wake-up and wait 50ms ( 0x0)</li>
<li>Send host command (0x 07 C6 04 08 00 8A 08 FE 9)<br />
what now?</li>
<li>start decoding (0x 04 E4 04 00 FF 14) wait x ms</li>
<li>stop decoding (0x 04 E5 04 00 FF 13)</li>
<li>read from serial port</li>
</ol>
<p dir="auto">or is the sequence something else?</p>
<p dir="auto">Grateful for your help!</p>
]]></description><link>https://community.m5stack.com/post/25223</link><guid isPermaLink="true">https://community.m5stack.com/post/25223</guid><dc:creator><![CDATA[qrcoder]]></dc:creator><pubDate>Tue, 14 May 2024 11:25:14 GMT</pubDate></item><item><title><![CDATA[Reply to QR-Code Reader - Trigger read from serial port and read code value on Mon, 13 May 2024 15:33:11 GMT]]></title><description><![CDATA[<p dir="auto">Have you read <a href="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/atombase/AtomicQR/ATOM_QRCODE_CMD_EN.pdf" target="_blank" rel="noopener noreferrer nofollow ugc">this document?</a></p>
]]></description><link>https://community.m5stack.com/post/25207</link><guid isPermaLink="true">https://community.m5stack.com/post/25207</guid><dc:creator><![CDATA[Cognitive5525]]></dc:creator><pubDate>Mon, 13 May 2024 15:33:11 GMT</pubDate></item></channel></rss>