<?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[M5PaperColor: Can&#x27;t read both SHT40 and battery data?]]></title><description><![CDATA[<p dir="auto">Hello, new M5PaperColor user here. While trying to familiarize myself with its functions, I've tried to modify the "PaperColor SHT40 Temperature &amp; Humidity" sketch to also include the battery data, to get an idea of how the frequency of screen refreshes impacts its runtime.</p>
<p dir="auto">But although the M5.Power functions work fine in the "PaperColor Battery" sketch, they just return values of 0 or -1 in this one. When I comment out all the SHT40 code, the battery functions work as expected. But as soon as I uncomment the sht4.begin() statement, the battery functions quit giving useful data again.</p>
<p dir="auto">Is there a way to retrieve valid data from both subsystems, or is there really no way for a sketch that gathers environmental data to also warn the user when the battery is getting low?</p>
]]></description><link>https://community.m5stack.com/topic/8239/m5papercolor-can-t-read-both-sht40-and-battery-data</link><generator>RSS for Node</generator><lastBuildDate>Sat, 30 May 2026 12:06:30 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/8239.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 May 2026 18:26:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5PaperColor: Can&#x27;t read both SHT40 and battery data? on Sat, 30 May 2026 07:56:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/shipbrook" aria-label="Profile: Shipbrook">@<bdi>Shipbrook</bdi></a></p>
<p dir="auto">M5Unified uses Wire<strong>1</strong> for internal I2C and Wire for external I2C.</p>
<p dir="auto">The example for SHT40 incorrectly uses Wire which causes issues as soon as other internal I2C communication is required, e.g. reading battery status.</p>
<p dir="auto">The quick way to fix this is replacing Wire with Wire<strong>1</strong> in below line:</p>
<pre><code>//if(!sht4.begin(&amp;Wire, SHT40_I2C_ADDR_44, SHT_SDA_PIN, SHT_SCL_PIN, 400000U))
if(!sht4.begin(&amp;Wire1, SHT40_I2C_ADDR_44, SHT_SDA_PIN, SHT_SCL_PIN, 400000U))
</code></pre>
<p dir="auto">The better way is to get the actual port used by M5Unified for internal I2C and the use that information:</p>
<pre><code>i2c_port_t PortIn = M5.In_I2C.getPort();
TwoWire * WireIn = (PortIn == 1) ? &amp;Wire1 : &amp;Wire;
if(!sht4.begin(WireIn, SHT40_I2C_ADDR_44, SHT_SDA_PIN, SHT_SCL_PIN, 400000U))
</code></pre>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/31011</link><guid isPermaLink="true">https://community.m5stack.com/post/31011</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Sat, 30 May 2026 07:56:39 GMT</pubDate></item></channel></rss>