Bluetooth Auto-Connect in MIT App Inventor
When building Arduino, ESP32, or IoT hardware projects, selecting your Bluetooth module manually every time you open your app gets repetitive. By storing your device's MAC address in TinyDB, your app can auto-connect instantly on launch.
🛠️ How It Works
Initial Link: User selects the Bluetooth module once using a
ListPicker.Save MAC: On successful connection, the app stores the module's MAC address in
TinyDB.Auto-Reconnect: On
Screen1.Initialize, the app retrieves the address and automatically connects in the background.
📱 Required Components
BluetoothClient(Connectivity)ListPicker(For first-time device selection)TinyDB(Storage — to save the MAC address)
🧩 Block Logic Overview
Screen1.Initialize: Read saved tag"BT_Address"fromTinyDB. If present, callBluetoothClient.Connectusing that address.ListPicker.BeforePicking: SetListPicker.ElementstoBluetoothClient.AddressesAndNames.ListPicker.AfterPicking: Connect toListPicker.Selection. On success, saveListPicker.SelectiontoTinyDBunder tag"BT_Address".
