<?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[Detecting USB Power in code on T-Display-S3]]></title><description><![CDATA[<p dir="auto">I am building firmware for the T-Display-S3 which needs to behave differently when connected to mains power (via USB) versus when on battery.  I have not yet found an API or method that I can use to distinguish between the two.<br />
My objective is to conserve power when the device is unplugged.<br />
To be clear, the hardware has built-in behavior which turns off the display when it's unplugged unless GPIO 15 has been asserted, but  this doesn't save enough power and I don't know how I can tell when this has happened.  What I'd like to do is to put the device into light sleep mode when it's unplugged.  Light sleep works fine, but I can't tell when the device has been unplugged.<br />
Any thoughts on detecting the unplug event?</p>
]]></description><link>https://www.community.lilygo.cc/topic/939/detecting-usb-power-in-code-on-t-display-s3</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 17:32:04 GMT</lastBuildDate><atom:link href="https://www.community.lilygo.cc/topic/939.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 10 Apr 2024 23:42:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Detecting USB Power in code on T-Display-S3 on Fri, 12 Apr 2024 01:06:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://www.community.lilygo.cc/uid/2154">@hpro</a> This only a community site, with mostly me.<br />
You could try their GitHub repository and raise an issue:<br />
<a href="https://github.com/Xinyuan-LilyGO/T-Display-S3/issues" rel="nofollow ugc">https://github.com/Xinyuan-LilyGO/T-Display-S3/issues</a><br />
Lithium batteries do not lose voltage as they are used up, They all of a sudden die!<br />
My suggestion was to calibrate the voltage at USB conditions and anything less than that, accounting for ADC drift would indicate that it was on battery only, no USB.<br />
-Terry</p>
]]></description><link>https://www.community.lilygo.cc/post/1653</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1653</guid><dc:creator><![CDATA[teastain2]]></dc:creator><pubDate>Fri, 12 Apr 2024 01:06:21 GMT</pubDate></item><item><title><![CDATA[Reply to Detecting USB Power in code on T-Display-S3 on Thu, 11 Apr 2024 22:58:13 GMT]]></title><description><![CDATA[<p dir="auto">It would be great to get a definitive response from the LilyGo team because the work-around could be a bit painful.</p>
<p dir="auto">My thought is that if USB power cannot be determined directly, perhaps it can be inferred from some period of declining voltage.</p>
<p dir="auto">Any other ideas?</p>
]]></description><link>https://www.community.lilygo.cc/post/1652</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1652</guid><dc:creator><![CDATA[hpro]]></dc:creator><pubDate>Thu, 11 Apr 2024 22:58:13 GMT</pubDate></item><item><title><![CDATA[Reply to Detecting USB Power in code on T-Display-S3 on Thu, 11 Apr 2024 05:07:28 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, Terry.  I had much the same thought.</p>
<p dir="auto">Using the method from the GetBatteryVoltage sketch I saw an overlap between the power measured without a battery and that when a small lipo was connected, so voltage doesn't seem to be a very good discriminator.</p>
<p dir="auto">Interestingly the battery connected (and fully charged) voltage was up to 4808mv, higher than the no battery voltage of 4768-4778mv.<br />
Any such voltage is a disaster if applied to a single cell lipo.  Maybe it'll burst out the back of the case ...</p>
<p dir="auto">Henry</p>
]]></description><link>https://www.community.lilygo.cc/post/1651</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1651</guid><dc:creator><![CDATA[hpro]]></dc:creator><pubDate>Thu, 11 Apr 2024 05:07:28 GMT</pubDate></item><item><title><![CDATA[Reply to Detecting USB Power in code on T-Display-S3 on Thu, 11 Apr 2024 03:26:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://www.community.lilygo.cc/uid/2154">@hpro</a> You could...use the ESP ADC function on pin GPIO4 to read the Battery Voltage.<br />
in my experience it shows~ 5V on USB and some lower values on Battery.<br />
The ESP has a terrible built in ADC that is not calibrated, stable or linear...but it's free.<br />
-Terry</p>
]]></description><link>https://www.community.lilygo.cc/post/1650</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1650</guid><dc:creator><![CDATA[teastain2]]></dc:creator><pubDate>Thu, 11 Apr 2024 03:26:04 GMT</pubDate></item></channel></rss>