I have a project I’m anticipating where I want a bluetooth module connected to an Arduino. I’m going to have the bluetooth module connected to an Arduino under my car seat. I’ll have the bluetooth pair with my phone automatically, then an app on my phone will send a short string through the bluetooth module to the Arduino, which will then set the position of my power seat to my preference. The same will work for my wife (naturally, mine will take precedence if we’re both nearby 😉 Ideally, I’d like to have the Arduino in sleep mode and have a signal from the bluetooth module wake it up via a hardware interrupt.
So, I found these cheap HC-05 and HC-06 Bluetooth-to-serial modules out there, which is nearly perfect. One problem – I bought one, and it wound up being an HC-06. Turns out, the State pin, which is tied to GPIO09 on the HC-06 ‘daughterboard’, and is supposed to go high when the bluetooth pairs, doesn’t work on the HC-06. I’m blogging this in case anyone else is looking to detect the state of the pairing on an HC-0X module.
Some research indicated the firmware is different on the HC-06 and that feature just isn’t even supported. Supposedly, it is supported on the HC-05. OK, no biggie – they’re, like, $5 ordered from China, mounted on a nice little break-out board. So, I order a couple of HC-05 and a couple weeks later they show up. I plug one in, pair it AND….still no go! Hmmm..in the meantime I’ve been reading about a lot of AT commands you can send these suckers (you configure them using an “AT” command set, sort of like my first modem – a 300 baud modem, I’ll have you know). I won’t document how to get into the console here – that’s document extensively all over the place.
Anyway, I’m thinking…hmm…maybe there’s one that enables that function? I found the AT command set for the HC-05 is thoroughly documented here, and sure enough, the “AT+POLAR” command does just that! The engrish docs read a little counter-intuitively – you actually need to send “AT+POLAR=0,0” to set the board up to turn the onboard LED high and raise GPIO9 (board pin 32) HIGH when paired. But once I tried that setting, it worked like a charm! Oh, and by the way, the opposite (AT+POLAR=1,1) results in the on-board LED flashing slowly when paired and GPIO9 just always stays low.
Hope this helps anyone else looking to do the same.