Arduino Nano ESP32 - DIYables Bluetooth App Analog Gauge

Overview

This example demonstrates an analog-style gauge display on the Arduino Nano ESP32 using BLE (Bluetooth Low Energy) via the DIYables Bluetooth STEM app. Display any value on a dial-style gauge with a configurable range and unit on your smartphone. Suitable for speedometers, pressure gauges, RPM displays, and similar applications.

Note: The Arduino Nano ESP32 supports BLE only — Classic Bluetooth is not supported. The DIYables Bluetooth App works on both Android and iOS with BLE.

Arduino Nano ESP32 Bluetooth Analog Gauge Example - Gauge Display via BLE Tutorial

Features

  • Analog Gauge Display: Dial-style gauge on your smartphone
  • Configurable Range: Set minimum and maximum values
  • Custom Unit: Display km/h, RPM, PSI, or any custom unit
  • Fast Updates: Up to 5 updates per second (200 ms interval)
  • On-Demand Request: App can request the current value at any time
  • Android & iOS Support: BLE is compatible with both platforms
  • No Pairing Required: BLE connects without manual pairing

Hardware Preparation

1×Arduino Nano ESP32
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano ESP32

Or you can buy the following kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Arduino Nano ESP32 Code

Detailed Instructions

  • New to the Arduino Nano ESP32? Start with the Arduino Nano ESP32 getting started guide.
  • Connect the Arduino Nano ESP32 to your computer via USB.
  • Open Arduino IDE.
  • Select the Arduino Nano ESP32 board and the correct COM port.
  • Click the Libraries icon in the left sidebar.
  • Search for "DIYables Bluetooth" and select the DIYables Bluetooth library by DIYables.
  • Click Install.
Arduino Nano ESP32 DIYables Bluetooth library
  • When prompted to install dependencies, click Install All.
Arduino Nano ESP32 DIYables Bluetooth dependency

BLE Code

  • In Arduino IDE, open File Examples DIYables Bluetooth ArduinoBLE_AnalogGauge, or paste the code into the editor.
/* * DIYables Bluetooth Library - ESP32 BLE Analog Gauge Example * Works with DIYables Bluetooth STEM app on Android and iOS * * This example demonstrates the Bluetooth Analog Gauge feature: * - Display values on an analog meter/gauge * - Configurable range and unit * - Perfect for sensor monitoring (speed, pressure, voltage, etc.) * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothAnalogGauge.h> #include <platforms/DIYables_Esp32BLE.h> // BLE Configuration const char* DEVICE_NAME = "ESP32BLE_Gauge"; const char* SERVICE_UUID = "19B10000-E8F2-537E-4F6C-D104768A1214"; const char* TX_UUID = "19B10001-E8F2-537E-4F6C-D104768A1214"; const char* RX_UUID = "19B10002-E8F2-537E-4F6C-D104768A1214"; // Create Bluetooth instances DIYables_Esp32BLE bluetooth(DEVICE_NAME, SERVICE_UUID, TX_UUID, RX_UUID); DIYables_BluetoothServer bluetoothServer(bluetooth); // Create Analog Gauge app instance (min=0, max=100, unit="km/h") DIYables_BluetoothAnalogGauge bluetoothGauge(0.0, 100.0, "km/h"); // Variables for gauge value float currentValue = 0.0; unsigned long lastUpdate = 0; const unsigned long UPDATE_INTERVAL = 200; // Update every 200ms // Optional: Analog input pin for sensor const int ANALOG_PIN = A0; // ESP32 ADC pin // Function to read sensor value float readSensorValue() { // TODO: Replace with actual sensor reading // Option 1: Read from analog pin and map to gauge range // int rawValue = analogRead(ANALOG_PIN); // return map(rawValue, 0, 4095, 0, 100); // ESP32 has 12-bit ADC // Option 2: Simulated data (sine wave) static float phase = 0; phase += 0.05; if (phase > 2 * PI) phase = 0; return 50 + 50 * sin(phase); // Oscillates between 0-100 } void setup() { Serial.begin(115200); delay(1000); Serial.println("DIYables Bluetooth - ESP32 BLE Analog Gauge Example"); // Initialize Bluetooth server with platform-specific implementation bluetoothServer.begin(); // Add gauge app to server bluetoothServer.addApp(&bluetoothGauge); // Set up connection event callbacks bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); currentValue = readSensorValue(); bluetoothGauge.send(currentValue); Serial.print("Initial value sent: "); Serial.print(currentValue); Serial.print(" "); Serial.println(bluetoothGauge.getUnit()); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); }); bluetoothGauge.onValueRequest([]() { currentValue = readSensorValue(); bluetoothGauge.send(currentValue); Serial.print("Value requested - Sent: "); Serial.print(currentValue); Serial.print(" "); Serial.println(bluetoothGauge.getUnit()); }); Serial.println("Waiting for Bluetooth connection..."); Serial.print("Gauge range: "); Serial.print(bluetoothGauge.getMin()); Serial.print(" - "); Serial.print(bluetoothGauge.getMax()); Serial.print(" "); Serial.println(bluetoothGauge.getUnit()); } void loop() { bluetoothServer.loop(); if (bluetooth.isConnected() && millis() - lastUpdate >= UPDATE_INTERVAL) { lastUpdate = millis(); currentValue = readSensorValue(); bluetoothGauge.send(currentValue); Serial.print("Gauge: "); Serial.print(currentValue, 1); Serial.print(" "); Serial.println(bluetoothGauge.getUnit()); } delay(10); }
  • Click Upload to flash the sketch to the board.
  • Open the Serial Monitor.
  • The Serial Monitor output should look like:
COM6
Send
DIYables Bluetooth - Analog Gauge Example Waiting for Bluetooth connection...
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Mobile App

  • Install the DIYables Bluetooth App on your smartphone: Android | iOS

Note: The DIYables Bluetooth App works on both Android and iOS with BLE. No manual pairing is required.

  • Launch the DIYables Bluetooth App.
  • On first launch, grant the following permissions:
    • Nearby Devices (Android 12+) / Bluetooth (iOS) — required to scan and connect to Bluetooth devices
    • Location (Android 11 and below only) — required by older Android versions to scan for BLE
  • Ensure Bluetooth is enabled on your device.
  • Tap Connect on the home screen. The app will scan for BLE devices.
DIYables Bluetooth App - Home Screen with Scan Button
  • Tap "Arduino_Gauge" in the scan results.
  • After connecting, return to the home screen and open the Analog Gauge app.
DIYables Bluetooth App - Home Screen with Analog Gauge App

Tap the settings icon on the home screen to show or hide apps. See the DIYables Bluetooth App User Manual for details.

  • The analog gauge displays values with smooth needle movement, simulating a speedometer.
DIYables Bluetooth App - Analog Gauge Screen

Now look back at the Serial Monitor on Arduino IDE. You will see:

COM6
Send
Bluetooth connected! Gauge value: 50.00 km/h Gauge value: 59.76 km/h Gauge value: 68.78 km/h
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Creative Customization - Adapt the Code to Your Project

Configure Gauge Range and Unit

// Speedometer: 0-200 km/h DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 200.0, "km/h"); // Pressure gauge: 0-100 PSI DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 100.0, "PSI"); // RPM gauge: 0-8000 RPM DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 8000.0, "RPM"); // Percentage: 0-100% DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 100.0, "%");

Send Gauge Values

// Send a value to the gauge bluetoothGauge.send(75.5); // Read from sensor and send float sensorValue = analogRead(A0) * (100.0 / 1023.0); bluetoothGauge.send(sensorValue);

Handle Value Requests

bluetoothGauge.onValueRequest([]() { float value = readSensor(); bluetoothGauge.send(value); Serial.print("Requested: "); Serial.println(value); });

Programming Examples

Potentiometer Gauge

DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 100.0, "%"); void loop() { bluetoothServer.loop(); static unsigned long lastTime = 0; if (millis() - lastTime >= 200) { lastTime = millis(); float percent = analogRead(A0) * (100.0 / 1023.0); bluetoothGauge.send(percent); } }

Battery Level Monitor

DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 100.0, "%"); float readBatteryLevel() { float voltage = analogRead(A0) * (5.0 / 1023.0) * 2; // voltage divider float percent = map(voltage * 100, 300, 420, 0, 100); return constrain(percent, 0, 100); } void loop() { bluetoothServer.loop(); static unsigned long lastTime = 0; if (millis() - lastTime >= 1000) { lastTime = millis(); bluetoothGauge.send(readBatteryLevel()); } }

Troubleshooting

Common Issues

1. Device not visible in the app

  • Confirm the board is powered on and the sketch is uploaded
  • Verify Bluetooth is enabled on your phone
  • On Android 11 and below, enable Location services as well

2. Gauge not updating

  • Verify send() is called inside the loop
  • Check the update interval timing
  • Confirm bluetoothServer.loop() is called each iteration

3. Gauge displays incorrect range

  • Review the min/max values in the constructor
  • Confirm the unit string is correct
  • Values outside the configured range will be clamped

4. Needle jumps erratically

  • Apply smoothing or averaging to sensor readings
  • Reduce the update frequency if needed
  • Check for noisy analog inputs

5. Upload fails or board not recognized

  • Install the latest Arduino Nano ESP32 board package via Board Manager
  • Try a different USB cable or port

Project Ideas

  • Speedometer for RC car
  • Pressure gauge for pneumatic systems
  • Battery level indicator
  • RPM gauge for motors
  • Signal strength meter

Next Steps

After completing the Bluetooth Analog Gauge example, explore:

  1. Bluetooth Temperature — Temperature-specific gauge display
  2. Bluetooth Plotter — Visualize data over time
  3. Bluetooth Slider — Send values back to the Arduino
  4. Multiple Bluetooth Apps — Combine gauge with other app widgets

Support

For additional help:

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!