Bluetooth serial terminal control
Build it step by step
0 of 7 doneBuild the divider
Nano D11 through 1 kΩ to the HC-05 RXD, and 2 kΩ from RXD to ground.
Wire the module
VCC to 5V, GND to ground, TXD to D10.
Add the DHT22
Data on D2 with a 10 kΩ pull-up.
Upload
Use the sketch above. The HC-05 is on D10 and D11, not on the USB serial pins, so it does not interfere with uploads.
Pair your phone
In Bluetooth settings find HC-05 and pair with 1234 or 0000.
Open a terminal app
Use a Bluetooth serial terminal app and connect to HC-05.
Send commands
T, H, L1, L0 and ? and read the replies.
How do you build a bluetooth serial terminal control?
An HC-05 lets a phone terminal app send commands and read sensor values from an Arduino. You need Arduino Nano, HC-05 Bluetooth Module, DHT22 Sensor, Resistor 10 kΩ, Resistor 1 kΩ, Resistor 2 kΩ, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and USB A to micro-USB cable (data). It takes 7 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 9
Parts list
- Development BoardsBuyArduino Nano × 1
- WirelessBuy
- SensorsBuyDHT22 Sensor × 1
- PassivesBuyResistor 10 kΩ × 1
- PassivesBuyResistor 1 kΩ × 1
- PassivesBuyResistor 2 kΩ × 1
- PrototypingBuy
- PrototypingBuy
- Cables & WiresBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| HC-05 VCC and GND | Nano 5V and GND | Supply |
| HC-05 TXD | Nano D10 (SoftwareSerial RX) | Data from the module |
| Nano D11 (SoftwareSerial TX) | 1 kΩ to HC-05 RXD, and 2 kΩ from RXD to GND | Divides 5 V down to about 3.3 V |
| DHT22 VCC and GND | Nano 5V and GND | Sensor supply |
| DHT22 DATA | Nano D2, with 10 kΩ to 5V | Pull-up |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "DHT sensor library" and "Adafruit Unified Sensor". The HC-05 is a Bluetooth Classic module, so it works with Android terminal apps but not with iPhones. Pair with the default PIN 1234 or 0000. The module's RXD pin is 3.3 V, so the 1 kΩ and 2 kΩ divider is needed. To change its name, hold the KEY pin high at power-up and send AT commands at 38400 baud.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <SoftwareSerial.h>
#include <DHT.h>
SoftwareSerial bt(10, 11); // RX, TX
DHT dht(2, DHT22);
String cmd;
void setup() {
bt.begin(9600); // HC-05 default data rate
dht.begin();
pinMode(LED_BUILTIN, OUTPUT);
bt.println("Ready. Commands: T, H, L1, L0, ?");
}
void loop() {
while (bt.available()) {
char c = bt.read();
if (c == '\n' || c == '\r') {
cmd.trim();
if (cmd == "T") { bt.print("Temp "); bt.print(dht.readTemperature(), 1); bt.println(" C"); }
else if (cmd == "H") { bt.print("Humidity "); bt.print(dht.readHumidity(), 0); bt.println(" %"); }
else if (cmd == "L1") { digitalWrite(LED_BUILTIN, HIGH); bt.println("LED on"); }
else if (cmd == "L0") { digitalWrite(LED_BUILTIN, LOW); bt.println("LED off"); }
else if (cmd == "?") { bt.println("T, H, L1, L0"); }
else if (cmd.length()) bt.println("Unknown command");
cmd = "";
} else cmd += c;
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Send T | Replies with the temperature |
| Send H | Replies with the humidity |
| Send L1 and L0 | Built-in LED switches on and off |
| Walk 5 m away | Link still works indoors |
If it does not work
Cannot see HC-05
Power the module properly. A slowly blinking LED means connected, fast blinking means waiting.
Garbled text
Baud rate mismatch. Use 9600 on both sides.
Phone cannot pair
Use the PIN 1234. iPhones cannot use Bluetooth Classic.
Replies missing
Terminal app is not adding a newline. Enable newline in its settings.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the bluetooth serial terminal control?
Arduino Nano, HC-05 Bluetooth Module, DHT22 Sensor, Resistor 10 kΩ, Resistor 1 kΩ, Resistor 2 kΩ, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and USB A to micro-USB cable (data).
How long does the bluetooth serial terminal control take to build?
About 60 minutes for a beginner maker, in 7 steps.
How do I know the bluetooth serial terminal control works?
Send T: Replies with the temperature. Send H: Replies with the humidity. Send L1 and L0: Built-in LED switches on and off.
Cannot see HC-05: what should I check?
Power the module properly. A slowly blinking LED means connected, fast blinking means waiting.
Garbled text: what should I check?
Baud rate mismatch. Use 9600 on both sides.
Phone cannot pair: what should I check?
Use the PIN 1234. iPhones cannot use Bluetooth Classic.
Replies missing: what should I check?
Terminal app is not adding a newline. Enable newline in its settings.
