Text file transfer from ESP32 to mobile app

319 Views Asked by At

I want to take a text file from an ESP32 module into my mobile app via Bluetooth. After which I want to be able to view the data in this file and convert this data to a csv file which I should be able to download and share.

I tried building the mobile app in MIT app inventor, but I couldn't transfer the text file from the ESP32 module.

1

There are 1 best solutions below

0
Ars_Codicis On

A simple Google Search resulted in this tutorial, specifically summarized with:


...setup and start Bluetooth communication and also a couple of simple projects involving data transfer between ESP32 and a smart phone over Bluetooth Communication...

  • You need to configure your Bluetooth Serial connection in your void setup() function.

  • You need to start a Bluetooth Serial connection, and loop that in your void loop() function.

  • Your ESP32 Module is now visible to your smartphone.

If you're following the tutorial, you'll quickly realize that it requires a 3rd party app to do the communication.

The MIT App Inventor Page regarding the BluetoothClient component has the function: ReceiveText(numberOfBytes). It says that it:

  • Reads a number of bytes from the input stream and converts them to text.
  • If numberOfBytes is negative, read until a delimiter byte value is read.

Using the other methods that are available to you, you can determine whether or not the Device is connected to the ESP32.

Additional Notes:


  • You'll need the ESP32 "address", which is obtainable with this function:
void printDeviceAddress() {

  const uint8_t* point = esp_bt_dev_get_address();
  for (int i = 0; i < 6; i++) {
    char str[3];
    sprintf(str, "%02X", (int)point[i]);
    Serial.print(str);
    if (i < 5){
      Serial.print(":");
    }
  }
}

This is what MIT App Inventor requires as the "address" to connect with the ESP32. Source

  • You will want to loop looking for data in your app:

Test Image

In conclusion:

I suggest that you follow the electronicshub.org tutorial and make sure that your ESP32 is successfully sending and receiving data. Once you've gotten that to work, the MIT App Inventor BluetoothClient is all you need to send/receive data.