← All posts

Blog

HC-05 pairing code — it is 1234 or 0000, and on a BLE module there is not one

Troniction

Two paths to the same connection, one passing through a gate and one going around it

You have the module wired up, it shows in the phone's Bluetooth list, you tap it — and now it wants a number you were never given.

Try 1234. If that fails, try 0000. Those are the factory defaults on almost every HC-05 and HC-06 sold, there is no way to tell which you have by looking at it, and guessing wrong costs nothing but a retry.

But there is a second answer, and it catches more people than the first. If your phone never asks for a code at all, nothing is broken. BLE modules usually need no pairing, and they are not connected from the Bluetooth settings screen in the first place. If that is what you are holding, the prompt you are waiting for is never going to appear.

The defaults, by what you actually own

ModuleDefaultHow you connect
HC-051234 (some boards 0000)Pair from the phone's Bluetooth settings
HC-061234 (some boards 0000)Pair from the phone's Bluetooth settings
Genuine HM-10000000No pairing — connect from inside an app
CC41-A / AT-09000000No pairing — connect from inside an app
MLT-BT05123456No pairing — connect from inside an app

Two things jump out of that table, and both matter more than the numbers.

The Classic modules take four digits and the BLE family takes six. That is not a convention someone chose; they are different radios with different pairing models, and it is one more way the two families are not interchangeable.

Only the top two rows involve the pairing screen at all. Which means the first question is not "what is my code" — it is "which module am I holding".

If it never asks for a code

This is worth stating plainly because so much time is lost to it.

A BLE module does not appear in the phone's normal Bluetooth settings the way headphones do, and it does not ask for a PIN. You connect to it from inside an app — nRF Connect or LightBlue are the two to know — and the app talks to it directly. There is no bonding step to get through and no number to type.

So if you own something sold as an HM-10 and you have been staring at the Bluetooth screen waiting for a prompt, the module is fine and the screen is the wrong place to be looking. If it does not appear in that list at all, that is a different article with four cheaper causes — and one of them is exactly this: you are looking in the wrong list.

Not sure which family you have? Ask the module. Open the Serial Monitor at 9600 and send AT+NAME? with no line ending — a reply of OK+Get:HMSoft means a genuine HM-10. No answer? Send AT+NAME without the question mark and line ending set to Both NL & CR; +NAME=BT05 is a CC41-A, +NAME=MLT-BT05 is an MLT-BT05. Any of those means BLE, and means no pairing code.

Do you actually need to change it?

Worth asking before you go anywhere near command mode, because entering AT mode on day one is one of the most reliable ways to conclude that a working module is broken.

Every module here works out of the box with its factory name and PIN. You do not need to change the code to pair with a phone, to send or receive data, to drive a car or to read a sensor. Nothing in a first project requires it.

There are two honest reasons to change it:

  • You have more than one module, and two things called HC-05 with the same PIN in the same room is a mess you will create exactly once.
  • Somebody else will use the build, and the factory default is known to everybody with a search engine.

If neither applies, leave it. The most common version of "the PIN command does not work" is somebody typing PIN commands they never needed, on a module that was fine.

Changing it

You need AT command mode, and then the command that belongs to your module — because it is a different command on each one, with different syntax.

Getting in depends on the module. An HC-05 needs the button held down while you apply power, and comes up at 38400 with the line ending set to Both NL & CR. An HC-06 is in command mode whenever it is powered and not connected, at 9600, with no line ending. A genuine HM-10 is the same: always listening, no line ending, uppercase only.

⚠️ If every command you type comes back ERROR, stop and fix that first — it is one dropdown, and the four modules want four different settings. That is the single most common cause of "the PIN command does not work", and it has nothing to do with the PIN.

Then, to set the code to 4321:

ModuleCommandIt replies
HC-05AT+PSWD=4321OK
HC-06AT+PIN4321OKsetPIN
Genuine HM-10AT+PASS4321OK+Set:…

Read those three carefully, because the differences are the whole difficulty:

  • The HC-05 takes an equals sign. The HC-06 does not — AT+PIN4321, run together, no = anywhere.
  • The command name itself changes: PSWD, then PIN, then PASS. Three names for one idea.
  • The replies do not match either. OK on one, OKsetPIN on another, OK+Set: on the third. If you are scripting against these, that inconsistency is the thing that will bite you.

The HC-05, end to end

It is the one most people are holding, so here it is as a sequence. Stop at the first step that does not do what it says.

  1. Unplug the module's power — its VCC wire, or the USB if the whole board is coming down.
  2. Press and hold the small button on the breakout board, and keep holding it while you restore power.
  3. Release. The LED should now blink slowly, about once every two seconds. That slow blink is command mode; a fast one means you are not in it and no amount of retyping will change that.
  4. In the Serial Monitor, set the baud rate to 38400 — not 9600, whatever the module's data rate is — and the line ending to Both NL & CR.
  5. Type AT in capitals. You want OK back.
  6. Type AT+PSWD=4321. You want OK.
  7. Power-cycle the module without holding the button, to bring it back up in normal data mode.
  8. On the phone, forget the old pairing and pair again with 4321.

Leave a second between HC-06 commands. It has no line ending to mark where a command ends, so it uses a gap in your typing instead. Type the next one immediately and the two run together into something that is not a command at all — which reads as the module ignoring you.

Why the command is different at all

It is tempting to assume AT+PSWD and AT+PIN are two firmware versions of one part, and to go looking for the "right" one.

They are not. The HC-05 and the HC-06 are different modules, with different command sets, and each name belongs to its own part. There is no version of the HC-06 that accepts AT+PSWD, and no setting that makes it. If the command is wrong for the module in your hand, the answer is to use the other command, not to hunt for a firmware update.

This is the same shape as everything else in this subject: a tutorial written against one module produces a confident, specific, useless result on another — and the reader concludes they have broken something.

After you change it, forget the old pairing

One step that is easy to miss and produces a very convincing failure.

The phone stored the old code when it first bonded to the module. Change the PIN and the phone keeps offering the code it remembers, which now fails — so a module that was working a minute ago stops connecting, with no indication that your own change caused it.

Go into the phone's Bluetooth settings, find the module, and choose Forget this device — or whatever your phone calls it. Then pair again with the new code. Turning Bluetooth off and on is not enough; the stored bond survives that.

The trap that looks like a broken app

Worth knowing before you write any code that connects to this thing.

An app cannot pair for you. If you build a controller in MIT App Inventor, its device picker lists only devices that are already paired through Android's own Bluetooth settings. A picker that comes up empty looks exactly like a broken app, and it is almost always this: the module was never paired in the first place.

So the order is: pair in the phone's Bluetooth settings, with 1234 or 0000, then open your app. On a BLE module there is nothing to pair, and the app connects directly — which is the same split as everywhere else on this page.

What if neither code works

If 1234 and 0000 are both rejected on a Classic module, work down this list.

  1. Check it is actually a Classic module. If it is BLE, the prompt you are answering is not the one you think it is. Run the sixty-second identification above.
  2. Check nothing else is already connected to it. A module holding a connection will not accept a new pairing, and an old phone or laptop in the room may have grabbed it.
  3. Read the PIN off the module. In AT command mode, AT+PSWD? on an HC-05 reports the current one. If somebody set it — including you, months ago — that is the fastest way to find out.
  4. Factory reset it. AT+ORGL on an HC-05 restores the factory defaults, PIN included.

⚠️ A factory reset is not free. AT+ORGL puts everything back, not just the PIN — the name you gave it, the data rate you set with AT+UART, and the master/slave role. If you renamed the module so you could tell it from the other three in the drawer, that goes too, and you will not find out until the next time you look for it in a list. Reset when you have lost the PIN and genuinely cannot recover it; not as a first move.

And if the module never appears in the list to be paired with in the first place, the pairing code is not your problem yet — that is a supply question far more often than a configuration one.

Every symptom in this subject sorts the same way, by which part of the chain is misbehaving, on the Arduino Bluetooth fixes index.

Common questions

My phone never asks for a code. Is something wrong?
Almost certainly not, and this is the single most common confusion here. BLE modules — a genuine HM-10 and its clones — usually need no pairing at all. You do not pair them from the phone's Bluetooth settings; you connect from inside an app such as nRF Connect or LightBlue. If you are waiting for a PIN prompt on a BLE module, you are waiting for something that is never going to happen.
Which is it, 1234 or 0000?
Try 1234 first — it is the factory default on most HC-05 boards. 0000 is the other common one and turns up on some clones. There is no way to tell by looking, and getting it wrong costs nothing but a retry, so work through both before assuming anything is broken.
AT+PSWD comes back as ERROR. What now?
The most likely answer is that you are holding an HC-06 rather than an HC-05. They are different modules, not different firmware of one part, and the HC-06 uses AT+PIN with no equals sign — AT+PIN4321, not AT+PSWD=4321. If AT itself also returns ERROR then the problem is not the command at all; it is the line ending or the baud rate.
I changed the PIN and now the phone will not connect.
Remove the pairing on the phone and pair again. The phone stored the old code when it first bonded to the module, and it will keep offering that one — which now fails. Find the module in the phone's Bluetooth settings and choose Forget this device, then pair fresh with the new code.
Why is the HM-10's default six digits when the HC-05's is four?
Because they are different radios. The Classic modules use a four-digit PIN — 1234 or 0000 — while the BLE family ships with 000000 on a genuine HM-10 and a CC41-A, and 123456 on an MLT-BT05. It is one more way the two families are not interchangeable, alongside the AT syntax and whether an iPhone can see them at all.

Still not connecting?

Arduino Bluetooth — Make It Connect is 62 pages of every way the link fails, why, and the fix — HC-05, HC-06 and HM-10 BLE, including the clone family almost nothing covers. $9.