odroid_go:arduino:07_bluetooth_serial

Arduino for ODROID-GO - Bluetooth Serial

We will learn about how to communicate between ODROID-GO and your smartphone.

ESP32 which is used on ODROID-GO supports Bluetooth 4.2. So we can program Bluetooth features with helpful libraries on Arduino.
In this guide, we're going to use BluetoothSerial.h library.

This is the code. Quite simple.

#include "BluetoothSerial.h"
 
BluetoothSerial serialBT;
 
void setup() {
    Serial.begin(115200);
 
    serialBT.begin("ODROID-GO");
    Serial.println("The device started, now you can pair it with bluetooth!");
}
 
void loop() {
    if (Serial.available()) {
        serialBT.write(Serial.read());
    }
    if (serialBT.available()) {
        Serial.write(serialBT.read());
    }
    delay(20);
}

Define an instance for BluetoothSerial as a global variable, serialBT.
To set, we use begin() function having a parameter indicates the name of the Bluetooth device for the Bluetooth scanners. We named that ODROID-GO.

And in loop() function, if a message from the Serial monitor available, send that message to the connected device via Bluetooth serial.
On the other hand, if a message from the Bluetooth serial available, send that message to the host.

You can use a Serial monitor to watch the debug messages from the Serial port.
It is placed at the Tools → Serial Monitor menu to open. Or, you can press CTRL-SHIFT-M to open easily.

To show the message properly, you should select bandwidth to 115200 baud.

This would be very helpful debugging tool for you.
In this guide, we're using this tool to communicate with the connected device.

We tried with the Serial Bluetooth Terminal application on Android Playstore, on a Galaxy Note 8.

It finds a Bluetooth device named ODROID-GO and can connect to that.

And in the app, select ODROID-GO on the Devices tab.

Push the connect button on the top of the screen at the Terminal tab.

Then these can communicate each other.

Of course you can do on iOS or the PC/laptop if it has a Bluetooth module.

The complete example is available as follows:

Click the Files → Examples → ODROID-GO → BT_Serial menu to import and press CTRL-U to compile/upload.

  • odroid_go/arduino/07_bluetooth_serial.txt
  • Last modified: 2018/06/20 10:58
  • by joshua