Can the remote be connected to more than one (technic) hub at the same time? #957
-
At the moment I am building MOC-43636 2020 Volvo Excavator This model implements two technic hubs, with all 8 ports connected. I would like to control the model with ONE Would that be possible (now or in future) with pybricks? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There is the experimental hub-to-hub communication or possibly #802. Nothing in the official release currently. Another possibility is to use an in-between computer to relay info from the remote to the hubs, e.g. with pybricksdev. |
Beta Was this translation helpful? Give feedback.
-
Took one remote for each of the two hubs to have more buttons available. Used the idea of #861 to have one main program that imports the correct for each hub. As example the main program for MOC-43636 2020 Volvo Excavator MOC43636_main.py """
Have split the program because the left hub does not use the code for the right hub and vice versa.
Maybe it helps to ease a bit on memory usage and time needed to load.
Run MOC43636_main.py on both hubs.
For each hub:
(if the hub is OFF, press the green button until the led blinks blue)
press the green center button on the correct remote for this hub
short press the green button on the hub, so the led shows a in and out fading blue led
The color of the remote and the hub will change to a matching color to indicate "connected".
This main program imports (loads and runs) either
MOC43636_lefthub.py
or MOC43636_righthub.py
depending on the hubname
In this case the names of the hubs are supposed to be:
"HubA_left"
"HubB_right"
The hub name can be set during flashing of the firmware to the hub.
This set of programs is tested with
version ('technichub', '3.3.0b2', 'v3.3.0b2 on 2023-03-08')
"""
from pybricks.hubs import TechnicHub
from pybricks.parameters import Color
from pybricks.tools import wait # StopWatch
from pybricks import version
hub = TechnicHub()
hubname = hub.system.name()
print("\tThis hub is '" + hubname + "' at version ", version)
hub = None # release the hub and define again in the separately imported program.
LEFTHUB = "HubA_left"
RIGHTHUB = "HubB_right"
if hubname == LEFTHUB:
import MOC43636_lefthub # noqa
elif hubname == RIGHTHUB:
import MOC43636_righthub # noqa
else:
from pybricks.hubs import ThisHub
hub = ThisHub()
hub.light.animate([Color.RED, Color.NONE], interval=64)
print("this hub '" + hubname + "' is not an expected hub like '" + LEFTHUB + "' or '" + RIGHTHUB + "'")
print("program Done\nWaiting 10 seconds to show the result (if any)")
wait(10000) |
Beta Was this translation helpful? Give feedback.
There is now a new alternate implementation of the hub-to-hub communication in pybricks/pybricks-micropython#158 for testing. There is some example code there that shows how to use the remote to control motors on two different hubs at the same time.