ESP32 UNO - DIYables Bluetooth App Rotator

Overview

Turn your phone into a wireless dial for the ESP32 Uno with the Bluetooth rotator app. You drag a disc on the screen, and the ESP32 Uno form board gets the angle as a number from 0 to 360 degrees. Use that knob angle to point a servo, set a stepper position or change a volume level. The board can link by BLE (Android and iPhone) or by Classic Bluetooth (Android).

By the end, you can:

  1. Install the DIYables Bluetooth library in Arduino IDE
  2. Flash a BLE or a Classic Bluetooth rotator sketch to the board
  3. Link the phone app and read each knob angle in the Serial Monitor
  4. Switch between a free 360° spin and a fixed angle window
  5. Drive a servo, a PWM output or a stepper driver from the angle
ESP32 Uno Bluetooth rotator

※ NOTE THAT:

The ESP32 Uno chip carries two Bluetooth radios: BLE and Classic. BLE is the pick when an iPhone must connect, and it needs no pairing step. Classic Bluetooth runs on Android phones only and asks you to pair in the phone settings first.

What the Rotator App Gives You

Use this table to see what the app does for you and what your sketch still handles.

Feature Details
On-screen disc You touch it and drag it in a circle, like a real knob
Free spin mode ROTATOR_MODE_CONTINUOUS goes all the way to 360° and wraps to 0°
Window mode ROTATOR_MODE_LIMITED keeps the angle between a min and a max, such as 0° to 180°
Angle data A float value reaches the board each time the disc moves
Two-way sync The board can push an angle back, so the disc shows the real position
Radio choice BLE for Android and iOS, Classic Bluetooth for Android only
Power BLE uses less current than Classic Bluetooth

Components You Need

1×ESP32 Uno-form Board
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×(optional) Servo Motor
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

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 .

Buy Note: For controlling multiple servo motors, use the PCA9685 16 Channel PWM Servo Driver Module to save MCU pins and simplify wiring.

ESP32 Uno Pinout

Your sketch never uses the printed Uno labels. It uses the GPIO number behind each label, so look it up on this map before you add a servo or a driver.

ESP32 Uno pinout diagram

Good to know: the main rotator sketch needs no wires. The optional servo signal goes to D9 (GPIO13), so SERVO_PIN in the code is 13.

Servo Wire ESP32 Uno Pin
Red (VCC) 5V
Brown (GND) GND
Orange (Signal) D9 (GPIO13)

Upload and Test the ESP32 Uno Code

At the end of this part, the board shows up on your phone and every knob move prints a new angle.

Step 1 — Prepare Arduino IDE

  1. First time with this board? Set it up with ESP32 Uno - Getting Started before you continue.
  2. Build the circuit by following the wiring table above. For the first run, you can leave every pin free.
  3. Plug in the USB Type-C cable between the ESP32 Uno and your computer.
  4. Select the board in Arduino IDE: pick ESP32 Dev Module and the COM port of the board (CH340).
  5. Give Bluetooth more flash: in the menu bar, go to Tools > Partition Scheme and choose Huge APP (3MB No OTA/1MB SPIFFS). The normal layout keeps only about 1.2 MB for your program.
  6. Find the book-shaped Libraries icon in the left toolbar and click it.
  7. Type "DIYables Bluetooth" in the search box and find the entry by DIYables.
  8. Press Install.
  • Search for DIYables Bluetooth created by DIYables and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Library Manager
Type:
All
Topic:
All
DIYables Bluetooth by DIYables
A comprehensive Bluetooth library that connects Arduino to the DIYables Bluetooth STEM mobile app (Android & iOS) via BLE and Classic Bluetooth. Features 11 built-in apps: Monitor, Chat, Digital Pin Control, Joystick, Sliders, Plotter, Analog Gauge, Rotator, Temperature, RTC, and Data Table. Clean architecture with platform abstraction. Works with Arduino Uno R4 WiFi, Arduino Nano 33 BLE, ESP32, and other BLE-capable boards. No mobile coding required. More info
1.0.1
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32 Dev Module on COM15
1
  1. Add the helper libraries: a dialog lists more packages. Press Install All.

Now upload ONE of the sketches below. They show the same knob. Only the radio type differs.

Step 2 — Option A: ESP32 Uno Classic Bluetooth Sketch (Android only)

Good to know: an iPhone cannot see a Classic Bluetooth device. iOS users go to Option B.

  1. Open the example: File Examples DIYables Bluetooth Esp32Bluetooth_Rotator, or paste the code below into an empty sketch.
/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-diyables-bluetooth-app-rotator */ /* * DIYables Bluetooth Library - ESP32 Uno Classic Bluetooth Rotator sketch * Pairs with the DIYables Bluetooth STEM app on Android phones * Note: iPhones have no Classic Bluetooth. Load the BLE sketch when you need iOS. * * What this sketch shows: * - a round knob on the phone that reports 0 to 360 degrees * - free spinning or a fixed angle window * - a good base for a servo, a compass dial or a volume control * * Board: ESP32 Uno form board (Arduino IDE board "ESP32 Dev Module") * * Tip: pick Tools > Partition Scheme > "Huge APP (3MB No OTA/1MB SPIFFS)" * because the Bluetooth code is too big for the default partition * * Extra part (not required): a servo motor that follows the knob * * How to try it: * 1. Upload this sketch to the ESP32 Uno * 2. Open the Serial Monitor at 115200 baud to follow the link status * 3. Connect with the DIYables Bluetooth App and turn the knob * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothRotator.h> #include <platforms/DIYables_Esp32Bluetooth.h> // Classic Bluetooth link with the name shown on the phone, plus the server on top DIYables_Esp32Bluetooth bluetooth("ESP32_Rotator"); DIYables_BluetoothServer bluetoothServer(bluetooth); // the Rotator screen of the app // Choice 1: free spin, the angle wraps after 360 // DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_CONTINUOUS); // Choice 2: the angle stays inside a min/max window DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_LIMITED, 0, 180); // last angle received from the phone float currentAngle = 0.0; // Extra servo part (remove the // marks after you install ESP32Servo) // #include <ESP32Servo.h> // Servo myServo; // const int SERVO_PIN = 13; // D9 (GPIO13) carries the servo signal void setup() { Serial.begin(115200); delay(1000); Serial.println("DIYables Bluetooth - ESP32 Rotator Example"); // Extra servo part: attach it and park it at 0 degrees // myServo.attach(SERVO_PIN); // myServo.write(0); bluetoothServer.begin(); bluetoothServer.addApp(&bluetoothRotator); bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); bluetoothRotator.send(currentAngle); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); }); bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; Serial.print("Rotator angle: "); Serial.print(angle); Serial.println("°"); // TODO: put your own action for the new angle here // Ideas: // - Servo control: myServo.write((int)angle); // - Stepper motor: stepper.moveTo(angleToSteps(angle)); // - LED ring: setLEDPosition(angle); // - Volume control: setVolume(map(angle, 0, 360, 0, 100)); }); Serial.println("Waiting for Bluetooth connection..."); } void loop() { bluetoothServer.loop(); delay(10); }
  1. Flash it: click the arrow-shaped Upload button.
  2. Start the Serial Monitor at 115200 baud. After a reset it prints:
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
DIYables Bluetooth - ESP32 Rotator Example Waiting for Bluetooth connection...
Ln 11, Col 1
ESP32 Dev Module on COM15
2

Step 2 — Option B: ESP32 Uno BLE Sketch (Android and iOS)

  1. Open the example: File Examples DIYables Bluetooth Esp32BLE_Rotator, or paste the code below.
/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-diyables-bluetooth-app-rotator */ /* * DIYables Bluetooth Library - ESP32 Uno BLE Rotator sketch * Talks to the DIYables Bluetooth STEM app on Android phones and iPhones * * What this sketch shows: * - a round knob on the phone that reports 0 to 360 degrees * - free spinning or a fixed angle window * - a good base for a servo, a compass dial or a volume control * * Board: ESP32 Uno form board (Arduino IDE board "ESP32 Dev Module") * * Tip: pick Tools > Partition Scheme > "Huge APP (3MB No OTA/1MB SPIFFS)" * because the Bluetooth code is too big for the default partition * * Extra part (not required): a servo motor that follows the knob * * How to try it: * 1. Upload this sketch to the ESP32 Uno * 2. Open the Serial Monitor at 115200 baud to follow the link status * 3. Connect with the DIYables Bluetooth App and turn the knob * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothRotator.h> #include <platforms/DIYables_Esp32BLE.h> // BLE name and UUIDs that the app looks for const char* DEVICE_NAME = "ESP32BLE_Rotator"; 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"; // BLE link object and the server that runs on top of it DIYables_Esp32BLE bluetooth(DEVICE_NAME, SERVICE_UUID, TX_UUID, RX_UUID); DIYables_BluetoothServer bluetoothServer(bluetooth); // the Rotator screen, held between 0 and 180 degrees DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_LIMITED, 0, 180); // last angle received from the phone float currentAngle = 0.0; void setup() { Serial.begin(115200); delay(1000); Serial.println("DIYables Bluetooth - ESP32 BLE Rotator Example"); bluetoothServer.begin(); bluetoothServer.addApp(&bluetoothRotator); bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); bluetoothRotator.send(currentAngle); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); }); bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; Serial.print("Rotator angle: "); Serial.print(angle); Serial.println("°"); // TODO: put your own action for the new angle here }); Serial.println("Waiting for Bluetooth connection..."); } void loop() { bluetoothServer.loop(); delay(10); }
  1. Upload it.
  2. Start the Serial Monitor at 115200 baud:
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
DIYables Bluetooth - ESP32 BLE Rotator Example Waiting for Bluetooth connection...
Ln 11, Col 1
ESP32 Dev Module on COM15
2
  1. Pro tip: the Classic sketch already holds the servo lines as comments. Delete the // marks in front of them after you install ESP32Servo, and the servo follows the knob with no other change.

Step 3 — Connect the Phone App

When this step is done, the knob on your phone talks to the board.

  1. Get the app: DIYables Bluetooth App for Android or iOS.
  2. Classic sketch only — pair first: on the Android phone open Settings > Bluetooth, switch it on, tap "ESP32_Rotator", accept (no PIN), and wait until "Paired" shows. With the BLE sketch, skip this.
  3. Start the app and allow the access it asks for on first launch:
    • Nearby Devices (Android 12 or newer) or Bluetooth (iOS) — needed to find and join devices
    • Location (Android 11 or older) — old Android needs it for a BLE scan
  • Make sure phone Bluetooth is on.
  • Scan: tap Connect on the home screen. BLE and Classic devices both appear.
  • DIYables Bluetooth App - Home Screen with Scan Button
    1. Choose your board: "ESP32_Rotator" for Classic, or "ESP32BLE_Rotator" for BLE. After the link is up, the app jumps back to the home screen.
    2. Open the knob: tap Rotator in the app menu.
    DIYables Bluetooth App - Home Screen with Rotator App
    1. Turn it: drag the disc around with one finger.
    DIYables Bluetooth App - Rotator Screen
    1. Pro tip: the gear icon on the home screen hides the apps you do not need. Every screen is covered in the DIYables Bluetooth App User Manual.

    Look at the Serial Monitor again. The link message and each new angle appear there:

    ∞
    Newbiely | Arduino IDE 2.3.8
    ──
    ☐
    ✕
    File
    Edit
    Sketch
    Tools
    Help
    ESP32 Dev Module
    Newbiely.ino
    ···
    8 Serial.println("Hello World!");
    Output
    Serial Monitor
    Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
    New Line
    9600 baud
    Bluetooth connected! Rotator angle: 27.50° Rotator angle: 63.00° Rotator angle: 118.25° Rotator angle: 164.75°
    Ln 11, Col 1
    ESP32 Dev Module on COM15
    2

    How the Sketch Works

    Here is the job of each part in the ESP32 Uno rotator sketch.

    Code Part What It Does
    DIYables_Esp32BLE or DIYables_Esp32Bluetooth Starts the radio under the name the phone lists
    DIYables_BluetoothRotator(ROTATOR_MODE_LIMITED, 0, 180) Creates the knob and holds it inside 0° to 180°
    addApp(&bluetoothRotator) Puts the Rotator screen on the Bluetooth server
    setOnConnected() Sends the last known angle as soon as a phone links
    onRotatorAngle() Runs each time the disc moves and stores the new angle
    bluetoothServer.loop() Handles incoming data, so call it often in loop()

    The result is a knob that always opens at the right position and reports every move at once.

    ESP32 Uno vs UNO R4 for This Project

    Moving this rotator from the UNO R4 WiFi to the ESP32 Uno swaps the radio library and the servo library, and adds a second Bluetooth mode.

    Item Arduino UNO R4 WiFi ESP32 Uno
    Logic voltage 5V 3.3V
    Bluetooth BLE only BLE and Classic Bluetooth
    Library platform file DIYables_ArduinoBLE.h DIYables_Esp32BLE.h or DIYables_Esp32Bluetooth.h
    Servo library Servo.h ESP32Servo.h
    Servo signal pin D9 D9 (GPIO13)
    Arduino IDE board Arduino UNO R4 WiFi ESP32 Dev Module with Huge APP partition

    The servo stays on the same D9 header spot, so the wiring does not move. The 3.3V signal out of the board drives most hobby servos fine. Just never send a 5V signal back into an ESP32 Uno pin.

    Shape the Knob for Your Project

    At the end of this part, the knob behaves the way your build needs.

    Pick a Mode

    The mode is set by the constructor. A call to setRotatorMode() swaps it at run time, and three getters report what is active.

    // Choice 1: free spin from 0 to 360°, then it wraps DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_CONTINUOUS); // Choice 2: angle kept inside a min/max window DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_LIMITED, 0, 180); // switch the mode while the sketch runs bluetoothRotator.setRotatorMode(ROTATOR_MODE_LIMITED, 0, 270); // read back the settings in use int mode = bluetoothRotator.getRotatorMode(); float minAngle = bluetoothRotator.getMinAngle(); float maxAngle = bluetoothRotator.getMaxAngle();

    React to a New Angle

    Put your own action inside onRotatorAngle(). The app calls it for every move of the disc.

    bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; Serial.print("Rotator angle: "); Serial.print(angle); Serial.println("°"); // your own action goes here });

    Reply When the App Asks for the State

    The app may request the current state when the Rotator screen opens. Answer with the stored angle.

    bluetoothRotator.onGetConfig([]() { // hand the stored angle back to the phone bluetoothRotator.send(currentAngle); Serial.println("App requested config - sent current angle"); });

    Move the Disc from the Board

    The ESP32 Uno can turn the disc on the phone by itself, or send a short text.

    // turn the disc on the phone to 90° bluetoothRotator.send(90.0); // show a short text in the app bluetoothRotator.send("Calibrated");

    Watch Link Events

    These two callbacks fire when a phone joins or leaves. Pushing the angle on join keeps both sides equal.

    bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); bluetoothRotator.send(currentAngle); // tell the app where the knob is }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); });

    Reading the Knob Screen

    Use this table to know each part of the Rotator screen.

    Screen Part Meaning
    Round disc Drag it in a circle to set the angle
    Number in the center The angle the app sends right now
    Marker on the edge Points at the current position
    Mode value 0 ROTATOR_MODE_CONTINUOUS, a full turn that wraps back to 0°
    Mode value 1 ROTATOR_MODE_LIMITED, the angle stops at the min and max

    Real Output Examples

    Each block below is a part of a sketch. Add it to the full BLE or Classic example from above.

    Example 1 — Servo on D9

    Window mode from 0° to 180° fits a hobby servo, so the angle goes straight to write(). First add "ESP32Servo" (author Kevin Harrington) from Library Manager, because the classic Servo library will not compile for the ESP32 Uno. Wire the servo as shown in the pinout section: signal to D9 (GPIO13), red to 5V, brown to GND.

    #include <ESP32Servo.h> Servo myServo; const int SERVO_PIN = 13; // D9 (GPIO13) sends the servo pulse void setup() { myServo.attach(SERVO_PIN); myServo.write(0); // the 0 to 180° window already matches the servo travel // (bluetoothRotator is created as ROTATOR_MODE_LIMITED, 0, 180) bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; myServo.write((int)angle); Serial.print("Servo: "); Serial.print((int)angle); Serial.println("°"); }); }

    For a pan-tilt head, put the second (tilt) servo on D10 (GPIO5) and drive it from another control, for example a Bluetooth slider.

    WARNING

    The chip checks D10 (GPIO5) at power-up to decide how to boot. A servo signal wire there is normally fine, but if the board will not start or upload with the tilt servo attached, unplug that signal wire during upload and plug it back in after.

    Example 2 — Brightness or Volume Dial on D5

    The knob spins freely here. The code turns 0–360° into a PWM duty of 0–255 and also prints a percentage. Wire an LED with a 220Ω resistor, or any PWM input, to D5 (GPIO16).

    const int PWM_PIN = 16; // D5 (GPIO16) outputs the PWM signal void setup() { pinMode(PWM_PIN, OUTPUT); // free spin: one full turn covers 0 to 255 bluetoothRotator.setRotatorMode(ROTATOR_MODE_CONTINUOUS); bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; int pwmValue = map((int)angle, 0, 360, 0, 255); analogWrite(PWM_PIN, pwmValue); int percentage = map((int)angle, 0, 360, 0, 100); Serial.print("Volume: "); Serial.print(percentage); Serial.println("%"); }); }

    Example 3 — Compass Needle on the Phone

    Now data goes from the board to the phone. Every 500 ms the board reads a heading and turns the disc to match. A compass talks over I2C. On this board that bus lives on the SDA (GPIO21) and SCL (GPIO22) header pins, while A4/A5 are plain analog inputs.

    // get a heading from the compass and return it in degrees float getCompassHeading() { // TODO: read an HMC5883L, QMC5883L or BMM150 here // give back a value from 0 to 360 return 0.0; } void loop() { bluetoothServer.loop(); static unsigned long lastUpdate = 0; if (millis() - lastUpdate >= 500) { lastUpdate = millis(); float heading = getCompassHeading(); bluetoothRotator.send(heading); // turn the disc to the heading } delay(10); }

    Example 4 — Stepper Driver on D5 and D4

    A STEP/DIR driver such as an A4988 can follow the knob. The code changes the angle into a step target for a 200-step motor, and stepper.run() moves it there. Wire STEP to D5 (GPIO16) and DIR to D4 (GPIO17).

    #include <AccelStepper.h> AccelStepper stepper(AccelStepper::DRIVER, 16, 17); // STEP on D5 (GPIO16), DIR on D4 (GPIO17) const int STEPS_PER_REV = 200; void setup() { stepper.setMaxSpeed(1000); stepper.setAcceleration(500); bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; // turn degrees into a step count long targetSteps = (long)(angle / 360.0 * STEPS_PER_REV); stepper.moveTo(targetSteps); Serial.print("Stepper target: "); Serial.print(targetSteps); Serial.println(" steps"); }); } void loop() { bluetoothServer.loop(); stepper.run(); delay(1); }

    Smarter Angle Handling

    Snap to 15° Steps

    The code rounds each angle to the closest multiple of 15° and sends it back, so the disc clicks into neat spots.

    bluetoothRotator.onRotatorAngle([](float angle) { // round to the closest 15° mark float snapped = round(angle / 15.0) * 15.0; currentAngle = snapped; Serial.print("Snapped angle: "); Serial.print(snapped, 0); Serial.println("°"); // move the disc in the app to the rounded value bluetoothRotator.send(snapped); });

    Four Zones, Four Colors

    Split the circle into quarters and run a different action in each. Here each quarter gives an RGB LED a new color. Write a setColor() function that fits your LED.

    bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; // one quarter of the circle per zone if (angle < 90) { Serial.println("Zone: NORTH"); setColor(0, 0, 255); // blue } else if (angle < 180) { Serial.println("Zone: EAST"); setColor(0, 255, 0); // green } else if (angle < 270) { Serial.println("Zone: SOUTH"); setColor(255, 0, 0); // red } else { Serial.println("Zone: WEST"); setColor(255, 255, 0); // yellow } });

    Choosing BLE or Classic on the ESP32 Uno

    The ESP32 Uno runs both sketches. Pick by phone type and power need.

    Point BLE (Esp32BLE_Rotator) Classic (Esp32Bluetooth_Rotator)
    iPhone Works Not possible
    Android Works Works
    Current draw Lower Higher
    Pairing in phone settings Not needed Needed once
    Name in the scan list ESP32BLE_Rotator ESP32_Rotator
    Good fit Battery builds, mixed phones Android-only builds

    Debug Helper

    Call this function inside onRotatorAngle() while you test. It prints the angle, the mode and the window in one block.

    void debugRotatorValue(float angle) { Serial.println("=== Rotator Debug ==="); Serial.println("Angle: " + String(angle, 1) + "°"); Serial.println("Mode: " + String(bluetoothRotator.getRotatorMode() == ROTATOR_MODE_CONTINUOUS ? "Continuous" : "Limited")); Serial.println("Range: " + String(bluetoothRotator.getMinAngle(), 0) + "° - " + String(bluetoothRotator.getMaxAngle(), 0) + "°"); Serial.println("====================="); }

    Build Ideas

    Area Ideas
    Motion Servo pointer, stepper angle picker, motor speed dial, robot arm joint
    Display Compass heading, clock hands, wind vane, dial gauge
    Sound Volume knob, tone pitch picker, equalizer band, radio tuner
    Light LED ring spot, hue color wheel, spotlight aim, stage light tilt

    Mix the Rotator with Other Bluetooth Apps

    Rotator Plus Slider

    The rotator gives the direction and a slider gives the speed. Sine and cosine of the angle, scaled by the speed, give the X and Y drive for a pair of motors.

    float speed = 50; bluetoothSlider.onSliderValue([](int slider1, int slider2) { speed = slider1; }); bluetoothRotator.onRotatorAngle([](float angle) { // mix the direction (angle) with the strength (speed) float radians = angle * PI / 180.0; float x = speed * cos(radians); float y = speed * sin(radians); controlMotors(x, y); });

    Rotator Plus Table

    Show the angle, its quarter and its value in radians as rows on the phone.

    bluetoothRotator.onRotatorAngle([](float angle) { bluetoothTable.sendValueUpdate("Angle", String(angle, 1) + "°"); bluetoothTable.sendValueUpdate("Quadrant", String((int)(angle / 90) + 1)); bluetoothTable.sendValueUpdate("Radians", String(angle * PI / 180.0, 3)); });

    Try These Next

    With the knob working, keep going with these ESP32 Uno pages:

    1. ESP32 Uno - Bluetooth Joystick — steer in two directions at once
    2. ESP32 Uno - Bluetooth Slider — set a value along a straight bar
    3. ESP32 Uno - Bluetooth Analog Gauge — show a reading on a needle dial
    4. ESP32 Uno - Multiple Bluetooth Apps — run the knob next to other screens

    Where to Get Help

    • The API reference that comes with the DIYables Bluetooth library
    • More app guides at diyables.io/bluetooth-app
    • The Arduino community forums

    Troubleshooting

    Problem Possible Cause Solution
    No COM port appears in Arduino IDE CH340 driver missing or a charge-only cable Install the CH340 driver and use a USB Type-C cable that carries data
    Upload stops at "Failed to connect" or "Waiting for download" The board did not enter download mode Hold the BOOT button while the upload starts, then let go
    Board does not boot or upload with the tilt servo on D10 D10 (GPIO5) is a boot strapping pin pulled the wrong way Unplug the module while uploading, or use another pin
    Compiler says the sketch is too big Default partition has no room for Bluetooth Choose Tools > Partition Scheme > Huge APP (3MB No OTA/1MB SPIFFS)
    Board name is missing in the app scan Sketch not running, phone Bluetooth off, or Classic not paired Check the Serial Monitor shows "Waiting for Bluetooth connection...", pair ESP32_Rotator first for Classic, and turn on Location on Android 11 or older
    ESP32_Rotator never shows on an iPhone iOS has no Classic Bluetooth Upload the BLE sketch and pick ESP32BLE_Rotator
    Compile error about Servo.h The standard Servo library has no support for this chip Install ESP32Servo and use the line #include
    Servo shakes or the board resets when it moves Servo draws too much current from the 5V pin Power the servo from a separate 5V supply, join the grounds, and add a 100µF capacitor across its power wires
    Angle stops at 180° The knob is in window mode Use ROTATOR_MODE_CONTINUOUS or raise the max with setRotatorMode()
    Serial Monitor prints garbled symbols Baud rate in the monitor does not match the sketch Pick 115200 in the drop-down at the bottom of the monitor

    FAQ

    BLE or Classic Bluetooth — which sketch fits my ESP32 Uno rotator build?

    Load the BLE sketch if anyone uses an iPhone or if you want to skip pairing. Load the Classic sketch if all users have Android phones. The knob and the Serial Monitor output are the same in both.

    Is the angle a whole number or a decimal?

    It is a float, so you get decimals such as 63.25°. A servo only takes whole degrees, so the examples cast it with (int)angle. Keep the float when you need fine steps, for example for a stepper.

    Can the board turn the knob on the phone by itself?

    Yes. Call bluetoothRotator.send(angle) with any value, and the disc moves to it. The compass example uses this to show a live heading.

    Why does the servo code use ESP32Servo and not Servo.h?

    The standard Servo library has no timer code for the ESP32 Uno chip, so it does not compile. ESP32Servo by Kevin Harrington gives the same attach() and write() calls. Your servo logic stays the same.

    Can a 5V servo run from the ESP32 Uno?

    Yes. Feed the servo from the 5V pin or an outside 5V supply, and connect its signal to D9 (GPIO13). The 3.3V pulse is enough for most hobby servos. A big or loaded servo needs its own supply with a shared ground.

    Do I need a driver to upload to the ESP32 Uno?

    The board talks to the computer through a CH340 USB-to-serial chip. Some Windows and macOS computers need the CH340 driver before the COM port shows. Install it once, then plug the cable in again.

    Can I keep my old UNO R4 rotator sketch?

    Not as it is. The UNO R4 WiFi sketch includes DIYables_ArduinoBLE.h. On the ESP32 Uno, include DIYables_Esp32BLE.h (or DIYables_Esp32Bluetooth.h for Classic) and set the baud rate to 115200. The rotator calls themselves do not change.

    Can I put a second servo on D10 for a pan-tilt head?

    You can, and D10 maps to GPIO5. That pin is a boot strapping pin, so a strong pull on it at power-up can stop the boot. A servo signal is usually fine. If the board hangs, unplug the signal during reset or upload.

    Will an Uno servo shield fit the ESP32 Uno?

    The header shape is the same, so the shield fits. Check that the shield does not push 5V into a signal pin, and that it does not need A4/A5 for I2C, because on this board I2C is on the SDA (GPIO21) and SCL (GPIO22) pins.

    My rotator build needs more pins than the Uno headers give. What can I use?

    The ESP32 Uno has a few extra holes near the power header: GPIO32 and GPIO33 (I/O, PWM, analog on ADC1, so they still read while WiFi is on) and GPIO15 (I/O, PWM, analog on ADC2). Solder a pin header into the hole and use its GPIO number in code. For an extra servo or a stepper DIR line, GPIO32 or GPIO33 is the best choice. Two warnings apply. First, GPIO15 and GPIO0 (the IO0 pin at the unused Uno NC position) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code, so use GPIO32/33 first. Second, never use the six holes under the digital header (SD0 to SD3, CMD, CLK = GPIO6 to GPIO11), because they go to the flash chip and using them crashes the board.

    Can I turn the same servo from a web page instead?

    Yes. The ESP32 Uno also has WiFi. The ESP32 Uno - Web Rotator page draws the same kind of knob in a browser and moves a servo with it.

    ※ 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!