<?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[RAW I2C Access help with SHT30 (ENVIII) please.]]></title><description><![CDATA[<p dir="auto">Hello most senior members of the forum, I beg for you to help me with an I2C communication using the SHT30 temperature and humidity sensor.</p>
<p dir="auto"><img src="/assets/uploads/files/1675504112147-bowing-asian-business-person-260nw-1249507468.jpg" alt="0_1675504110806_bowing-asian-business-person-260nw-1249507468.jpg" class=" img-fluid img-markdown" /><br />
I'm trying to write a tutorial on I2C communications but struggling with the SHT30. So far I am using the following functions to test :</p>
<pre><code>from umachine import Pin, I2C,
import utime
i2c=I2C(0,scl=Pin(0), sda=Pin(1), freq=400000)
i2c.scan()# looks for the address 68 (0x44) Primary and 69 (0x45) secondary. and 112 (0x70)
[hex(x) for x in i2c.scan()]
i2c.writeto(0x44, b'\x2C\x06') # High repeatability with clock stretching.
utime.sleep(1)


result = bytearray(2)
i2c.readfrom_into(0x44, result)
result #= 0x87 aka 135
# 0xFFFF = 65535
# 0xFFF = 4095
def temp_c(data):
    # t_celsius = (((data[0] &lt;&lt; 8 |  data[1]) * 175) / 0xFFFF) - 45 + self.delta_temp;
    value = data[0] &lt;&lt; 8 | data[1]
    temp = (value &amp; 0xFFF) / 16.0
    if value &amp; 0x1000:
            temp -= 256.0
    return temp
    
temp_c(result)
</code></pre>
<p dir="auto">But I'm getting bad results from the sensor. I have a feeling it could be to do with the conversion formula but maths is not my strong point. can someone please help me?</p>
]]></description><link>https://community.m5stack.com/topic/5029/raw-i2c-access-help-with-sht30-enviii-please</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 06:50:31 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5029.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Feb 2023 09:48:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to RAW I2C Access help with SHT30 (ENVIII) please. on Thu, 09 Feb 2023 06:14:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a> I have had a few issues with the SHT30 sensor.<br />
For a start, Hardware I2C is broken in micropython but SoftI2C works fine.<br />
On a core2 I had to use the PaHub to get the SHT30 to read.</p>
<p dir="auto">I have solved my initial problem in that it was the conversion formula I had wrong.</p>
]]></description><link>https://community.m5stack.com/post/20053</link><guid isPermaLink="true">https://community.m5stack.com/post/20053</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Thu, 09 Feb 2023 06:14:22 GMT</pubDate></item><item><title><![CDATA[Reply to RAW I2C Access help with SHT30 (ENVIII) please. on Thu, 09 Feb 2023 00:45:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ajb2k3" aria-label="Profile: ajb2k3">@<bdi>ajb2k3</bdi></a> Hi Adam, just an "aside" from a lurker...I could not get the M5Stack ENV to work with C3, using their library. It seems the "get" command in the library may be deprecated or Espressif did not bring it forward for risc-v.<br />
So, I moved the i2c logic into my main loop:<br />
(This is Arduino C, but looks very similar to the Python version!!!)</p>
<p dir="auto">Wire.beginTransmission(0x44);  //0x44 for M5Stack ENV  (0x45 is DFRobot)<br />
Wire.write(0x2C);               //show all the "wheels and gears"<br />
Wire.write(0x06);<br />
Wire.endTransmission();<br />
delay(50);<br />
Wire.requestFrom(0x44, 2);<br />
data[0] = Wire.read();<br />
data[1] = Wire.read();<br />
delay(50);<br />
cTemp = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45;<br />
Serial.println(cTemp);<br />
delay(1000);</p>
<p dir="auto">Cheers, Terry</p>
]]></description><link>https://community.m5stack.com/post/20049</link><guid isPermaLink="true">https://community.m5stack.com/post/20049</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Thu, 09 Feb 2023 00:45:25 GMT</pubDate></item><item><title><![CDATA[Reply to RAW I2C Access help with SHT30 (ENVIII) please. on Wed, 08 Feb 2023 09:44:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/crami25" aria-label="Profile: crami25">@<bdi>crami25</bdi></a> Normally yes but, the M5Stamp C3 and C3U are not supported buy UIFlow hence why I’m using mainstream MP</p>
]]></description><link>https://community.m5stack.com/post/20044</link><guid isPermaLink="true">https://community.m5stack.com/post/20044</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Wed, 08 Feb 2023 09:44:24 GMT</pubDate></item><item><title><![CDATA[Reply to RAW I2C Access help with SHT30 (ENVIII) please. on Wed, 08 Feb 2023 00:09:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ajb2k3" aria-label="Profile: ajb2k3">@<bdi>ajb2k3</bdi></a><br />
You can do everything in UIFlow !!<br />
The first part of the sketch uses the M5Stack ENVII library and displays the values on a M5Stack core..<br />
The second part uses pure I2C commands setting the SHT30 registers (0x2c,0x06) and then reads the 6 Raw data bytes into  the "Result" list (temperature MSB, temperature  LSB,  temperature CRC, humidity MSB, humidity LSB, humidity CRC).<br />
The the MSB and LSB temperature data are then converted to degrees Celsius accorfung to the SHT data sheet.</p>
<p dir="auto"><img src="/assets/uploads/files/1675813791128-bfccd30f-3df4-4205-998d-f79680b18da5-image-resized.png" alt="0_1675813790190_bfccd30f-3df4-4205-998d-f79680b18da5-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The corresponding Python Code looks like this:</p>
<p dir="auto"><img src="/assets/uploads/files/1675813970507-38b070f0-918c-4472-98eb-c6ca67041d29-image-resized.png" alt="0_1675813969356_38b070f0-918c-4472-98eb-c6ca67041d29-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/20042</link><guid isPermaLink="true">https://community.m5stack.com/post/20042</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Wed, 08 Feb 2023 00:09:44 GMT</pubDate></item></channel></rss>