Arduino UNO R4 - DIYables Bluetooth App Analog Gauge

Overview

The Bluetooth Analog Gauge example provides a visual analog-style gauge display through the DIYables Bluetooth STEM app. Designed for Arduino UNO R4 WiFi using BLE (Bluetooth Low Energy) — display any analog value on a beautiful gauge with configurable range and unit on your smartphone. Perfect for speedometers, pressure gauges, RPM displays, and any value that benefits from a dial-style visualization.

Note: The Arduino UNO R4 WiFi only supports BLE (Bluetooth Low Energy). It does not support Classic Bluetooth. The DIYables Bluetooth App supports both BLE and Classic Bluetooth on Android, and BLE on iOS. Since this board uses BLE, the app works on both Android and iOS.

Arduino UNO R4 WiFi Bluetooth Analog Gauge Example - Gauge Display via BLE Tutorial

Features

  • Analog Gauge Display: Beautiful dial-style gauge on 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 (200ms interval)
  • On-Demand Request: App can request current value
  • Works on Android & iOS: BLE is supported on both platforms
  • No Pairing Required: BLE auto-connects without manual pairing

Hardware Preparation

1×Arduino UNO R4 WiFi
1×Alternatively, DIYables STEM V4 IoT
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 Block Shield for Arduino UNO R4
1×Recommended: Breadboard Shield for Arduino UNO R4
1×Recommended: Enclosure for Arduino UNO R4
1×Recommended: Power Splitter for Arduino UNO R4
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

1×DIYables STEM V4 IoT Starter Kit (Arduino included)
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 UNO R4 WiFi Code

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino UNO R4 WiFi, refer to the Arduino UNO R4 WiFi getting started guide.
  • Connect the Arduino UNO R4 WiFi board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select Arduino UNO R4 WiFi board and the appropriate COM port.
  • Navigate to the Libraries icon on the left bar of the Arduino IDE.
  • Search "DIYables Bluetooth", then find the DIYables Bluetooth library by DIYables
  • Click Install button to install the library.
Arduino UNO R4 DIYables Bluetooth library
  • You will be asked for installing some other library dependencies
  • Click Install All button to install all library dependencies.
Arduino UNO R4 DIYables Bluetooth dependency

BLE Code

  • On Arduino IDE, Go to File Examples DIYables Bluetooth ArduinoBLE_AnalogGauge example, or copy the above code and paste it to the editor of Arduino IDE
/* * DIYables Bluetooth Library - Bluetooth 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.) * * Compatible Boards: * - Arduino UNO R4 WiFi * - Arduino Nano 33 BLE / BLE Sense * - Arduino Nano 33 IoT * - Arduino MKR WiFi 1010 * - Arduino Nano RP2040 Connect * - Any board supporting the ArduinoBLE library * * Optional: Analog sensor (potentiometer, pressure sensor, etc.) * * Setup: * 1. Upload the sketch to your Arduino * 2. Open Serial Monitor to see connection status * 3. Use DIYables Bluetooth App to connect and view the gauge * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothAnalogGauge.h> #include <platforms/DIYables_ArduinoBLE.h> // BLE Configuration const char* DEVICE_NAME = "Arduino_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_ArduinoBLE 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; // Function to read sensor value float readSensorValue() { // TODO: Replace with actual sensor reading // Examples: // - Pressure sensor: readPressure() // - Voltage sensor: analogRead(A0) * (5.0 / 1023.0) // - Speed sensor: calculateSpeed() // Option 1: Read from analog pin and map to gauge range // int rawValue = analogRead(ANALOG_PIN); // return map(rawValue, 0, 1023, 0, 100); // 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(9600); while (!Serial); Serial.println("DIYables Bluetooth - Analog Gauge Example"); // Optional: Initialize analog pin // pinMode(ANALOG_PIN, INPUT); // 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!"); // Send initial value 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!"); }); // Optional: Handle requests for current value bluetoothGauge.onValueRequest([]() { currentValue = readSensorValue(); bluetoothGauge.send(currentValue); Serial.print("Value requested - Sent: "); Serial.print(currentValue); Serial.print(" "); Serial.println(bluetoothGauge.getUnit()); }); // You can change gauge configuration at runtime: // bluetoothGauge.setRange(0.0, 200.0); // Change range to 0-200 // bluetoothGauge.setUnit("mph"); // Change unit to mph // bluetoothGauge.setRange(0.0, 5.0); // For voltage (0-5V) // bluetoothGauge.setUnit("V"); 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() { // Handle Bluetooth server communications bluetoothServer.loop(); // Send gauge updates periodically (only when connected) if (bluetooth.isConnected() && millis() - lastUpdate >= UPDATE_INTERVAL) { lastUpdate = millis(); // Read sensor value currentValue = readSensorValue(); // Send to Bluetooth app bluetoothGauge.send(currentValue); // Print to Serial Monitor Serial.print("Gauge: "); Serial.print(currentValue, 1); Serial.print(" "); Serial.println(bluetoothGauge.getUnit()); } delay(10); }
  • Click Upload button on Arduino IDE to upload code to Arduino UNO R4 WiFi
  • Open the Serial Monitor
  • Check out the result on Serial Monitor. It looks like the below:
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 supports both BLE and Classic Bluetooth on Android, and BLE on iOS. Since the Arduino UNO R4 WiFi uses BLE, the app works on both Android and iOS. No manual pairing is needed for BLE — just scan and connect.

  • Open the DIYables Bluetooth App
  • When opening the app for the first time, it will ask for permissions. Please grant the following:
    • Nearby Devices permission (Android 12+) / Bluetooth permission (iOS) - required to scan and connect to Bluetooth devices
    • Location permission (Android 11 and below only) - required by older Android versions to scan for BLE devices
  • Make sure Bluetooth is turned on on your phone
  • On the home screen, tap the Connect button. The app will scan for BLE devices.
DIYables Bluetooth App - Home Screen with Scan Button
  • Find and tap "Arduino_Gauge" in the scan results to connect.
  • Once connected, the app automatically goes back to the home screen. Select the Analog Gauge app from the app menu.
DIYables Bluetooth App - Home Screen with Analog Gauge App

Note: You can tap the settings icon on the home screen to hide/show apps on the home screen. For more details, see the DIYables Bluetooth App User Manual.

  • You will see an analog gauge displaying values with a 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. Cannot find the device in the app

  • Make sure the Arduino UNO R4 WiFi is powered on and the sketch is uploaded
  • Ensure your phone's Bluetooth is enabled
  • On Android 11 and below, also enable Location services

2. Gauge not updating

  • Check that send() is being called in the loop
  • Verify the update interval timing
  • Ensure bluetoothServer.loop() is called

3. Gauge shows wrong range

  • Check the min/max values in the constructor
  • Make sure the unit string is correct
  • Values outside the range will be clamped

4. Needle jumps erratically

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

5. Upload fails or board not recognized

  • Install the latest Arduino UNO R4 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 mastering the Bluetooth Analog Gauge example, try:

  1. Bluetooth Temperature - For temperature-specific gauge
  2. Bluetooth Plotter - For data over time
  3. Bluetooth Slider - For setting values back to Arduino
  4. Multiple Bluetooth Apps - Combining gauge with other apps

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!