Arduino Nano ESP32 - Web Apps Web Rotator
Overview
This tutorial covers the DIYablesWebRotatorPage class from the DIYables ESP32 WebApps Library. The browser page renders a draggable disc that reports its current angle to the Arduino Nano ESP32 over WebSocket. The disc operates in either a continuous (0–360°) or a limited-range mode. The configuration is set in the constructor and sent to the browser automatically on connection.

Watch this step-by-step video tutorial demonstrating how to use a servo motor with the Web Rotator app:
What This Tutorial Covers
- Selecting between continuous and limited rotation modes
- Receiving angle values in a sketch callback
- Driving a servo motor from the reported angle
- Supplying the current angle to newly connected browsers
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
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.
Steps
Follow these instructions step by step:
- If this is your first time using the Arduino Nano ESP32, refer to the tutorial on setting up the Arduino Nano ESP32 development environment.
- Connect the Arduino Nano ESP32 board to your computer using a USB cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate board (e.g. Arduino Nano ESP32) and COM port.
- Navigate to the Libraries icon on the left bar of the Arduino IDE.
- Search "DIYables ESP32 WebApps", then find the DIYables ESP32 WebApps Library by DIYables
- Click Install button to install the library.
- Search for DIYables ESP32 WebApps created by DIYables and click the Install button.
- You will be asked for installing some other library dependencies
- Click Install All button to install all library dependencies.
- On Arduino IDE, Go to File Examples DIYables ESP32 WebApps WebRotator example, or copy the above code and paste it to the editor of Arduino IDE
- Update the WiFi credentials in the sketch:
- Click Upload button on Arduino IDE to upload code to Arduino Nano ESP32
- Open the Serial Monitor
- The Serial Monitor output should resemble the following:
- If nothing appears, press the reset button on the board.
- Enter the IP address from the Serial Monitor into a browser on the same network.
- Example: http://192.168.0.2
- The home page shows a card for the rotator application:

- Select the Web Rotator card to open the disc control page:

- The page is also directly accessible at http://192.168.0.2/web-rotator.
- Drag the disc and observe the angle reported in the Serial Monitor.
Rotation Modes
Continuous Mode (full 0–360°)
Limited-Range Mode
Callbacks
Receiving Angle Updates
Called each time the user rotates the disc:
Supplying Angle to the Browser
Called when a browser connects and requests the current angle:
Servo Motor Example
Map the browser angle (0–180°) to a standard servo:
Troubleshooting
Disc angle does not trigger the callback
- Confirm onRotatorValueFromWeb is registered before webAppsServer.begin()
- Verify the WebSocket status in the browser shows "connected"
Servo moves to wrong position
- Check that the angle range matches the servo's physical range (typically 0–180°)
- Use limited-range mode when the mechanical range is less than 360°
Page not reachable
- Verify the IP address from the Serial Monitor
- Ensure both the board and browser device are on the same 2.4 GHz network