Welcome to MattzoBricks › Forums › MattzoTrainController for Bluetooth (MTC4BT) › seeed Studio XIAO ESP32S3: detektion for PU didn’t work
- This topic has 21 replies, 3 voices, and was last updated 1 week, 2 days ago by
Matthias Runte.
-
AuthorPosts
-
-
March 15, 2026 at 14:08 #8929
Stefan Piltz
ParticipantHello,
First of all, thank you so much for this great project!
I’m currently encountering the following problem with the MTC4BT.
For the MTC4BT, I’m using the Seeed Studio XIAO ESP32S3 with Mattzobricks 1.2.2.
The Discovering mode only works for SBrick and Buwizz2 but it didn’t find Lego PU, neither the hub nor the remote control.
What could be the problem? Another Seeed Studio XIAO ESP32S3 also doesn’t recognize the PU hub.
Compilation worked without any problems. I’m using a MacBook Air with an M.2 processor and macOS 26.3.1. -
March 16, 2026 at 07:36 #8930
Matthias Runte
KeymasterCan you post the content of your data directory? This should contain a controller_config.json and network.json file, and potentially other loco and remote files.
-
March 16, 2026 at 18:50 #8931
Stefan Piltz
ParticipantFolder Name: data/MTC4BT1
Content:
– controller_config.json
– network.json
– loco_BR81_001_PU.json
– loco_BR81_001_SBrick.jsonnetwork.json:
{ "logging": { "min_level": "debug", "serial": { "enabled": true }, "syslog": { "enabled": false, "server": "192.168.0.66", "port": 514, "appname": "MTC4BT1" } }, "network" : { "hostname": "mtc4bt", "otaPassword": "xxxxxx", "type" : "wireless" }, "wifi": { "SSID": "Vodafone-1D5C", "password": "ThatsMySecret", "wait": 500 }, "mqtt": { "broker": "192.168.0.66", "port": 1883, "keepalive": 10, "ping": 0 } }controller_config.json:
{ "name": "MTC4BT1", "pwrIncStep": 10, "pwrDecStep": 10, "espPins": [ { "pin": 21, "attachedDevice": "status" } ], "locos": [], "locoConfigs": [ "/loco_BR81_001_SBrick.json" ] }loco_BR81_001_PU.json
{ "locos": [ { "address": 3, "name": "BR81-001", "pwrIncStep": 10, "pwrDecStep": 10, "bleHubs": [ { "type": "PU", "address": "A8:E2:C1:99:52:F0", "channels": [ { "channel": "LED" }, { "channel": "B", "attachedDevice": "motor", "direction": "forward" } ] } ], "events": [ { "triggers": [ { "source": "loco", "eventType": "dirchanged", "value": "forward" } ], "actions": [ { "address": "A8:E2:C1:99:52:F0", "channel": "LED", "color": "white" } ] }, { "triggers": [ { "source": "loco", "eventType": "dirchanged", "value": "backward" } ], "actions": [ { "address": "A8:E2:C1:99:52:F0", "channel": "LED", "color": "red" } ] }, { "triggers": [ { "source": "loco", "eventType": "dirchanged", "value": "stopped" } ], "actions": [ { "address": "A8:E2:C1:99:52:F0", "channel": "LED", "color": "blue" } ] } ] } ] }my_platformio_ini:
[platformio] default_envs = seeed_xiao_esp32-s3 ; This controller must be configured through config files in the folder you define below. ; Configure your network in the <code>network_config.json</code> file. ; Configure the controller in the <code>controller_config.json</code> file. ; See the <code>/data_example</code> folder for example configuration files. ; Run <code>platformio.exe run --target uploadfs</code> to upload the data-folder content to the ESP32. ; moved to my_platformio.ini ; for Linux you have to add a / before $PROJECT_DIR data_dir = /$PROJECT_DIR/data/MTC4BT1Comment: for searching I have make an empty structure for locos and locoConfigs.
Currently I’m working with the Brick, which working well. And I know, that the MAC Adress for the PU is wrong because of not finding PU Hubs. -
March 17, 2026 at 13:21 #8933
Hilbert B
KeymasterPlease look at the serial output when you have the following controller_config.json
{ "name": "MTC4BT", "espPins": [ { "pin": 2, "inverted": false, "attachedDevice": "status" } ], "locos": [ ] }It should post all BLE devices including the your PU device.
I think lego PU devices should start with 90:84 a PU remote starts with either e4 or fc (from what I have seen).
With this configuration it will endless scan for devices. The best way is to start you esp, look at the serial output and then switch on you PU device and see what mac address shows up.
Hilbert
-
March 17, 2026 at 22:58 #8937
Stefan Piltz
ParticipantThanks, I tried again with the exact controller_config.json file you are shown up.
With this config file, The controller finds many BLE devices, including SBrick and Buwizz2, but still not the PU Hub.Here are an extract of the Terminal output:
[0405] [0] [INFO] BLE : Discovered unknown device: SBrick (88:6b:0f:43:ab:37).
[0406] [0] [INFO] BLE : Discovered unknown device: (48:e4:59:70:f1:fb).
[0407] [0] [INFO] BLE : Discovered unknown device: (fa:47:29:13:7c:1d).
[0408] [0] [INFO] BLE : Discovered unknown device: (5a:7b:6c:ad:e0:9a).
[0409] [1] [INFO] Try mqtt reconnect…
[0410] [1] [WARN] MQTT: Subscriber connect failed, rc=-2. Try again in a few seconds…
[0411] [0] [INFO] BLE : Discovered unknown device: (f1:f0:13:1e:b2:69).
[0412] [0] [INFO] BLE : Discovered unknown device: (71:44:31:0c:46:63).
[0413] [0] [INFO] BLE : Discovered unknown device: (dc:ce:e7:47:17:0e).
[0414] [0] [INFO] BLE : Scanning for 0 hub(s) aborted.
[0415] [0] [INFO] BLE : Scanning for 0 hub(s)…
[0416] [0] [INFO] BLE : Discovered unknown device: SBrick (88:6b:0f:43:ab:37).
[0417] [0] [INFO] BLE : Discovered unknown device: (9c:9a:c0:18:da:fe).
[0418] [0] [INFO] BLE : Discovered unknown device: SBrick (88:6b:0f:43:ad:37).
[0419] [0] [INFO] BLE : Discovered unknown device: (76:ac:e5:2e:cd:39).
[0420] [0] [INFO] BLE : Discovered unknown device: (67:ce:52:5a:ab:72).
[0421] [0] [INFO] BLE : Discovered unknown device: BuWizz2 (50:fa:ab:ea:26:84).
[0422] [0] [INFO] BLE : Discovered unknown device: (5e:51:14:d5:9c:c9).
[0423] [0] [INFO] BLE : Discovered unknown device: (f1:f0:13:1e:b2:69).
[0424] [0] [INFO] BLE : Discovered unknown device: (71:44:31:0c:46:63).
[0425] [0] [INFO] BLE : Discovered unknown device: (48:23:70:4e:b8:e7).
[0426] [1] [INFO] Try mqtt reconnect…
[0427] [1] [WARN] MQTT: Subscriber connect failed, rc=-2. Try again in a few seconds…
[0428] [0] [INFO] BLE : Discovered unknown device: (5a:7b:6c:ad:e0:9a).
[0429] [0] [INFO] BLE : Discovered unknown device: (48:e4:59:70:f1:fb).
[0430] [0] [INFO] BLE : Discovered unknown device: (cc:3e:7a:02:24:67).
[0431] [0] [INFO] BLE : Scanning for 0 hub(s) aborted.
[0432] [0] [INFO] BLE : Scanning for 0 hub(s)…
[0433] [0] [INFO] BLE : Discovered unknown device: SBrick (88:6b:0f:43:ab:37).
[0434] [0] [INFO] BLE : Discovered unknown device: (76:ac:e5:2e:cd:39).
[0435] [0] [INFO] BLE : Discovered unknown device: (67:ce:52:5a:ab:72).
[0436] [0] [INFO] BLE : Discovered unknown device: SBrick (88:6b:0f:43:ad:37).
[0437] [0] [INFO] BLE : Discovered unknown device: BuWizz2 (50:fa:ab:ea:26:84). -
March 18, 2026 at 08:17 #8938
Matthias Runte
KeymasterI agree with Hilbert, my PU hubs all start with 90:84:2b.
It’s weird that the PU hubs don’t show up.
Can you please try to use small letters in the MAC address, so
“address”: “a8:e2:c1:99:52:f0”,
instead of
“address”: “A8:E2:C1:99:52:F0”.
I remember we wanted to fix that, but I am not sure if Hilbert already had done it when we compiled firmware V1.2.2.
You can also try to connect the hubs to the LEGO PU app on your phone, which triggers a firmware update. This also helped me one time.
-
March 18, 2026 at 08:21 #8939
Matthias Runte
KeymasterJust checked, large characters in MAC addresses should be okay.
https://github.com/Mattzobricks/MattzoControllers/issues/112But you can try anyway. Please report if that did the trick, then we’d need to review it.
-
March 18, 2026 at 10:15 #8940
Hilbert B
KeymasterJust a brain fart: does the lego app report the mac address?
And maybe just as important, there are no PU remotes on and paired to that hub? If that is the case it also wont show up.
The LED of the hub should flash white, any other colour is wrong (during the pairing stage)
-
This reply was modified 2 weeks, 5 days ago by
Hilbert B.
-
March 19, 2026 at 21:08 #8956
Stefan Piltz
ParticipantYes correct, the LED on the Hubs is flashing white during the pairing process. But the controller do not create a connection to the Hub.
-
This reply was modified 2 weeks, 5 days ago by
-
March 18, 2026 at 11:55 #8942
Matthias Runte
KeymasterYes, the LEGO app shows the MAC address indeed.
Good point with the pairing of hub/remote.
Stefan, when you try it, apply the possible solutions one by one, and let us know what the actual problem was, please. This helps to grow our knowledge base.
-
March 18, 2026 at 21:03 #8948
Matthias Runte
KeymasterNote: I Aadded the hints to the documentation on https://mattzobricks.com/automation/train-automation/mtc4bt.
-
March 18, 2026 at 22:31 #8949
Stefan Piltz
ParticipantFirst of all, thank you so much for your active support in solving this problem. Unfortunately, during the week I only have some time to dedicate to this issue late in the evening.
I updated the firmware of the Lego Hub using the PowerUp app. This changed the name from “Hub No. 4” to SmartHub.
I couldn’t retrieve the MAC address using the LEGO app; it only shows the hub name: SmartHub also a BLEScanner on a iPhone shows only the UUID not the MAC address.
I obtained the MAC addresses of my 3 LEGO PU Hubs using a BLEScanner on a Windows PC with the Python Bleak library, since the Mac only outputs the UUID, also with the Python Bleak library.
Interestingly, the MAC address of one PowerUp Hub starts with 9c:9a:c0.
BLE Scanner Liste (from windows PC):
88:6B:0F:43:AD:37: SBrick
9C:9A:C0:18:DA:FE: Smart Hub
90:84:2B:CA:E6:A8: HUB NO.4
90:84:2B:15:93:D6: HUB NO.4
50:FA:AB:EA:26:84: BuWizz2
88:6B:0F:43:AB:37: SBrickI’ve adjusted the controller_config.json file accordingly, entering the MAC address in lowercase.
The XIAO still can’t find the LEGO PU Hubs.Next, I’ll try the BLEScanner from the Arduino IDE on the XIAO and hope that it then displays the LEGO PU Hubs.
I’ll write as soon as I’ve taken the next step.
-
March 18, 2026 at 23:02 #8950
Stefan Piltz
ParticipantI was able to get the BLEScanner example from the Arduino IDE onto the XIAO faster than I expected. Using the example program included in the Arduino IDE, the controller finds the LEGO PU Hubs.
Here is the terminal output for 1 scan:
Advertised Device: Name: , Address: 54:95:4d:12:af:ca, manufacturer data: 4c000c0e083f5d9e721d22df8c8e2e54b24410064a1d34fbff18, rssi: -68
Advertised Device: Name: HUB NO.4, Address: 90:84:2b:ca:e6:a8, manufacturer data: 9703004107004300, serviceUUID: 00001623-1212-efde-1623-785feabcd123, txPower: 0, rssi: -65
Advertised Device: Name: Smart Hub, Address: 9c:9a:c0:18:da:fe, manufacturer data: 9703004107004300, serviceUUID: 00001623-1212-efde-1623-785feabcd123, txPower: 0, rssi: -65
Advertised Device: Name: , Address: 7e:d1:6a:fb:85:ab, manufacturer data: 4c0010063c1ecdc0c704, txPower: 8, rssi: -64
Advertised Device: Name: , Address: f3:02:2c:a5:a9:e9, manufacturer data: 4c0012020000, rssi: -54
Advertised Device: Name: , Address: 52:b3:42:d9:83:87, manufacturer data: 4c000c0e083f5d9e721d22df8c8e2e54b24410064a1d34fbff18, rssi: -69
Advertised Device: Name: , Address: 65:ae:cd:ba:7b:b6, manufacturer data: 4c000711087bf93da29ee3dddaefdf7d9c0e5bd955, rssi: -97
Advertised Device: Name: Smart Hub, Address: 90:84:2b:15:93:d6, manufacturer data: 9703004107004300, serviceUUID: 00001623-1212-efde-1623-785feabcd123, txPower: 0, rssi: -64
Advertised Device: Name: , Address: cf:04:d6:8d:a5:54, manufacturer data: 4c0012020002, rssi: -39
Advertised Device: Name: , Address: 45:98:5c:0d:4f:5b, manufacturer data: 4c0010077f1f4ad420f068, txPower: 12, rssi: -92
Advertised Device: Name: , Address: 5d:1f:93:9a:8e:74, manufacturer data: 4c0009081388c0a800421b58160800b66e8d0afda6e5, rssi: -46
Advertised Device: Name: , Address: d8:2c:32:63:91:e1, manufacturer data: 4c0012020003, rssi: -87
Advertised Device: Name: , Address: f9:0c:9e:5d:25:a7, manufacturer data: 4c0012020002, rssi: -47
Advertised Device: Name: , Address: 40:79:12:78:90:23, manufacturer data: 4c00021574278bdab64445208f0c720eaf059935000097adc5, rssi: -103
Advertised Device: Name: , Address: 43:a0:1a:9c:d7:48, manufacturer data: 01060106fc036af7ab, serviceUUID: 0000febe-0000-1000-8000-00805f9b34fb, rssi: -96
Devices found: 15
Scan done!Therefore, I would say that the controller and the LEGO PU hubs are okay.
Perhaps it’s due to the PlatformIO version?
I’m currently using the following versions in VS Code:
– Espressif 32 Version: 6.13.0
– PlatformIO Core: 6.1.19
– PlatformIO Home: 3.4.4I’m going to compile a BLEScanner using VSCode + Platformio and see if the LEGO Hubs are still recognized.
-
March 19, 2026 at 08:17 #8951
Matthias Runte
KeymasterThanks for your feedback. I will add the start of the MAC address of your PU hub to the documentation. Do you remember when you bought it?
-
March 19, 2026 at 10:28 #8954
Stefan Piltz
ParticipantI bought the LEGO hubs last year between July and October 2025. One set was released in 2018 and the other two in 2022.
I’ll take a look today to see what the manufacturing date of the hub is (hoping I can find a timestamp when LEGO Hub). -
March 19, 2026 at 21:04 #8955
Stefan Piltz
ParticipantI’ve just made some progress.
I removed the comment characters from the following lines in the file BLEHubScanner.cpp…// _scanner->setActiveScan(true); // Set active scanning, this will get more data from the advertiser.
// _scanner->setInterval(97); // How often the scan occurs / switches channels; in milliseconds.
// _scanner->setWindow(37); // How long to scan during the interval; in milliseconds.
// _scanner->setMaxResults(20); // The number of results to limit storage to (0 = do not store the scan results, use callback only).All 3 LEGO Hubs will be found on my system now.
So, the BLEScanner of the MTC4BT is now working for me.
However, the controller still won’t connect to the LEGO Hub even when I upload a valid configuration with lowercase letters in the MAC address. -
March 20, 2026 at 08:45 #8957
Hilbert B
KeymasterHi Stefan,
Thank you so much for this feedback, I hope that I am asking not too much, but if you set
_scanner->setMaxResults(20);
to
_scanner->setMaxResults(0);Does that also make the hub show up? If so we/I should make that change if the MTC4BT is in scan only mode.
The rest should work.
There is an other experimental branch on github, that uses the newer nimble library and is based on white list, could you give that one a go? My thoughts behind this is that you live in a ble rich environment that overwhelms the ESP, that brach uses a white list, so it only allows these devices to make a connection.
It works with the current configuration, so no changes there.
If you have cloned the git repo, you can easily switch branch and upload that version to the ESP, ONLY if it is not too much work for you!
Hilbert
-
March 20, 2026 at 22:17 #8958
Stefan Piltz
ParticipantHi Hilbert,
Unfortunately, the hubs aren’t showing up for me with
_scanner->setMaxResults(0);I also pulled the experimental branch via Git and tried it briefly. All 3 hubs were detected. I’ll test it more thoroughly this weekend, though, as I also had a test run where the connection didn’t work fine.
Stefan
-
March 27, 2026 at 21:06 #8971
Stefan Piltz
ParticipantHi Hilbert,
the new nimBLE Lib Version works fine for me. With up to 5 BLE Hubs (2xSBrick 3xPU)
I tried this version with the following changed line:
_scanner->setActiveScan(true); // Set active scanning, this will get more data from the advertiser.
_scanner->setInterval(97); // How often the scan occurs / switches channels; in milliseconds.
_scanner->setWindow(37); // How long to scan during the interval; in milliseconds.
_scanner->setMaxResults(20); // The number of results to limit storage to (0 = do not store the scan results, use callback only).With this I in more then 50% of test runs ERRORS occur with reason 520 or reason 534 or Characteristics not writable. But at the end all hubs were connected.
I also make a test run with only this line activated:
_scanner->setActiveScan(true); // Set active scanning, this will get more data from theThe PU Hub names are also showing up and the connection works fine so far.
So I will give the newer nimBLE lib a go for my configuration.Thanks for helping!
Stefan-
March 28, 2026 at 14:18 #8973
Matthias Runte
KeymasterThanks for the update, Stefan.
-
-
-
March 21, 2026 at 15:12 #8960
Stefan Piltz
ParticipantAbout Hub and different start of the MAC address I checked the manufacturing date of the PCB.
The hub with 9C:9A:C0:18:DA:FE has a manufacturing date of Week: 13 and Year 2025.
So it seems that the newer hubs now have 9C: at the beginning.
My 3 Hubs a from the train Sets:
– 60197 Passenger Train
– 60337 Passenger Express Train-
March 28, 2026 at 14:19 #8974
Matthias Runte
KeymasterThanks. Can anybody else confirm this finding?
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.
