Forum Replies Created

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • Stefan PiltzStefan Piltz
    Participant

    Hi 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 the

    The 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

    Stefan PiltzStefan Piltz
    Participant

    About 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

    Stefan PiltzStefan Piltz
    Participant

    Hi 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

    Stefan PiltzStefan Piltz
    Participant

    Yes correct, the LED on the Hubs is flashing white during the pairing process. But the controller do not create a connection to the Hub.

    Stefan PiltzStefan Piltz
    Participant

    I’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.

    Stefan PiltzStefan Piltz
    Participant

    I 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).

    Stefan PiltzStefan Piltz
    Participant

    I 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.4

    I’m going to compile a BLEScanner using VSCode + Platformio and see if the LEGO Hubs are still recognized.

    Stefan PiltzStefan Piltz
    Participant

    First 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: SBrick

    I’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.

    Stefan PiltzStefan Piltz
    Participant

    Thanks, 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).

    Stefan PiltzStefan Piltz
    Participant

    Folder Name: data/MTC4BT1
    Content:
    – controller_config.json
    – network.json
    – loco_BR81_001_PU.json
    – loco_BR81_001_SBrick.json

    network.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/MTC4BT1
    

    Comment: 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.

Viewing 10 posts - 1 through 10 (of 10 total)