I' am asking for help regarding my MIT App. I want to integrate two connectivity options where the user can choose either “CONNECT BLUETOOTH” or “CONNECT WI-FI.”
I cannot use regular Bluetooth because it shares the same radio as WiFi, which means I cannot initialize both in the Arduino sketch code at the same time. If I initialize one first, the other crashes. That is why I plan to use BLE instead of Bluetooth Classic.
I have been working on this for weeks and have tried using multiple AI tools, but I still have not been able to solve it. (It's a simple logic but i can't do it.)
This is what i did for the couple of weeks
- Tried using TinyDB for storing data for returning users.
- Installed 2 extension (TaifunWifi), and BLE Extension Version 20240822
*Since im still quite new to mit app i am not sure where to place my blocks ( i need help with that, because i am not sure if i am doing it right.)
Below is the app flow:
MIT APP INVENTOR Code Blocks and ESP32 Sketch Code
I have only 2 buttons on screen1 which is "CONNECT BLUETOOTH" and "CONNECT WI-FI", 1 LABEL STATUS AND 1 Retry for Wifi if the user wants to choose another network, Assume 2 buttons, 1 Label Status, 1 Button for Retry Wifi, and screen 2 is already created.
we will not use bluetooth client classic because it cant coexist with wifi, Instead use BLE
Case 1 for BLUETOOTH(use BLE not BluetoothClassic):
- User Clicks "CONNECT BLUETOOTH"
- Users Bluetooth is not open.
- Notifer (Please open Bluetooth and connect to FarmMonitor_BLE) (user manually connects and pairs).
- User Returns to app
- (Label Status Changed to BLUETOOTH CONNECTED.)
- User Clicks "CONNECT BLUETOOTH" again.
- Listpicker, USER picks FarmMonitor_BLE or We can proceed immediately to screen2(Dashboard) without listpicker up to you which is easier to do.
- If user is already connected to and paired to FarmMonitor_BT then auto reconnection.
Case 2 for WIFI(WifiManager Library by Tzapu):
- User Clicks "CONNECT WIFI"
- Users WIFi is not open
- Notifer (Please open WIFI and Connect to FarmMonitor_Setup)
- (User connects to FarmMonitor_Setup, user will be directed to wifi web portal configuration, user configures his network, network changed to his desired network, esp32 save the users chosen network).
- User returns to app
- User Click "CONNECT WI-FI"
- Proceed to screen2 (Dashboard).
- if user wants to change different network, user clicks "Retry Wi-Fi" on Screen 1 then step step 3 to 6 starts again.
BLUETOOTH(BLE) LOCAL Connection
WIFI(ANYWHERE CONNECTION)
ESP32 INFO:
Chip type: ESP32-D0WD-V3 (revision v3.1)
Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None
Crystal frequency: 40MHz
MAC: d4:e9:f4:c3:a0:9c