ESP32 - DIYables Bluetooth App Rotator
Overview
The Bluetooth Rotator example provides a rotatable disc/knob control accessible through the DIYables Bluetooth STEM app. Designed for ESP32 boards with support for both BLE (Bluetooth Low Energy) and Classic Bluetooth connections. The rotator sends angle values and supports continuous (0-360°) or limited angle range modes — perfect for servo control, compass display, volume knobs, and any application requiring rotational input.
This example supports two Bluetooth modes:
- ESP32 BLE (Bluetooth Low Energy): Works on both Android and iOS
- ESP32 Classic Bluetooth: Works on Android only. iOS does not support Classic Bluetooth. Use BLE if you need iOS support.

Features
- Rotatable Knob: Touch and drag to rotate the on-screen disc
- Continuous Mode: Full 360° rotation without limits
- Limited Mode: Constrained angle range (e.g., 0-180° for servos)
- Angle Output: Float angle value sent in real time
- Servo Compatible: Direct mapping to servo angles (0-180°)
- BLE & Classic Bluetooth: Choose the Bluetooth mode that suits your project
- Cross-Platform: BLE mode works on both Android and iOS; Classic Bluetooth works on Android
- Low Power Option: BLE mode consumes less power than Classic Bluetooth
Hardware Used In This Tutorial
Or you can buy the following kits:
| 1 | × | DIYables ESP32 Starter Kit (ESP32 included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
ESP32 Code
Quick Instructions
Follow these instructions step by step:
- If this is your first time using the ESP32, refer to the tutorial on setting up the environment for ESP32 in the Arduino IDE.
- Connect the ESP32 board to your computer using a USB cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate ESP32 board and 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.

- You will be asked for installing some other library dependencies
- Click Install All button to install all library dependencies.

Choose one of the two Bluetooth modes below depending on your needs:
ESP32 Classic Bluetooth Code (works with app on Android only)
Note: Classic Bluetooth is NOT supported on iOS. If you need iOS support, use the BLE code below.
- On Arduino IDE, Go to File Examples DIYables Bluetooth Esp32Bluetooth_Rotator example, or copy the above code and paste it to the editor of Arduino IDE
- Click Upload button on Arduino IDE to upload code to ESP32
- Open the Serial Monitor
- Check out the result on Serial Monitor. It looks like the below:
ESP32 BLE Code (works with app on both Android and iOS)
- On Arduino IDE, Go to File Examples DIYables Bluetooth Esp32BLE_Rotator example, or copy the above code and paste it to the editor of Arduino IDE
- Click Upload button on Arduino IDE to upload code to ESP32
- Open the Serial Monitor
- Check out the result on Serial Monitor. It looks like the below:
Mobile App
- If you are using the ESP32 Classic Bluetooth code, you need to pair the ESP32 with your Android phone before opening the app:
- Go to your phone's Settings > Bluetooth
- Make sure Bluetooth is turned on
- Your phone will scan for available devices
- Find and tap "ESP32_Rotator" in the list of available devices
- Confirm the pairing request (no PIN required)
- Wait until it shows "Paired" under the device name
- If you are using the ESP32 BLE code, no pairing is needed. Just proceed to the next step.
- 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 both BLE and Classic Bluetooth devices.

- Find and tap your device in the scan results to connect:
- For Classic Bluetooth: tap "ESP32_Rotator"
- For BLE: tap "ESP32BLE_Rotator"
- Once connected, the app automatically goes back to the home screen. Select the Rotator app from the app menu.

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.
- Drag the rotator knob to change the angle

Now look back at the Serial Monitor on Arduino IDE. You will see:
- Rotate the knob in the app and watch the real-time angle values in the Serial Monitor
Creative Customization - Adapt the Code to Your Project
Configure Rotator Mode
Set continuous or limited mode:
Handle Angle Changes
Use the onRotatorAngle() callback to receive angle values:
Handle Configuration Request from App
Send Angle to App
You can update the rotator position from ESP32:
Handle Connection Events
How to Use the Rotator
App Interface Controls
The rotator interface in the DIYables Bluetooth App provides:
- Rotatable Disc: Touch and drag to rotate
- Angle Display: Shows current angle value
- Visual Indicator: Marks the current rotation position
Rotator Modes
- ROTATOR_MODE_CONTINUOUS (0): Full 360° rotation, wraps around
- ROTATOR_MODE_LIMITED (1): Constrained to min/max angle range
Programming Examples
Servo Control
Volume/Brightness Knob
Compass Display
Stepper Motor Control
Advanced Programming Techniques
Angle Snap to Increments
Zone-Based Control
BLE vs Classic Bluetooth - Which to Choose?
| Feature | BLE (Esp32BLE_Rotator) | Classic Bluetooth (Esp32Bluetooth_Rotator) |
|---|---|---|
| iOS Support | ? Yes | ? No |
| Android Support | ? Yes | ? Yes |
| Power Consumption | Low | Higher |
| Range | ~30-100m | ~10-100m |
| Data Rate | Lower | Higher |
| Pairing Required | No (auto-connect) | Yes (manual pairing) |
| Best For | Battery-powered, cross-platform | High throughput, Android-only |
Troubleshooting
Common Issues
1. Cannot find the device in the app
- Make sure the ESP32 is powered on and the sketch is uploaded
- For BLE: Ensure your phone's Bluetooth and Location are enabled
- For Classic Bluetooth: Pair the device first in phone's Bluetooth settings
- Check that the correct partition scheme is selected (Huge APP)
2. Rotator not responding
- Check Bluetooth connection status in the app
- Verify connection in Serial Monitor
- Try disconnecting and reconnecting
3. Angle values seem incorrect
- Check rotator mode configuration (continuous vs limited)
- Verify min/max angle settings with getMinAngle() and getMaxAngle()
- Check Serial Monitor for actual angle values received
4. Servo jitters at certain angles
- Add a small dead zone filter for angle changes
- Use a separate power supply for the servo
- Add a capacitor across servo power pins
5. Connection drops frequently
- Move closer to the ESP32 (reduce distance)
- For BLE: Check for interference from other BLE devices
- For Classic Bluetooth: Ensure stable power supply to ESP32
6. Sketch too large / not enough space
- In Arduino IDE, go to Tools > Partition Scheme and select "Huge APP (3MB No OTA/1MB SPIFFS)" or "No OTA (Large APP)"
- The default partition scheme only provides ~1.2MB for app code, which is not enough for Bluetooth libraries
- This setting gives ~3MB by sacrificing the OTA (over-the-air update) partition
Debug Tips
Add comprehensive debugging:
Project Ideas
Motor Control
- Servo position knob
- Stepper motor angle selector
- Motor speed dial
- Robotic arm joint control
Display Projects
- Compass heading display
- Analog clock hands
- Wind direction indicator
- Dial gauge simulator
Audio Projects
- Volume control knob
- Tone frequency selector
- Equalizer band control
- Radio tuner dial
Lighting Projects
- LED ring position control
- Color wheel (hue selector)
- Spotlight direction control
- Stage lighting angle
Integration with Other Bluetooth Apps
Combine with Bluetooth Slider
Use rotator for angle and slider for speed/intensity:
Combine with Bluetooth Table
Display rotator data in a structured table:
Next Steps
After mastering the Bluetooth Rotator example, try:
- Bluetooth Joystick - For 2D directional control
- Bluetooth Slider - For linear value control
- Bluetooth Analog Gauge - For gauge-style feedback display
- Multiple Bluetooth Apps - Combining rotator with other controls
Support
For additional help:
- Check the API Reference documentation
- Visit DIYables tutorials
- Arduino community forums