<?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[Issues with Pahub - Some I2C units work, others don&#x27;t]]></title><description><![CDATA[<p dir="auto">Hi. I am a newbie. I am having issues getting some, but not all I2C units to work with the pahub. I have a Core S3 (lite) and am using Uiflow 2.0. I want to connect the following units to the hub:  NCIR, Weight I2C, Tof4m and ENVIII via the Pahub. I can get the NCIR weight I2C units to work without any trouble, but I cannot get the Tof4m and ENVIII to work with the hub although they work fine connected directly to the S3.<br />
Here is some example code. I have included the NCIR, weight I2C and the ToF4m. If I delete the Init for the Tof4m and "get target distance" blocks then the program runs fine and displays the output from the NCIR and Weight I2C on the screen as I want it to. Here is the code before I delete the Tof4m related blocks:</p>
<p dir="auto">import os, sys, io<br />
import M5<br />
from M5 import *<br />
from hardware import *<br />
from unit import TOF4MUnit<br />
from unit import NCIRUnit<br />
from unit import PAHUBUnit<br />
from unit import WeightI2CUnit<br />
import time</p>
<p dir="auto">label0 = None<br />
label1 = None<br />
label2 = None<br />
i2c0 = None<br />
pahub_0 = None<br />
ncir_0 = None<br />
weight_i2c_0 = None<br />
tof4m_0 = None</p>
<p dir="auto">def setup():<br />
global label0, label1, label2, i2c0, pahub_0, ncir_0, weight_i2c_0, tof4m_0</p>
<p dir="auto">M5.begin()<br />
Widgets.fillScreen(0x222222)<br />
label0 = Widgets.Label("label0", 2, 30, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)<br />
label1 = Widgets.Label("label1", 1, 62, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)<br />
label2 = Widgets.Label("label2", -2, 88, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)</p>
<p dir="auto">i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)<br />
tof4m_0 = TOF4MUnit(PAHUBUnit(i2c=i2c0, channel=2), 0x29)<br />
pahub_0 = PAHUBUnit(i2c=i2c0, channel=0)<br />
ncir_0 = NCIRUnit(PAHUBUnit(i2c=i2c0, channel=0))<br />
weight_i2c_0 = WeightI2CUnit(PAHUBUnit(i2c=i2c0, channel=1), 0x26)</p>
<p dir="auto">def loop():<br />
global label0, label1, label2, i2c0, pahub_0, ncir_0, weight_i2c_0, tof4m_0<br />
M5.update()<br />
label0.setText(str(ncir_0.get_ambient_temperature()))<br />
label1.setText(str(weight_i2c_0.get_adc_raw))<br />
label1.setText(str(tof4m_0.get_distance))<br />
time.sleep(1)</p>
<p dir="auto">if <strong>name</strong> == '<strong>main</strong>':<br />
try:<br />
setup()<br />
while True:<br />
loop()<br />
except (Exception, KeyboardInterrupt) as e:<br />
try:<br />
from utility import print_error_msg<br />
print_error_msg(e)<br />
except ImportError:<br />
print("please update to latest firmware")</p>
<p dir="auto">With the ToF4m blocks added I get the following error:</p>
<p dir="auto">Traceback (most recent call last):<br />
File "&lt;stdin&gt;", line 39, in &lt;module&gt;<br />
File "&lt;stdin&gt;", line 26, in setup<br />
File "driver/vl53l1x.py", line 60, in <strong>init</strong><br />
File "driver/vl53l1x.py", line 176, in get_model_info<br />
File "driver/vl53l1x.py", line 273, in _read_register<br />
TypeError: unexpected keyword argument 'addrsize'</p>
<p dir="auto">I get a similar one with the ENVIII. I always ensure that the bus is set to PAHUB for the units and the PAHUB numbers match the physical port. Any help would be appreciated as I am getting very frustrated. I have even bought a new hub and tried that, but it didn't help.</p>
]]></description><link>https://community.m5stack.com/topic/6918/issues-with-pahub-some-i2c-units-work-others-don-t</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 03:39:27 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6918.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Oct 2024 10:21:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Issues with Pahub - Some I2C units work, others don&#x27;t on Mon, 21 Oct 2024 15:59:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/bjhsartorius" aria-label="Profile: BJHSartorius">@<bdi>BJHSartorius</bdi></a></p>
<p dir="auto">first of all for your setup there is <strong>no need</strong> for a PaHub as all four I2C units have <strong>different</strong> I2C addresses and therefore all four units can be connected in parallel using <a href="https://docs.m5stack.com/en/unit/hub" target="_blank" rel="noopener noreferrer nofollow ugc">these</a>. You can read about I2C <a href="https://en.wikipedia.org/wiki/I%C2%B2C" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">I2C addresses of your four units: NCIR: <strong>0x5A</strong>; Weight I2C: <strong>0x26</strong>; Tof4m: <strong>0x29</strong>; ENV III: <strong>0x44</strong>/<strong>0x70</strong></p>
<p dir="auto">That said, I don't know why there is an issue when ToF4m is added.</p>
<p dir="auto">However, I do know why there is an issue with PaHub and ENV III. They both share the same I2C address (0x70). In other words PaHub and ENV III can never be used on the same I2C bus unless you manually (soldering required) change the I2C address of the PaHub; see <a href="https://docs.m5stack.com/en/unit/pahub?id=schematic" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/26811</link><guid isPermaLink="true">https://community.m5stack.com/post/26811</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Mon, 21 Oct 2024 15:59:58 GMT</pubDate></item></channel></rss>