BLOG / ARDUINO / How to Use a Bluetooth Module with Ardui…
Bài viết Blog

How to Use a Bluetooth Module with Arduino

Viktor Build ~1 min read

A quick guide to wiring the HC-05 Bluetooth module to an Arduino Mega and sending messages from an Android phone over serial.

// Xem trên YouTube

The HC-05 is one of the easiest ways to add wireless control to an Arduino project. I connected it to my Arduino Mega and used an Android app to send messages over Bluetooth — no cables, no Wi-Fi setup needed.

Parts

  • Arduino Mega
  • HC-05 Bluetooth module
  • Jumper wires
  • Android phone with Serial Bluetooth Terminal app installed

Wiring

The HC-05 comes with 6 pins, but you only need four: GND, VCC, TX, and RX. Connect VCC to 3.3V on the Mega, GND to GND, then cross the data lines — HC-05 TX goes to Arduino RX, and HC-05 RX goes to Arduino TX. The Arduino Mega is nice for this because it has multiple hardware serial ports (Serial1, Serial2, Serial3), so the Bluetooth module doesn't share the same port as the USB connection to your computer.

The sketch

The sketch initialises Serial for the USB monitor and Serial1 for the Bluetooth module. In the loop it forwards anything received on Serial1 to Serial, so messages typed in the phone app appear in the Arduino serial monitor.

Pairing and testing

Power on the Arduino, open Bluetooth settings on your phone, and pair with the HC-05. The default pairing PIN is 1234. Then open Serial Bluetooth Terminal, connect to HC-05, and type a message — it shows up in the Arduino serial monitor right away.

Result

It worked on the first try. The HC-05 is cheap, widely available, and surprisingly simple to set up. Good starting point if you want to add wireless control to a project without dealing with Wi-Fi configuration.

Xem toàn bộ code trên GitHub →

Tham gia cộng đồng trên Discord

Đặt câu hỏi, chia sẻ dự án và giao lưu với các maker khác.

Tham gia Discord — miễn phí

Bạn thích hướng dẫn này?

Ủng hộ kênh trên Patreon để nhận quyền truy cập sớm và nhiều hơn nữa.

Ủng hộ trên Patreon →