PaHub Access cracked.
Yes, I am finially able to access 1 of the channels on the PaHub!
from m5ui import * from uiflow import * import i2c_bus import unit setScreenColor(0x222222) tof1 = unit.get(unit.TOF, unit.PORTA) label1 = M5TextBox(89, 38, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0) label2 = M5TextBox(69, 116, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0) i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x70) while True: i2c0.write_u8(0x00, 0x01) label2.setText(str(tof1.distance)) wait_ms(2)
I am using the tof here for this.
Thanks for sharing! Do you also have an example on how to connect multiple sensors to the PaHub and read values from them?
Sorry, haven't had the time to revisit this how ever I think that it should be
tof1 = unit.get(unit.TOF, unit.PORTA) tof2= unit.get(unit.TOF, unit.PORTA) label1 = M5TextBox(89, 38, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0) label2 = M5TextBox(69, 116, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0) i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x70) i2c1 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x71) while True: i2c0.write_u8(0x00, 0x01) label2.setText(str(tof1.distance)) wait_ms(2)
or something like this
lukasmaximus last edited by
Seems your over complicating things a little @ajb2k3 We apologise that there has been very little info on how to connect multiple sensors up to the PaHub, I also was struggling to set up a bunch of sensors before someone on the dev team showed me. But it is as simple as selecting your desired unit in the units tab and selecting pahub from the dropdown list instead of port a.
Then you must select the port of the Pahub you wish to connect to. The port numbers are labelled on the pcb if you look closely.
Then this was the code I wrote for a parking proximity alarm
Hope this helps. If you want me to send the resulting python script I can also send it
ajb2k3 last edited by ajb2k3
@lukasmaximus my code is before the Pahub was added to UIFlow and I haven’t had the time to check out the pahub blocks added yet
Sweet you can now select the hubs ports. I didn’t know that.
@lukasmaximus and @ajb2k3 Thank you very much for your answers!
I am working with Visual Studio Code and UIFlow-v1.3.2. But I use flow.m5stack.com to look up how to connect the sensors. I was confused because PaHub is greyed out there:
Thanks for showing how to select the PaHub, however it does still not work for me. Even with the simplest possible example in UI Flow I get the following error: 'module' object has no attribute 'PAHUB0'
from m5stack import *
from m5ui import *
from uiflow import *
env1 = unit.get(unit.ENV, unit.PAHUB0)
If I connect the same unit to unit.PORTA everything works fine. I would like to be able to connect EARTH, ENV and LIGHT units using the PaHub. Is it possible that not all units are supported yet?
E.g. for the EARTH unit I can not select PaHub using the drop down you showed.
Thanks for your help!
The PaHub will be "Grayed Out if the firmware is not updated and you are using the wrong version of UIFlow.
Also the PaHub does NOT work with the M5Stick.
I will try to make a video on the PaHub this weekend but I'm heckticly busy.
maechler last edited by maechler
@ajb2k3 I am using a regular M5Stack Core. So which version of UIFlow should I be using?
@maechler 1.3.5 beta sorry in and out of the forum
@ajb2k3 Thanks, it does work with 1.3.5 beta!