Nano 33 IoT + Classic Bluetooth. Can send data through Serial Monitor, but not data in stored variables - any help?

I am running Classic Bluetooth on my Nano 33 IoT as described in the threads here and here. I can transmit/receive data using the Serial Monitor and an Android App called Serial Bluetooth as seen in this example here or as seen in the image(s) below:

Serial Monitor:

Serial Bluetooth Monitor:

However, I can't send data from anything in a stored variable in the Arduino sketch. For example, doing an AnalogRead() and sending that information or even trying to send a String like "testing". Here's the simplest example of this:

void loop() {
    if (Serial.available()) {

Oddly, the first character seems it's being sent to the ESP32 but not sent through BT. If I go to the Serial Monitor while running this sketch, each time I enter a space (" ") and send it, the App receives a "t ". Otherwise, nothing is sent. Repeated spaces only results in more "t"s.

Similarly, if I send a word in the Serial monitor like "okay" the App receives a "totktaty"

Here's what I mean:

So, I don't understand why information can be sent using the Serial Monitor, but not within the sketch. Any help would be appreciated, thanks!

PS: If it matters, I have tried sending information to the ESP32 as one byte at a time, it does not work. Below are the baudrates in my sketch:


UPDATE: This is causing the problem:

    if (Serial.available()) {

If I remove this "if" statement, I can transmit data perfectly. I don't understand why checking Serial.available would cause this error however

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.