Bluetooth presence (via HC05 and Jeenode)

90 replies [Last post]
brett
Offline
Providence, United States
Joined: 9 Jan 2010
Andrew I updated the wiki

Andrew I updated the wiki page on the blue node with some sample output.  I'll paste again here.
I flash this onto my arduno and reattached my bluetooth device to make sure I wasn't going mad.

[BlueNode.1] - RF disabled
SYNC> AT
OK
SYNC> AT+NAME=blueNode
OK
SYNC> AT+ROLE=1
OK
SYNC> AT+INIT
ERROR:(17)
SYNC> AT+INQM=0,5,15
OK
ASYNC> AT+INQ
OK
+INQ:12:37:E90912,520204,7FFF
device=12:37:E90912 type=520204 rssi=7FFF
OK

Another command you might want to try.

// Set Connection mode.
// 1 - connect the module to any address.
sendBluetoothCommand("AT+CMODE=1", SYNC);

Put this before the AT+INIT and see if that helps any.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Brett for

Thanks Brett for clarifying,

i've added the line

 sendBluetoothCommand("AT", SYNC);
  sendBluetoothCommand("AT+NAME=blueNode", SYNC);
  // AT+ROLE=p1
  // p1 - 0 Slave Role, 1 Master Role, 2 Slave-Loop role.
  sendBluetoothCommand("AT+ROLE=1", SYNC);
  sendBluetoothCommand("AT+CMODE=1", SYNC);
  sendBluetoothCommand("AT+INIT", SYNC);
  // AT+INQM=p1,p2,p3
  // p1 - 0 inquire_mode_standad, 1 inquire_mode_rssi
  // p2 - maximum number of bluetooth devices response
  // p3 - the maximum of limited inquiring time. 1~48 (1.28s ~ 61.44s)
  //      15*1.28 = 19sec
  sendBluetoothCommand("AT+INQM=0,5,15", SYNC);

Same output alas...

[BlueNode.1]18 g212 @ 868Mhz
SYNC> AT
OK
SYNC> AT+NAME=blueNode
OK
SYNC> AT+ROLE=1
OK
SYNC> AT+CMODE=1
OK
SYNC> AT+INIT
ERROR:(17)
SYNC> AT+INQM=0,5,15
OK
ASYNC> AT+INQ
OK
OK
OK
OK
ASYNC> AT+INQ
OK
OK
OK
OK
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ

Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Andrew that's a bummer.   I

Andrew that's a bummer.   I don't know what could be wrong with your BT device its almost as if the antenna isn't connected!?  You ordered from a different supplier this time?
You have set everything just like Gary and I have so all things being equal lets blame the hardware.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
BrettSure is, as long as im

Brett

Sure is, as long as im not doing something stupid i dont mind blaming the hardware.

not much else i can think other than provide a 5v supply prehaps

original order was from the UK (more expensive but same week postage)

Thanks

Andrew

magill
Offline
Joined: 27 Apr 2012
HC-05 issues

Andrew

I have surrendered after fighting with 2 of these devices. Same response as you. Interestingly the second module I ordered was slightly different from the first, but behaved exactly the same.

John

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Hi John, Thats a real shame,

Hi John,

 

Thats a real shame, and i was thinking i was doing something very wrong....well my 2nd modeule is on its way over from a different supplier heres hoping!!

 

Thanks,

Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Its got to be how its being

Its got to be how its being initialized but if everybody has the same unit how can this be so?
That make 3 units between Andrew and John that just don't function with my code, ok I missed out the AT+INIT and when I retested my code I got error(16) "SSP not initalized" but onced Iadded AT+INIT got error(17) "already initialized" and the unit worked, as per my wiki page.

I find that hard to believe the defect rate is this high.  Maybe I should buy another and hope I get a dud so I can investigate.   This is surreal.   Gary are you using my code or some other variant?  What is your AT sequence?
Yours work right?

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Brett, I haven't tried your

Brett,

 I haven't tried your version of the code yet sorry, stupid iphone and then the raspberry pi stuff put it on a back burner.

i can try to give it a go and see if it works with my unit.

I had success with my original attempt though, init code shown below:

  BTSerial.begin(9600); delay(200);
  BTSerial.write("AT+ROLE=1\r\n");
  delay(500);
  BTSerial.write("AT+INQM=0,5,15\r\n");
  delay(500);
  BTSerial.write("AT+RESET\r\n");
  delay(500);
  BTSerial.begin(38400);
  delay(200);
  BTSerial.write("AT+INIT\r\n");
I did this as I was concerned the key pin wouldn't go high straight away and the datasheet suggested this might cause a connection at 9600 baud. Therefore I opted to do this, reset then switch to 38400 for the scan.
The fact that Andrew is getting OK responses though suggest your code has the correct baud rate so I can't see what is different.

Best I check your code after a factory reset of the module maybe
Garry
magill
Offline
Joined: 27 Apr 2012
HC-05 command mode

Andrew

Have you noticed that the module starts to flash fast ie it drops out of command mode. I have tried every combination of commands, including delays between them, on 2 modules. I give up! On to the next project.

John

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
John, Yes i get two slow

John,

 

Yes i get two slow flashes, then it drops into fast flashing.

i dont want to give up just yet :)

 

Andrew

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
New HC-05 arrived today, the

New HC-05 arrived today, the comms board it sits on is a different design with different pinouts so thats something positive as it ensures its a different batch

Im stuggling to get any serial debug out of the latest sketch, can somebody verify this works ok for them?

http://livebox-hah.googlecode.com/svn/trunk/userapps/arduino/Bluetooth/B...

thanks

Andrew

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Did you enable debug - it is

Did you enable debug - it is turned off by default.  You should get something!?
Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Brett,So it is, I missed that

Brett,

So it is, I missed that i will remove the comments from //#define SERIAL 1

Thanks

Andrew

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
After enabling Debug this is

After enabling Debug this is the current output

Sadly no OK from the first AT command

[BlueNode.1]18 g212 @ 868Mhz
SYNC> AT

bobonline19
Offline
Joined: 4 Apr 2013
hc-05 variants
I don't know if it helps at all but on the hc-05 adapter board that came with mine there is a tiny switch that has to be continually pressed to keep it in AT mode. Otherwise it tries to open a transparent Bluetooth serial data link. Part of the problem with progressing my nodes further
AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
(No subject)

Thanks for the info,

I need to check the FTDI levels for the new board, the new adaptor board suggests the comms needs to be at 3.3v

its also possible it requires a 5v + supply and not 3v

no switch as far as i can see....

 

Old on Left, new on Right

 

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
(No subject)

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Hi Andrew. Mine is the as

Hi Andrew. 

Mine is the as same as the one on the left. I connected both 3.3 and 5v but not sure if I needed to.

It worked fine. Still waiting on a new ftdi comms cable before I can flash Brett's script and have another play.

Garry

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Garry,Regarding the

Thanks Garry,

Regarding the supply V+, i've not read the specification fully but Brett does mention 3.3V was sufficient, this may however be for the type of adapter board variant he is using, something i need to check to rule out supply issues.

my old module gave me nice OK Acks, it just didnt detect any devices so i suspect its faulty as theres not much we have not tested.

The new module doesnt even go as far as to respond, tried various comm rates but from my understanding once in AT mode it will communicate at 38400 which is what Bretts sketch is setup for, prehaps i need to concentrate in getting this adaptor board / hc-05 module into AT mode, the config could be different

This is the second variant - http://www.ebay.co.uk/itm/201005161594?ssPageName=STRK:MEWNX:IT&_trksid=...

Thanks

Andrew

 

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Mine is also the same as the

Mine is also the same as the one on the left.   I do recall doing an AT+RESET manually when I first played around with this device.   That was never included in the sketch you could always try putting that in your startup seq see if it helps any.

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks Brett, I've added the

Thanks Brett,

 

I've added the Reset to my script and reverted back to my original HC-05 as the replacement (on the right in the image) will not respond at any baud rate

heres is my current output, still not devices detected so i may purchase module #3


[BlueNode.1]18 g212 @ 868Mhz
SYNC> AT+RESET
OK
SYNC> AT
OK
SYNC> AT+NAME=blueNode
OK
SYNC> AT+ROLE=1
OK
SYNC> AT+CMODE=1
OK
SYNC> AT+INIT
OK
SYNC> AT+INQM=0,5,15
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ
OK
ASYNC> AT+INQ

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Andrew

Andrew,

if you email me your address I will post you mine to try out.

I cannot use as I intended due to iphone bluetooth probs so whilst I'd like to return to this project at some point I'm not in any rush at the moment.

at least you can test one that we now is working.

 

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
This is all most

This is all most frustrating.  Andrew I would be interested to see if Garys code work for you.  Gary I would be interest to know if my code work for you !

Brett

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thank you Garry, Thats a

Thank you Garry,

 

Thats a great offer,  i will PM you

 

Brett, it sure is, i did test my original module with Garrys code above and had the same result but i will give it a test with the newer module just to be sure.

 

thanks both

Andrew

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Brett,tested your code and

Brett,

tested your code and all ok for me!?

 

Andrew,

will stick device in post tomorrow for you. If you have any joy, keep hold of it, at least it's then getting used. I cannot find a way round these iPhone issues with BT. 

Hoping to pull a list of connected devices from my router next to do something similar with wifi.  Not holding my breath though!

cheers

Garry

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
arp-scan

Garry is there any way we could make use of arp-scan to give us active ip's on the network?

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Interesting idea for the pi

Interesting idea Mark for the pi and beaglebone installs.

a lua script using io.popen to run arp-scan and capture the response. Then it just parsing and endpoint generation?!

sure it's more difficult than that but I'm sure it's doable.

thats another weekend accounted for :)

G.

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Arp scan

I've been using arp scan with my Raspi, it seems to work OK with my wife's 4S but is not really reliable with my 3GS.

This is the line from my python script:

ping4s = Popen("arp-scan 192.168.0.5-192.168.0.10 | grep xx:xx:xx:xx:73:44; echo command returned $?",shell=True, stdout=PIPE).stdout

brett
Offline
Providence, United States
Joined: 9 Jan 2010
If I scan a subnet that goes

If I scan a subnet that goes via an L3 router that bridge network segments inside my ESX box, every VM inside comes back with the same MAC address.  The L3 router is correctly subtituting its MAC so it can relay traffic.  For a flat network space this will work but beware if you are routing traffic over several IP spaces (like I do).

brett@beaglebone:~$ sudo arp-scan 192.168.4.0/24
Interface: eth0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.8.1 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.4.1     00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.33    00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.65    00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.97    00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.129   00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.161   00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.193   00:0c:29:3d:c7:c6       VMware, Inc.
192.168.4.225   00:0c:29:3d:c7:c6       VMware, Inc.

OR

Given you know the target MAC you can also use arpping - 0 means it there 1 is a failure.

brett@beaglebone:~$ sudo arping -c1 -ieth0 -q 00:14:bf:8e:7e:e4; echo $?
0
brett@beaglebone:~$ sudo arping -c1 -ieth0 -q 00:14:bf:8e:7e:e9; echo $?
1

Given this is already the exit code it makes it easier to call, you don't need a popen.  In LUA its a one liner.

retval = os.execute("arping -c 1 -i eth0 -q 00:14:bf:8e:7e:e4")

Setup a timer to do this say one a minute and update a BSC endpoint STATE to be on/off etc...
Oh and "arping" is already on your livebox too !

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
This sounds cool. Arping may

This sounds cool. Arping may be the way to do it. 

Will see what time I get over the weekend

bobonline19
Offline
Joined: 4 Apr 2013
l2ping

Once you're back to the pi there is also l2ping using a Bluetooth USB dongle and bluezutills as well as harp. Its a shame that there doesn't appear to be a serial Bluetooth module that supports it only discovery.

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Thanks GarryI will be sure to

Thanks Garry

I will be sure to let you know how i get on

thanks again

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
When I arping on my livebox

When I arping on my livebox using a MAC I get 'bad address XX:XX:XX:XX:XX:XX' but an ip address is accepted.

Dunno if I'm doing something wrong.

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
arping on Livebox

Same result here Allan, I also have to use -Ibr0 as the port

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Well blow me down with a

Well blow me down with a feather!!

Garry kindly sent me his module which was proven to work with his and bretts code above

and it worked first time!!!

incredibly frustrating that my two modules both dont respond but hey ho! atleast i now know it wasnt a ID10T error :)

OK
SYNC> AT+INIT
ERROR:(17)
SYNC> AT+INQM=0,5,15
+INQ:25:56:D697BD,0,7FFF
device=25:56:D697BD type=0 rssi=7FFF
ASYNC> AT+INQ
+INQ:1D:DF:71E8E0,240400,7FFF
device=1D:DF:71E8E0 type=240400 rssi=7FFF
+INQ:1D:DF:71E8D5,240400,7FFF
device=1D:DF:71E8D5 type=240400 rssi=7FFF
+INQ:CDD:EF:BD6E8D,5A020C,7FFF
device=CDD:EF:BD6E8D type=5A020C rssi=7FFF

now to test with some of the 5 or 6 handsets i have gathered up in the past few weeks as a result of attempting to get this working

Garry, you are the man! thanks so much

Andrew

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
No problem. Glad it works for

No problem. 

Glad it works for you and that somebody is getting use out of it. 

Doesnt say much for the hc05 as a module though does it?!

Think they need a new qc manager! ;)

 

G.

magill
Offline
Joined: 27 Apr 2012
now working

Andrew

Glad you had some success. Like you I have 2 of these devices, both different from different sources.

Both headed for the bin!!

houen
Offline
Joined: 16 Apr 2014
HC-05 starts flashing for me as well

Hi guys

 

So glad it worked for you Andrew, but now I need you guys' help. I am now on my third HC-05 module and they all start flashing as soon as I give them the INQ command. Have any of oyu found a way to solve it? If not, do you have a link, make or model to one I can try and purchase that might work for me?

 

It should probably be noted, that I am doing Arduino for my project.

 

I have a Stack Overflow question about it as well: http://stackoverflow.com/questions/23221336/hc-05-bluetooth-rssi-not-wor...

 

I really hope you can help. I am reaching in the dark here...

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Hi Houen,so basically it

Hi Houen,

so basically it falls out of programming mode?

I really wish i could advise you on how to get it working but as discussed above it seems we are missing something between different comms boards or the QC on these modules is terrible and a shed load do not work at all.

The module Garry supplied me with is identical to my original module (i.e same comms board) and worked 1st time, my original modules appear to have behaved as yours did.

maybe 4th time lucky?

Thanks

Andrew

AndrewJ
Offline
United Kingdom
Joined: 22 Nov 2012
Hi Houen,so basically it

Hi Houen,

so basically it falls out of programming mode?

I really wish i could advise you on how to get it working but as discussed above it seems we are missing something between different comms boards or the QC on these modules is terrible and a shed load do not work at all.

The module Garry supplied me with is identical to my original module (i.e same comms board) and worked 1st time, my original modules appear to have behaved as yours did.

maybe 4th time lucky?

Thanks

Andrew

Hardware Info