<?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[equivalent to pyb.USB_VCP() or lobo&#x27;s machine.stdin_get()]]></title><description><![CDATA[<p dir="auto">If you have a Pycom board running a looping script on a LiPo battery out in the field, it would be really useful for it to detect when a USB cable has been connected, and exit out of the script.</p>
<p dir="auto">Does anyone know if there is an equivalent to Pyboard's pyb.USB_VCP() function; specifically the <a href="http://docs.micropython.org/en/v1.9.3/pyboard/library/pyb.USB_VCP.html#pyb.USB_VCP.any" target="_blank" rel="noopener noreferrer nofollow">vcp.any</a> function?  This returns True when a USB connection is detected.<br />
Lobo's micropython port has the  <a href="https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/machine#machinestdin_getlen-timeout" target="_blank" rel="noopener noreferrer nofollow">machine.stdin_get() function</a> which passes in a timeout parameter, making it non-blocking. This does not detect the USB but does allow a check if a char is entered within a time period, before continuing on with the script.</p>
]]></description><link>https://forum.pycom.io/topic/3980/equivalent-to-pyb-usb_vcp-or-lobo-s-machine-stdin_get</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 18:47:36 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/3980.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 10 Nov 2018 07:44:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to equivalent to pyb.USB_VCP() or lobo&#x27;s machine.stdin_get() on Sat, 10 Nov 2018 07:44:39 GMT]]></title><description><![CDATA[<p dir="auto">If you have a Pycom board running a looping script on a LiPo battery out in the field, it would be really useful for it to detect when a USB cable has been connected, and exit out of the script.</p>
<p dir="auto">Does anyone know if there is an equivalent to Pyboard's pyb.USB_VCP() function; specifically the <a href="http://docs.micropython.org/en/v1.9.3/pyboard/library/pyb.USB_VCP.html#pyb.USB_VCP.any" target="_blank" rel="noopener noreferrer nofollow">vcp.any</a> function?  This returns True when a USB connection is detected.<br />
Lobo's micropython port has the  <a href="https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/machine#machinestdin_getlen-timeout" target="_blank" rel="noopener noreferrer nofollow">machine.stdin_get() function</a> which passes in a timeout parameter, making it non-blocking. This does not detect the USB but does allow a check if a char is entered within a time period, before continuing on with the script.</p>
]]></description><link>https://forum.pycom.io/post/23413</link><guid isPermaLink="true">https://forum.pycom.io/post/23413</guid><dc:creator><![CDATA[philwilkinson]]></dc:creator><pubDate>Sat, 10 Nov 2018 07:44:39 GMT</pubDate></item><item><title><![CDATA[Reply to equivalent to pyb.USB_VCP() or lobo&#x27;s machine.stdin_get() on Sat, 10 Nov 2018 13:36:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1904">@philwilkinson</a> Pycom device uses an UART and not a USB peripheral for the REPL, like the Pyboard. However, what you can do is to use uart.any() to tell, whether there is a character from the UART REPL interface waiting:</p>
<pre><code>from machine import UART
uart=UART(0, 115200)

if uart.any():
  ....
</code></pre>
<p dir="auto">That will not detect the cable, but the first character sent.<br />
That will however not detect characters from a telnet session.<br />
You can also connect one of the modem control signals of the USB/UART bridge to a GPIO pin.</p>
]]></description><link>https://forum.pycom.io/post/23415</link><guid isPermaLink="true">https://forum.pycom.io/post/23415</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Sat, 10 Nov 2018 13:36:58 GMT</pubDate></item><item><title><![CDATA[Reply to equivalent to pyb.USB_VCP() or lobo&#x27;s machine.stdin_get() on Mon, 12 Nov 2018 04:41:56 GMT]]></title><description><![CDATA[<p dir="auto">What about detecting a microUSB cable only charging LoPy + Expansion Board ?<br />
It would be useful because only measuring the voltage of battery doesn't mean the battery is being discharging or charging (at least in the beginning of the discharging process).</p>
]]></description><link>https://forum.pycom.io/post/23432</link><guid isPermaLink="true">https://forum.pycom.io/post/23432</guid><dc:creator><![CDATA[rcolistete]]></dc:creator><pubDate>Mon, 12 Nov 2018 04:41:56 GMT</pubDate></item><item><title><![CDATA[Reply to equivalent to pyb.USB_VCP() or lobo&#x27;s machine.stdin_get() on Mon, 12 Nov 2018 07:01:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/234">@rcolistete</a> You can always connect Vin via a voltage divider to a GPIO Pin.</p>
]]></description><link>https://forum.pycom.io/post/23434</link><guid isPermaLink="true">https://forum.pycom.io/post/23434</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Mon, 12 Nov 2018 07:01:45 GMT</pubDate></item></channel></rss>