DigiTekXplorer
Home
Capstone Project
abCore16 Folder
  • abCore16 Project
  • Instruction Set
  • abCore16 User Guide
AI Case Studies
Coding Basics
Embedded Systems
RP Pico Folder
  • Raspberry Pi Pico
  • Pico VGA Project
  • Pico Audio Project
FPGAs
Basic Concepts
Android App Folder
  • BLE Basics
  • Android Studio
  • BLE App User Guide
  • The Gemini Prompt
  • Android App Development
UART Design Folder
  • UART Design
DigiTekXplorer
Home
Capstone Project
abCore16 Folder
  • abCore16 Project
  • Instruction Set
  • abCore16 User Guide
AI Case Studies
Coding Basics
Embedded Systems
RP Pico Folder
  • Raspberry Pi Pico
  • Pico VGA Project
  • Pico Audio Project
FPGAs
Basic Concepts
Android App Folder
  • BLE Basics
  • Android Studio
  • BLE App User Guide
  • The Gemini Prompt
  • Android App Development
UART Design Folder
  • UART Design
More
  • Home
  • Capstone Project
  • abCore16 Folder
    • abCore16 Project
    • Instruction Set
    • abCore16 User Guide
  • AI Case Studies
  • Coding Basics
  • Embedded Systems
  • RP Pico Folder
    • Raspberry Pi Pico
    • Pico VGA Project
    • Pico Audio Project
  • FPGAs
  • Basic Concepts
  • Android App Folder
    • BLE Basics
    • Android Studio
    • BLE App User Guide
    • The Gemini Prompt
    • Android App Development
  • UART Design Folder
    • UART Design
  • Home
  • Capstone Project
  • abCore16 Folder
    • abCore16 Project
    • Instruction Set
    • abCore16 User Guide
  • AI Case Studies
  • Coding Basics
  • Embedded Systems
  • RP Pico Folder
    • Raspberry Pi Pico
    • Pico VGA Project
    • Pico Audio Project
  • FPGAs
  • Basic Concepts
  • Android App Folder
    • BLE Basics
    • Android Studio
    • BLE App User Guide
    • The Gemini Prompt
    • Android App Development
  • UART Design Folder
    • UART Design

DigiTekXplorer - Android App Development

Android App Development using Google AI Studio

BLE Controller Description

B_Bot BLE Controller is an Android application that allows you to wirelessly control a Raspberry Pi Pico 2 W robot (B-Bot) via Bluetooth Low Energy (BLE). Send vehicle movement commands, adjust speed and turning angles, and monitor the Pico's HeartBeat count and control an LED, all from a simple, user-friendly interface.

AI-Powered App Development

The BLE B_Bot Controller Android app was created through an iterative process leveraging the capabilities of Google Gemini. The process began with a comprehensive specification detailing the desired app functionality, UI layout, communication protocol with a Raspberry Pi Pico 2 W, and technical requirements such as using Kotlin and Jetpack Compose, avoiding deprecated functions, and handling BLE connectivity.


The comprehensive app specification was entered into Gemini's prompt and then Gemini generated Kotlin code for the app, structured into multiple files (MainActivity, BleApp, BleManager, and BleViewModel) to promote code organization and maintainability. The generated code was reviewed and refined to ensure it met all the specifications, including the specific UI layout, BLE command formats, error handling (e.g., connection retries, Snackbar messages), and the handling of data received from the Pico (Heartbeat count and LED status).  


The app specification was refined over multiple days as we learned how Gemini responded to additional details, especially the behavior of buttons when pressed. On the eighth iteration of the specification, enough details were provided to allow Gemini to generate Kotlin code files used in Android Studio to create the app.  In between each iteration, many code errors were identified by Android Studio.  Code snippets and error descriptions, provided by Android Studio, were copied into Gemini’s prompt entry. Gemini then generated new code, in some cases a complete new source file, to fix the problem. As stated, this was an iterative process that eventually led to error-free code.  Although warnings were still present, we were able to create the app and load the app onto a physical Android phone for testing. 


The resulting app provides a complete solution to control a B_Bot rover via BLE.

Bridging Android and the Pico 2 W

The Raspberry Pi Pico 2 W brings Wi-Fi and Bluetooth capabilities to the popular microcontroller platform, opening exciting possibilities for wireless projects. This page details the "BLE B-Bot Controller," an Android application specifically created to communicate with and control a Pico 2 W device (named "B-Bot") using Bluetooth Low Energy (BLE).

App Overview & Key Features

The BLE B-Bot Controller provides a user-friendly interface on your Android phone to interact directly with your paired Pico 2 W device. Its core features include:

  • BLE Device Scanning: Initiates scans filtered for the specific BLE service advertised by the B-Bot project.
  • Device Selection & Connection: Displays discovered compatible devices (showing device name and MAC address) and allows users to select and establish a BLE connection.
  • Connection Management: Provides clear visual feedback on the connection status (Connecting, Connected, Failed) and includes an automatic reconnection attempt on failure.
  • Direct Command Interface: Send custom 3-character commands (with optional numerical parameters) directly to the Pico 2 W via a text input field.
  • Message Sending: Transmit arbitrary text messages to the Pico 2 W.
  • Slider Controls: Adjust parameters like Speed (0-10) and Turn Angle (0-180) using sliders, which send formatted commands (spd,NN, trn,NNN) upon button press.
  • Movement Buttons: Dedicated buttons for common movement commands (Forward, Reverse, Left, Right, Halt) sending predefined codes (fwd, rev, lft, rgt, hlt).
  • Status Monitoring:
    • Heartbeat Count: Request and display a Heartbeat counter value from the Pico 2 W (updates only on user request via the "Update HB" button).
    • LED Control & Status: Control an LED on the B_bot  via buttons and request/display its current status ("on"/"off").
  • Modern UI: Built with Jetpack Compose for a clean, reactive user interface.

Technology Stack

For those interested in the underlying technology, the app was built using:

  • Language: Kotlin
  • UI Framework: Jetpack Compose (Android's modern toolkit for native UI)
  • Core APIs: Android Bluetooth Low Energy (BLE) APIs
  • Permissions: Accompanist Permissions library for handling runtime permission requests.
  • Architecture: Followed a basic MVVM (Model-View-ViewModel) structure.

The Development Journey: Accelerating with AI (Gemini)

A unique aspect of this app's creation was the significant role played by the AI assistant, Google Gemini. Starting from a detailed set of specifications provided – outlining everything from the BLE protocol and command formats to the exact UI layout and error handling – Gemini generated the foundational Kotlin code for the entire application.


Why was this approach so valuable, especially for someone new to these technologies?

  • Bridging Knowledge Gaps: Developing an Android app, particularly one involving BLE, requires familiarity with Kotlin, the Android SDK, Jetpack Compose UI patterns,   Android Activity/ViewModel lifecycles, manifest configurations, Gradle dependencies, and the notoriously complex Bluetooth Low Energy APIs (including callbacks, asynchronous operations, GATT services/characteristics, connection states, and cross-version compatibility issues). For someone with limited experience in these specific areas, the learning curve can be incredibly steep.
  • Accelerated Prototyping: Gemini translated the detailed requirements directly into functional code structures for MainActivity, BleViewModel, BleManager,BleApp, Constants, and AndroidManifest.xml. This dramatically reduced the initial development time compared to writing everything from scratch, especially the intricate BLE communication logic.
  • Handling BLE Complexity: BLE programming is known for its nuances. Gemini generated code to handle scanning, connecting, discovering services, reading/writing characteristics (including handling different write types), enabling notifications, and managing connection states, incorporating best practices based on its training data.
  • Iterative Debugging Partner: Development rarely works perfectly on the first try. When build errors or runtime issues (like incorrect BLE callback behavior on specific Android versions) arose, we provided code snippets, error messages and Logcat output back to Gemini. The AI analyzed this feedback and provided targeted code corrections and explanations, facilitating a rapid debugging cycle that would have been much slower relying solely on documentation and web searches.
  • Focus on the Goal: By handling much of the boilerplate and complex API interactions, Gemini allowed us to focus more on defining the requirements and testing the functionality against the Pico 2 W, rather than getting bogged down in low-level implementation details from the start.


In essence, using Gemini acted as a powerful assistant, making a project of this complexity achievable and significantly faster for someone without deep prior expertise in all the required domains. It transformed the process from potentially months of learning and coding into days of specification, generation, and collaborative refinement.

Getting Started with the App

  1. Prerequisites: Ensure your Pico 2 W is programmed correctly, powered on, and within range. Turn on Bluetooth and Location on your Android phone.
  2. Install & Launch: Install the BLE B-Bot Controller app.
  3. Grant Permissions: Allow Location and Bluetooth/Nearby Devices permissions when prompted.
  4. Scan & Connect: Tap "Scan", wait for your device to appear in the dialog, and tap the device name ("B_Bot") to connect.
  5. Control: Once the status shows "Connected", use the buttons, sliders, and text fields to interact with your B_Bot.
  6. Visual Feedback: Press the HB Update button to assure you are connected to the Pico 2 W. An incrementing number should appear in the text field each time the button is pressed. As another visual verification, press the LED "On" button. The B_Bot’s purple LED should turn on.

Documentation Generation with Gemini

Gemini significantly sped up the creation of essential project documentation. We were able to generate a detailed user guide based on the app specifications, saving valuable time on writing and formatting. The AI's ability to understand the app's functionality and structure allowed it to produce accurate and helpful documentation with minimal manual effort.  Because Gemini generated the app's code from a detailed specification, it was in a perfect position to generate documentation for the app's description, user guide, and content for this website. This documentation makes the project more accessible, understandable, and valuable for other users.

Android BLE App Development

Bluetooth LE

Android Studio

Android Studio

  

The Bluetooth LE (BLE) radio is designed for very low power operation. Transmitting data over 40 channels in the 2.4GHz frequency band. BLE provides developers flexibility to build products that meet unique project requirements, including point-to-point used in this project.

Xplorer BLE

Android Studio

Android Studio

Android Studio

Android Studio is the official Integrated Development Environment (IDE) for Android app development. It provides a comprehensive suite of tools and features that enhance productivity and streamline the development process.

Xplorer Android Studio

Gemini Prompt

User Guide: BLE B_Bot Controller App

User Guide: BLE B_Bot Controller App

Explains how the Gemini prompt for the BLE B_Bot Controller app was created and a final version of the prompt.

Xplorer Gemini Prompt

User Guide: BLE B_Bot Controller App

User Guide: BLE B_Bot Controller App

User Guide: BLE B_Bot Controller App

This guide explains how to use the BLE B_Bot Controller app to control a Raspberry Pi Pico 2 W via Bluetooth Low Energy (BLE).

Xplorer User Guide

Copyright © 2025 DigiTekXplorer - All Rights Reserved.


Powered by

This website uses cookies.

We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.

Accept