Reading values in serial monitor from ESP32 via bluetooth on smartphone

Hello,

yesterday I was searching for a suitable smartphone app creator app for my project and I came across MIT APP Inventor - which means my question will probably be very basic and easy to answer for most.

What exactly I am trying to do is simple - I am working on a very specific project and I need to read stored values in my ESP32 EEPROM where ESP32 is connected to my smartphone via BT. The connection between the two I have successfully managed to establish. However what I am struggling with is reading the serial monitor.

/////////////////////////////////

// Generated with a lot of love//
// with TUNIOT FOR ESP32 //
// Website: Easycoding.tn //
/////////////////////////////////
#include "BluetoothSerial.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include <EEPROM.h>

float value = 458.36;
float k = 0;

String DATA;
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run make menuconfig to and enable it
#endif

BluetoothSerial SerialBT;
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(":");}
}
Serial.println();
}

void setup()
{

Serial.begin(9600);
EEPROM.begin(4);
EEPROM.writeFloat(0, value);
EEPROM.commit();

delay(5000);
SerialBT.begin("ESP32test");
Serial.println("This is your address:");
printDeviceAddress();
}

void loop()
{
k = EEPROM.readFloat(0);
Serial.print(k, 2);
Serial.print("\n");
delay (10000);
}

As you can see it is quite simple - I read the saved float from the eeprom in serial monitor. Now all I need to do is to be able to read this data on my smartphone. Now in the image of blocks some may not make much sense since I have never touched such thing before but what I did was watch some youtube tutorials and tried to figure it myself since everyone was doing kinda the same thing but differently. But I still didn't manage to display anything on my smartphone. The android version is 9 PKQ1.180904.001. Please pardon my formatting, this is my very first post too.

Okay I revisited the blocks and I figured using serial is not the correct approach. I am using bluetooth after all. But still can't figure out how to do it. I tried doing this, which I think looks much more like it but still not working. Anyone help? :slight_smile:

The ESP32 can work with Classic Bluetooth (BluetoothClient component) and BLE (BLE extension), you are using Classic Bluetooth.
In these tutorials you can see codes with Classic Bluetooth.

Codes with ESP32 as Classic Bluetooth (It is in Spanish).

http://kio4.com/arduino/150_Wemos_BluetoothClasico.htm

Hello Juan_Antonio and thank you for your response.

I've gone over the tutorials in your included link however it made me even more confused if anything.
I think my problem could lie somewhere here:

  1. I am an absolute newb to MIT
  2. I am a semi-newb to arduino
    However my knowledge about bits and bytes is quite good. I think the problem is somewhere there. I am storing 4 byte numbers (float) in eeprom of my esp32. Then I read that number from eeprom and save it in a variable k (float). Then I write Serial.print(k); which should display the saved variable - which it does correctly but only on my serial monitor in arduino. Now I was trying something out and tried to arrange the blocks like this

    The output of the clock block is 0 on my smartphone so I would assume there is no data available?
    There are quite a few options in the bluetooth such as receive x bytes but I think I am not quite skilled to arrange the blocks the way it would work :frowning:
    Any help would be much appreciated!

Try first sending String from Arduino/ESP32 to App.
In the Properties of the ClientBluetooth. DelimiterByte = 10 (this mean \n, end line for println in Arduino).

Hello Juan_Antonio thank you yet again for your response. I did what you said (set the delimiter to 10) but no luck, whatever I do I cannot get it to work. The text label on my phone changes but not to what I want. See:


With this right now, the sample text "DATA_FROM_ESP32_EEPROM" disappeared and there is nothig on my phone except the connected button. In arduino I am trying to do simplest command.
Serial.println("hello");

BytesAvalaibleToReceive >=0
ReceiverText NumberOfBytes = -1

http://ai2.appinventor.mit.edu/reference/components/connectivity.html#BluetoothClient

Thank you, but this did not work either.

borrar_p9A0i_bluetooth_potenciometro_copiar.aia (3.1 KB)

In ESP32, delay 1000

Try
void loop()
{
//k = EEPROM.readFloat(0);
//Serial.print(k, 2);
Serial.println("Hello");
delay (1000);
}

@Rob94

Try this tutorial:

Hello
I am working on a similar project for blinds in which I am using esp32 wroom(sparkfun thing plus) / RFID and an MIT app..I am able to display the data of the RFID tag onto the phone through the app Bluetooth serial terminal.but I need to create an MIT app to display the RFID output through Bluetooth in my app and should read out the text displayed as well ..can you please give me an idea atleast on what has to be done

You have to decide if you want to use classic Bluetooth or BLE, in case you use BLE you can consult these tutorials.