ESP32 UNO - DIYables Bluetooth App Chat
Overview
Text your project from your phone: an ESP32 Uno Bluetooth chat turns the DIYables Bluetooth App into a pocket terminal for your board. The ESP32 Uno form board carries both a BLE radio and a Classic Bluetooth radio, so the same chat screen works as a wireless serial monitor on iPhone and Android. Words you type become commands, and the board writes its answers back into the chat list.
By the end, you can:
- Install the DIYables Bluetooth library and flash a chat sketch
- Pick BLE or Classic Bluetooth for your phone
- Reply to text commands such as ping, status and LED ON
- Forward Serial Monitor lines to the phone for cable-free debugging
- Switch an LED, relays, a servo or a motor by typing words

Two radios, two sketches
| Sketch | Radio | Phones | Pairing |
|---|---|---|---|
| Esp32BLE_Chat | BLE (Bluetooth Low Energy) | Android and iOS | None, connect inside the app |
| Esp32Bluetooth_Chat | Classic Bluetooth | Android only | One time, in the phone settings |
Good to know: an iPhone never shows Classic Bluetooth hobby boards. If anyone on your team uses iOS, start with the BLE sketch.
Features
This list shows what the chat sketches do before you change a single line.
| Feature | What You Get | |
|---|---|---|
| Text in both directions | Phone to board and board to phone, with no visible delay | |
| Echo reply | Each message comes back as "Echo | ..." so you know the link is alive |
| Ready commands | ping, status, time and heap already have answers | |
| Timed status line | A new status message lands every 10 s while a phone is linked | |
| Serial Monitor bridge | A line typed in Arduino IDE shows up in the app chat | |
| Radio choice | BLE for iOS and low power, Classic Bluetooth for Android-only builds |
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: Use the LED Module for easier wiring. It includes an integrated resistor.
The two chat sketches need only the board and the cable. The LED, resistor, breadboard and wires are for the video demo, where chat words switch an LED.
ESP32 Uno Pinout
The chat itself uses no pins, since the radio lives inside the chip. Once you hook up LEDs, relays or a servo for the command examples, use this diagram to turn each Uno header label into the GPIO number your code needs.

ESP32 Uno Code
By the end of this part, the DIYables Bluetooth library sits in Arduino IDE and a chat sketch runs on the board.
Detailed Instructions
- First time with this board? Set it up with ESP32 Uno - Getting Started before you continue.
- Plug in the USB Type-C cable between the ESP32 Uno and your computer.
- Select the board in Arduino IDE: pick ESP32 Dev Module and the COM port of the board (CH340).
- Open the Library Manager with the Libraries icon in the left bar.
- Type "DIYables Bluetooth" in the search box; the entry by DIYables is the one you want.
- Press Install on that entry.
- Search for DIYables Bluetooth created by DIYables and click the Install button.
- Accept the extras. A popup lists the helper libraries; press Install All there.
- Make room for the code. Bluetooth sketches are large, so set Tools > Partition Scheme to Huge APP (3MB No OTA/1MB SPIFFS) first.
Now pick one radio mode below. Upload only one of the two sketches.
Classic Bluetooth Sketch (Android phones only)
WARNING
Classic Bluetooth does not reach iPhones. For iOS, jump to the BLE sketch.
This sketch shows up on the phone as ESP32_Chat. It echoes each message, answers four commands, and sends a status line every 10 s.
- Get the code from File Examples DIYables Bluetooth Esp32Bluetooth_Chat, or paste the code below into a new sketch.
- Press Upload and wait for "Done uploading".
- Open the Serial Monitor at 115200 baud.
- Read the start lines:
BLE Sketch (Android and iOS)
Over BLE, the board calls itself ESP32BLE_Chat. It does the same work as the Classic one, over Bluetooth Low Energy.
- Get the code from File Examples DIYables Bluetooth Esp32BLE_Chat, or paste the code below into a new sketch.
- Press Upload and let it finish.
- Open the Serial Monitor at 115200 baud.
- Read the start lines:
- Pro tip: the start lines print only once, right after boot. If you opened the Serial Monitor too late, press the RST button and they appear again.
Mobile App
By the end of this part, your phone is linked and the Chat screen is open.
Step 1 — Install the app
Get the DIYables Bluetooth App: Android | iOS
Step 2 — Pair (Classic Bluetooth only)
Skip this step for the BLE sketch. For the Classic sketch, pair the board on your Android phone before you open the app:
- Open Settings > Bluetooth and switch Bluetooth on.
- When the list fills, choose "ESP32_Chat".
- Accept the request. No PIN is asked.
- Check that the phone now lists it as "Paired".
Step 3 — Allow permissions
Open the app. On the first start it asks for:
- Nearby Devices (Android 12 and newer) or Bluetooth (iOS), so it can scan and connect
- Location (Android 11 and older only), because older Android needs it for BLE scans
Step 4 — Connect
Turn on Bluetooth on the phone. Then press Connect; one scan finds BLE and Classic boards together.

Tap the name that matches your sketch:
| Sketch | Name in the Scan List |
|---|---|
| Classic Bluetooth | ESP32_Chat |
| BLE | ESP32BLE_Chat |
Step 5 — Open Chat
After the link is up, the app returns to the home screen. Pick the Chat tile from the menu.

※ NOTE THAT:
The settings icon on the home screen hides or shows app tiles. The DIYables Bluetooth App User Manual explains every screen.
Step 6 — Send text
Type a word in the box and tap Send.

Switch back to the Serial Monitor. A short session looks like this:
Now send each ready word in turn: ping, status, time, heap. Then type a line in the Serial Monitor, press Enter, and watch it land in the phone chat.
Video Tutorial
See the ESP32 Uno build in action in the video below.
The demo sketch switches an LED from the chat, blinks it, and reports its state. The Uno headers of this board have no built-in LED, so the demo uses an external LED on D13 (GPIO18).
| LED Pin | ESP32 Uno Pin |
|---|---|
| Anode (long leg) through a 220 ohm resistor | D13 (GPIO18) |
| Cathode (short leg) | GND |
Send HELP in the app to list the demo words: LED ON, LED OFF, STATUS, UPTIME and BLINK.
Shape the Chat Code for Your Build
By the end of this part, you know the four building blocks behind every chat project.
| Code Part | What It Does |
|---|---|
| bluetoothChat.onChatMessage() | Runs your code each time a text arrives from the app |
| bluetoothChat.send() | Pushes a text line to the phone at any moment |
| setOnConnected() / setOnDisconnected() | Runs your code when the phone links or drops |
| Serial.available() block in loop() | Moves Serial Monitor lines to the chat |
Receive Messages from App
Compare the incoming text with your own words and act on it. This snippet drives an LED on D13 (GPIO18):
Each extra else if adds one more word. Try FAN_ON / FAN_OFF for a fan relay, or READ to answer with a sensor value. Put pinMode(18, OUTPUT); in setup() first.
Send Messages to App
The board does not have to wait for a question. Use send() for alerts, values and progress notes.
Handle Connection Events
Send a hello as soon as a phone links, so the person sees the board is awake.
Serial-to-Bluetooth Bridge
This loop() takes one line from the Serial Monitor and passes it to the phone.
The result: you get a two-way text link with only these four parts, and the rest of your sketch stays free for your own job.
Using the Chat Screen
This part maps the chat screen and the words the example already knows.
App Interface Controls
| Screen Part | Job |
|---|---|
| Message list | Scrolls through every line you sent and got |
| Text box | Holds the text you are typing, at the bottom |
| Send button | Ships the text to the board |
| Auto-scroll | Keeps the newest line in view |
Built-in Commands
Case does not matter for these words.
| Command | Answer from the Board |
|---|---|
| ping | pong! |
| status | A short "running normally" line |
| time | Seconds since the last reset |
| heap | Bytes of RAM still free |
ESP32 Uno vs UNO R4 for This Project
Moving this chat from the UNO R4 WiFi to the ESP32 Uno changes the platform file and adds a second radio choice.
| Item | Arduino UNO R4 WiFi | ESP32 Uno |
|---|---|---|
| Logic voltage | 5V | 3.3V |
| Bluetooth types | BLE only | BLE and Classic Bluetooth |
| Platform header | DIYables_ArduinoBLE.h | DIYables_Esp32BLE.h or DIYables_Esp32Bluetooth.h |
| Serial baud rate | 9600 | 115200 |
| Demo LED | LED_BUILTIN | External LED on D13 (GPIO18) |
| Arduino IDE board | Arduino UNO R4 WiFi | ESP32 Dev Module plus Huge APP partition |
The chat callbacks are the same on both boards, so your command logic copies over as-is. Only the include line, the class name and the pin numbers change. Feed any 5V module output through a level shifter, because ESP32 Uno pins are not 5V tolerant.
Programming Examples
Each block below drops into the chat sketch. The Uno header label sits in the comment, and the GPIO number goes in the code.
Basic Echo Chat
The smallest chat: every message comes straight back. Use it to prove both directions work.
Command-Based LED Control
Here a plain LED sits on D13, and the three legs of an RGB LED use D9, D6 and D5. Send HELP for the word list.
Sensor Query System
The phone asks, the board answers. A DHT22 data line on D2 (GPIO26) gives temperature and humidity on request.
Good to know: run the DHT22 from the 3V3 pin. Then its data line never goes above 3.3V.
Relay Control with Confirmation
Relay 1 on D7 (GPIO14) and relay 2 on D4 (GPIO17). Each command gets a reply, so you know it arrived.
※ NOTE THAT:
Pick a relay module whose IN pin switches with a 3.3V signal. Many 5V relay boards do, but check the module page first.
Advanced Programming Techniques
These blocks add timed reports, a log, commands with values, and a debug helper.
Periodic Status Updates
A status line goes out every 10 s, only while a phone is linked. It adds uptime and free heap.
Message Logging
Each incoming line and each reply gets a seconds stamp in the Serial Monitor. A helper builds the answer.
Command Parser with Arguments
This parser splits "WORD VALUE" text, like "PWM 90". PWM comes out on D3 (GPIO25). For the PIN word, type the GPIO number: "PIN 18 HIGH" lights D13 (GPIO18).
WARNING
Keep the PIN word away from GPIO6 to GPIO11 (flash chip), GPIO1 and GPIO3 (USB serial), and the input-only pins GPIO34, 35, 36 and 39. Writing to the flash pins crashes the ESP32 Uno.
Debug Helper
Call this at the top of your chat handler when replies look wrong. It prints the text, its length and the free heap.
Hardware Integration Examples
Plain words can move parts too. One block turns a servo, the other drives a DC motor.
Servo Control via Chat
Send a number from 0 to 180, or "SERVO 45", and the horn turns there. "SWEEP" runs it end to end and back. The signal wire goes to D9 (GPIO13). You need the ESP32Servo library (Kevin Harrington) from the Library Manager.
Motor Control via Chat
The driver gets speed from D3 (GPIO25) and direction from D4 (GPIO17) and D5 (GPIO16). Words it knows: FORWARD, REVERSE, STOP, and "SPEED 120" style values.
BLE or Classic Bluetooth on the ESP32 Uno?
The ESP32 Uno runs both radio types, so pick by phone and by power budget.
| Point | BLE sketch | Classic sketch |
|---|---|---|
| iPhone | Works | Not possible |
| Android | Works | Works |
| Current draw | Lower | Higher |
| Typical indoor range | About 10 to 30 m | About 10 m |
| Throughput | Plenty for text | Higher, steady stream |
| Pairing | None, the app connects | Once, in phone settings |
| Best pick for | Battery builds and mixed phones | Android-only builds with lots of text |
Pair Chat with Other App Screens
The library can show several app screens from one sketch. Chat works well as the "control word" screen next to them.
Combine with Bluetooth Monitor
Chat starts and stops the stream; the Monitor screen shows the live value from a sensor on A0 (GPIO2).
Good to know: the ESP32 Uno ADC reads 0 to 4095 (12-bit). The analogSetAttenuation(ADC_11db) line lets A0 read the whole 0 to 3.3V span; without it the value hits 4095 far too early.
WARNING
A0 (GPIO2) is a boot strapping pin. A sensor that pulls it HIGH during reset can stop the upload. Unplug the sensor while you upload if that happens.
Combine with Bluetooth Slider
Chat loads a preset, and the sliders handle fine tuning.
Project Ideas
Pick one of these and build it on top of the chat sketch.
| Area | Ideas |
|---|---|
| Remote control | Text-driven robot, room-by-room light switch, garage door words, servo pointer |
| Monitoring | Ask for plant soil data, daily health report, alarm text on a sensor limit |
| Fun and games | Quiz bot, dice roller, guess-the-number game |
| Learning | String parsing drills, your own command protocol, a tiny chatbot |
Next Steps
Once the chat runs, try another screen of the app on your ESP32 Uno:
- ESP32 Uno - Bluetooth Monitor - stream text lines to the phone
- ESP32 Uno - Bluetooth Slider - set numbers with sliders
- ESP32 Uno - Bluetooth Digital Pins - flip outputs with buttons
- ESP32 Uno - Bluetooth Multiple Apps - run chat beside other screens
- ESP32 Uno - Bluetooth and BLE - the overview of every example
Support
Stuck? Check the DIYables Bluetooth library API reference, the DIYables Bluetooth App tutorials, or post your question in the Arduino forum.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | CH340 driver missing or a charge-only cable | Install the CH340 driver and use a data USB cable |
| Upload stops at "Failed to connect" or "Waiting for download" | Board did not enter download mode | Hold the BOOT button while the upload starts, release it when "Writing" shows |
| Compile ends with a "text section exceeds" size error | Stock 1.2MB app area cannot hold the Bluetooth stack | Switch the partition to Huge APP and compile again |
| Board name missing from the scan list | Sketch not running, phone Bluetooth off, or Location off on old Android | Press RST, turn on Bluetooth (plus Location on Android 11 or older), scan again |
| ESP32_Chat never appears on an iPhone | Classic Bluetooth sketch on iOS | Upload the Esp32BLE_Chat sketch instead |
| App says connected but no reply comes back | Chat screen not open or onChatMessage() not set | Open the Chat tile in the app and check the callback in setup() |
| Garbled text in Serial Monitor | Baud rate mismatch | Set the Serial Monitor to 115200 |
| Serial Monitor text never reaches the phone | Line ending set to No line ending | Choose Newline in the Serial Monitor and connect the app first |
| Demo LED stays dark | LED reversed or wired to the wrong pin | Long leg through 220 ohm to D13 (GPIO18), short leg to GND |
| Board resets when a relay or motor switches | Supply dips under load | Power relays and motors from their own supply and join the grounds |
FAQ
Which chat sketch should I use on the ESP32 Uno, BLE or Classic?
Use Esp32BLE_Chat if any phone in your project is an iPhone, or if you run on a battery. Use Esp32Bluetooth_Chat only for Android phones when you want a paired, steady link. Both sketches give the same chat screen and the same commands.
Why does my iPhone not see ESP32_Chat?
iOS does not let apps talk to Classic Bluetooth serial devices like this one. The BLE sketch shows up as ESP32BLE_Chat and works on iPhones. Upload that sketch and scan again in the app.
How do I rename the board in the scan list?
For BLE, change the DEVICE_NAME text at the top of the sketch. For Classic Bluetooth, change the text inside DIYables_Esp32Bluetooth bluetooth("ESP32_Chat"). Upload again. Give each board its own name if two of them sit near each other.
Can two phones chat with one ESP32 Uno at the same time?
No. The chat sketch serves one phone at a time. When the first phone drops the link, the board waits for the next one, and the setOnDisconnected() callback runs.
How long can one chat message be?
Short commands and status lines work best. BLE sends data in small packets, so keep each message to one short line. Send long reports as several send() calls.
Does Bluetooth need any wiring on the ESP32 Uno?
No. The antenna and radio sit on the ESP32 Uno module itself. You add wires only for the LEDs, relays, sensors or motors that your commands control.
Can I use 5V modules with chat commands?
Yes, for modules that take a 3.3V control signal, like many relay boards. ESP32 Uno pins are 3.3V logic and are not 5V tolerant. If a module sends 5V back into a pin, put a level shifter or a voltage divider in between.
Is the ESP32 Uno chat code different from the UNO R4 WiFi chat code?
The callbacks and the send() calls are the same. The UNO R4 WiFi sketch includes DIYables_ArduinoBLE.h, while the ESP32 Uno uses DIYables_Esp32BLE.h or DIYables_Esp32Bluetooth.h. The ESP32 Uno sketches also run at 115200 baud and add the heap command.
Why does the monitor example want analogSetAttenuation(ADC_11db)?
It opens the ESP32 Uno ADC range to about 0 to 3.3V, so a full sensor swing maps to 0 to 4095. With a narrower range the value tops out at 4095 too soon. The UNO R4 does not need this line; only the ESP32 Uno does. Keep the sensor signal at 3.3V or less.
What if my chat build needs more pins than the Uno headers give?
The ESP32 Uno has a few extra holes near the power header: GPIO32 and GPIO33 (input, output, PWM, and analog on ADC1, so they also work while WiFi is on) and GPIO15 (input, output, PWM, analog on ADC2). Solder pin headers and write the GPIO number in code. For extra chat-controlled LEDs or relays, start with GPIO32 and GPIO33. Two warnings: GPIO15 and GPIO0 (the IO0 pin at the unused Uno NC spot) are boot strapping pins, and a wrong connection can stop the board from booting or uploading, so use GPIO32/33 first. Never use the six holes under the digital header (SD0 to SD3, CMD, CLK = GPIO6 to GPIO11), because they connect to the flash chip and using them crashes the board.
Can the ESP32 Uno chat over WiFi instead of Bluetooth?
Yes. The DIYables Web Apps library has a chat page that runs in any browser on the same network. See ESP32 Uno - Web Chat for that version.