<?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[Arduino code for PaHuB2 + any I2C sensor]]></title><description><![CDATA[<p dir="auto">Dear all,</p>
<p dir="auto">I looking for the sample code reading the values from the I2C module (like ENV III) that is connected to the PaHUB2 socket 0 (PaHUB2 has I2C address 0x71).</p>
<p dir="auto">Thank you.</p>
]]></description><link>https://community.m5stack.com/topic/5997/arduino-code-for-pahub2-any-i2c-sensor</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 21:00:30 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5997.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 Jan 2024 18:16:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Arduino code for PaHuB2 + any I2C sensor on Thu, 07 Mar 2024 15:01:48 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> In Arduino you can uise the PCA9548 library .<br />
Example : <a href="https://randomnerdtutorials.com/tca9548a-i2c-multiplexer-esp32-esp8266-arduino/" target="_blank" rel="noopener noreferrer nofollow ugc">https://randomnerdtutorials.com/tca9548a-i2c-multiplexer-esp32-esp8266-arduino/</a></p>
]]></description><link>https://community.m5stack.com/post/24285</link><guid isPermaLink="true">https://community.m5stack.com/post/24285</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Thu, 07 Mar 2024 15:01:48 GMT</pubDate></item><item><title><![CDATA[Reply to Arduino code for PaHuB2 + any I2C sensor on Sun, 21 Jan 2024 02:10:18 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></p>
<p dir="auto">Thank you so much for the help.<br />
It works perfectly...</p>
]]></description><link>https://community.m5stack.com/post/23419</link><guid isPermaLink="true">https://community.m5stack.com/post/23419</guid><dc:creator><![CDATA[EKTan]]></dc:creator><pubDate>Sun, 21 Jan 2024 02:10:18 GMT</pubDate></item><item><title><![CDATA[Reply to Arduino code for PaHuB2 + any I2C sensor on Sat, 20 Jan 2024 19:33:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ektan" aria-label="Profile: ektan">@<bdi>ektan</bdi></a> Sorry, this took me all day to write and de-bug.<br />
It is an ENVIII on position 0 and ENVII on position 1, as that is what I have!</p>
<pre><code>#include &lt;M5Stack.h&gt;  //use any controller by substituting the library
#include "M5_ENV.h"
SHT3X sht30;  // creates ONE instance!!!
float tmp1 = 12.3;
float hum1 = 0.0;
float tmp2 = 12.3;
float hum2 = 0.0;

void setup() {
  M5.begin();
  M5.Power.begin();
  delay(100);
  Wire.begin();
  sht30.init();
  Wire.beginTransmission(0x70);  //(the PaHub)
  Wire.write(0x00);              //turns off all ports
  Wire.endTransmission();        // as it says!
  M5.Lcd.setTextSize(3);         //or lower for StickC
  M5.Lcd.setTextColor(RED);
  M5.Lcd.print("Setup  ");
  delay(1000);
}
void loop() {
  Wire.beginTransmission(0x70);  //(the PaHub)
  Wire.write(0x01);              //turns on port 0, ENV1
  Wire.endTransmission();
  if (sht30.get() == 0) {   // Obtain the data of shT30.  
    tmp1 = sht30.cTemp;     // Store the temperature obtained from shT30.
    hum1 = sht30.humidity;  // Store the humidity obtained from the SHT30.
             } else {
    tmp1 = 0, hum1 = 0;
  }
  delay(100);
  Wire.beginTransmission(0x70);  //(the PaHub)
  Wire.write(0x02);              //reads the ENV at port 1
  Wire.endTransmission();
  if (sht30.get() == 0) {   // Obtain the data of shT30. 
    tmp2 = sht30.cTemp;     // Store the temperature obtained from shT30.
    hum2 = sht30.humidity;  // Store the humidity obtained from the SHT30.
    } else {
    tmp2 = 0, hum2 = 0;
  }
  delay(100);
  M5.Lcd.fillRect(0, 0, 320, 80, BLACK);
  M5.Lcd.setCursor(5, 5);
  M5.Lcd.print("Temp1=  ");
  M5.Lcd.setCursor(130, 5);
  M5.Lcd.print(tmp1, 1);  //one decimal place
  M5.Lcd.setCursor(5, 50);
  M5.Lcd.print("Temp2=  ");
  M5.Lcd.setCursor(130, 50);
  M5.Lcd.print(tmp2, 1);  //one decimal place
  delay(1000);
}
</code></pre>
<p dir="auto">There is no PaHub library because the Wire C-code is in-line with the Arduino code.<br />
This is actually easier to understand and illustrates how the PaHub works.<br />
-Terry</p>
]]></description><link>https://community.m5stack.com/post/23418</link><guid isPermaLink="true">https://community.m5stack.com/post/23418</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Sat, 20 Jan 2024 19:33:35 GMT</pubDate></item><item><title><![CDATA[Reply to Arduino code for PaHuB2 + any I2C sensor on Sat, 20 Jan 2024 17:40:36 GMT]]></title><description><![CDATA[<p dir="auto">Dear all,<br />
I'm looking for the sample Arduino code to read the ENV III module that is connected to the PaHUB2 socket 0 (PaHUB2 has an I2C address 0x71).</p>
<p dir="auto">Thank you.</p>
]]></description><link>https://community.m5stack.com/post/23416</link><guid isPermaLink="true">https://community.m5stack.com/post/23416</guid><dc:creator><![CDATA[EKTan]]></dc:creator><pubDate>Sat, 20 Jan 2024 17:40:36 GMT</pubDate></item></channel></rss>