Esp32BleAndroid Quick Start Guide

This guide explains how to set up the Esp32BleAndroid package to enable communication between an ESP32 and Unity via Bluetooth Low Energy (BLE).

Overview

In the provided Demo scene:

  • Data from ESP32 to Unity: The ESP32 generates simulated acceleration data (x, y, z) using a SIN function and sends it to Unity. A 3D object ‘Tumbler’ tilts in response to this data.
  • Data from Unity to ESP32: When you enter values into the InputField and click the ‘On‘ button, Unity sends that numerical data back to the ESP32.


Step 1: Download and Set Up the Unity Project

  1. Import the Asset:
    • Download Esp32BleAndroid from the Asset Store.
    • Click the Import button to add the files to your project.

  2. Verify the Assets:
    • Confirm that the package is imported under the “Assets” folder.

  3. Open the Demo Scene:
    • In the Project tab, navigate to Assets > Esp32BleAndroidInterface > Scenes.
    • Double-click the “Esp32BleAndroidSampleScene.unity” to open it.

  4. Building and Debugging Instructions:
  5. Verify the Game Information:
    • Esp32BleAndroid” game information installed on Android phone will appear as shown below:

Step 2: Program the ESP32 using Arduino IDE

  1. Hardware Connection:
    • Connect your ESP32 to your PC using a Micro USB cable.
    • Ensure your Arduino IDE environment is configured for ESP32 development according to Arduino IDE v2 for Esp32.

    [Esp32]

    [Esp32-S3]

  2. Upload the Firmware:
    • Locate the file “esp32ble-v2.1.ino” in the “Assets / Esp32BleAndroidInterface / esp32ble-v2.1” folder.
    • Open this file in Arduino IDE, then Compile and Upload it to your ESP32.

Step 3: Run the Demo Scene

  1. Play Esp32BleAndroid:
    • The 3D object ‘Tumbler’ should tilt in sync with the ESP32 data.
    • View the Console tab for system status logs using the Android Logcat, refer to Building and Debugging Games for Android for details.
    • [BLE Advertising]

      [BLE Communication]

  2. Monitor Serial Output:
    • Open the Serial Monitor in Arduino IDE.
    • Confirm the status changes from [Not connected to Unity] to [Connected to Unity and sending acceleration data].
    • [Not connected to Unity]

      [Connected to Unity and sending acceleration data]

  3. Input Data (Unity to ESP32):
    • Enter numerical values into InputField ‘No0’ and ‘No1‘ on the game screen.
    • Click the On button.
    • Confirm the Console tab for system status logs.
    • Confirm that the Serial Monitor in Arduino IDE displays the received No0/No1 data.