connection problem

来源:互联网 发布:黑客模拟软件 编辑:程序博客网 时间:2024/05/17 23:40
Hello,
I'm trying to control my Arduino that has a HC-06 bluetooth connector on it from my Raspberry Pi 3 with the on board bluetooth. I need to send a character from the Raspberry Pi to the Arduino that will turn on a LED. Right now the Arduino code works and I can connect my computer to the HC-06 bluetooth connector and I'm able to turn the LED on and off. I was also able to connect my computer to the Raspberry Pi via bluetooth and even send a file between the two. But I'm not able to connect the Raspberry Pi to my Arduino with the HC-06 connector.

I get this error after trying to connect to it with bluetoothctl:
[CHG] Device 20:15:05:07:54:32 Connected: yes
Failed to connect: org.bluez.Error.NotAvailable

I've read up on a lot of info on how this can be done but it seems like my bluetooth version and the one in a tutorial are always different. I'm not sure what I'm missing but if you have any idea please let me know! Thank you all very much!!!
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by RudolfAtHome » Tue Oct 25, 2016 11:05 am
After a lot of search with trial and error I am at the same point! I do'nt get the file "/dev/rfcomm0". With the connect commad I get sthe same error message.
Posts: 2
Joined: Tue Oct 25, 2016 10:58 am
by nicntj » Tue Oct 25, 2016 12:20 pm
RudolfAtHome wrote:After a lot of search with trial and error I am at the same point! I do'nt get the file "/dev/rfcomm0". With the connect commad I get sthe same error message.

Yeah! We're probably missing something small which isn't allowing the on board bluetooth to read it. Are you trying to do the same thing with the Arduino and the HC-06 bluetooth connector? Because I'm also wondering if the Pi might have a hard time connecting to the HC-06. I know that some devices are unable to connect.
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by Massi » Tue Oct 25, 2016 12:41 pm
nicntj wrote:
RudolfAtHome wrote:After a lot of search with trial and error I am at the same point! I do'nt get the file "/dev/rfcomm0". With the connect commad I get sthe same error message.

Yeah! We're probably missing something small which isn't allowing the on board bluetooth to read it. Are you trying to do the same thing with the Arduino and the HC-06 bluetooth connector? Because I'm also wondering if the Pi might have a hard time connecting to the HC-06. I know that some devices are unable to connect.


hc-06 works like a charm with the old blueZ and also with the new one
you only have to configure it properly (the old with the rfcomm.conf file, the new modifying the service file)
since it has been discussed many times on this forum, i leave you searching for the solution.
Posts: 1514
Joined: Fri May 02, 2014 1:52 pm
Location: Italy
by Douglas6 » Tue Oct 25, 2016 2:54 pm
Here's a hint: https://www.raspberrypi.org/forums/view ... 85#p947185
User avatar
Posts: 3323
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by nicntj » Thu Oct 27, 2016 1:23 pm
Douglas6 wrote:Here's a hint: https://www.raspberrypi.org/forums/view ... 85#p947185

Yes I have seen this post and tried that before and I actually reinstalled Raspbian, updated and tried again. And I'm still running into the same problem.

I get this error after trying to connect to it with bluetoothctl:
[CHG] Device 20:15:05:07:54:32 Connected: yes
Failed to connect: org.bluez.Error.NotAvailable
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by Douglas6 » Thu Oct 27, 2016 2:13 pm
Go to a terminal window and type 'bluetoothctl' then type 'scan on'. Does the Pi see the HC-06? Type 'info <bdaddr>'. What does it say? Quit bluetoothctl and enter 'sudo sdptool browse local'. Is the Serial Port Profile listed?
User avatar
Posts: 3323
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by nicntj » Fri Oct 28, 2016 12:10 am
Douglas6 wrote:Go to a terminal window and type 'bluetoothctl' then type 'scan on'. Does the Pi see the HC-06? Type 'info <bdaddr>'. What does it say? Quit bluetoothctl and enter 'sudo sdptool browse local'. Is the Serial Port Profile listed?

Yes the Pi sees the HC-06. The info <bdaddr> returns: Device <bdaddr> not available. Yes the Serial Port Profile is listed.
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by Douglas6 » Fri Oct 28, 2016 12:19 am
Try the info command again, but replace '<bdaddr>' with the actual Bluetooth device address of the HC-06, for example:
CODE: SELECT ALL
info AA:BB:CC:DD:EE:FF
User avatar
Posts: 3323
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by nicntj » Fri Oct 28, 2016 12:36 am
Douglas6 wrote:Try the info command again, but replace '<bdaddr>' with the actual Bluetooth device address of the HC-06, for example:
CODE: SELECT ALL
info AA:BB:CC:DD:EE:FF

It says:
Name: HC-06
Alias: HC-06
Class 0x001f00
Paired: no
Trusted: yes
Blocked: no
connected: no
LegacyPairing: yes
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by Douglas6 » Fri Oct 28, 2016 12:45 am
OK. It needs to be paired before you can connect with it. In bluetoothctl, try to pair it:
CODE: SELECT ALL
pair AA:BB:CC:DD:EE:FF
You might need to trust it again:
CODE: SELECT ALL
trust AA:BB:CC:DD:EE:FF
Then you can connect to it.
User avatar
Posts: 3323
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by nicntj » Fri Oct 28, 2016 12:53 am
Douglas6 wrote:Then you can connect to it.

Alright so I paired it and it asked me for the key and I inputed it. It came up with the same error message I've been getting. But it nows says that the pairing is successful. I can still not connect to it.
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by Douglas6 » Fri Oct 28, 2016 1:05 am
How are you trying to connect? Use this rfcomm command:
CODE: SELECT ALL
sudo rfcomm connect hci0 AA:BB:CC:DD:EE:FF
User avatar
Posts: 3323
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by nicntj » Fri Oct 28, 2016 1:17 am
Douglas6 wrote:How are you trying to connect? Use this rfcomm command:
CODE: SELECT ALL
sudo rfcomm connect hci0 AA:BB:CC:DD:EE:FF

YES! Now the HC-06 has its status light on full! I just need to figure out how to send the data that I want. Thank you very much this was extremely helpful!!!
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by Douglas6 » Fri Oct 28, 2016 1:34 am
You'll notice that you now have a /dev/rfcomm0 virtual serial device. You can use it with a serial terminal program such as minicom, or program to it with PySerial in Python or WiringPi in C.
User avatar
Posts: 3323
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by nicntj » Fri Oct 28, 2016 2:43 am
Douglas6 wrote:You'll notice that you now have a /dev/rfcomm0 virtual serial device. You can use it with a serial terminal program such as minicom, or program to it with PySerial in Python or WiringPi in C.

Yep! I was able to get it all to work and do what I needed it to do! Thank you very much!!!!
Posts: 14
Joined: Tue Oct 25, 2016 12:51 am
by RudolfAtHome » Fri Oct 28, 2016 6:50 pm
Many thanks to Douglas6 - my Bluetooth is working now with the HC-06!
Posts: 2
Joined: Tue Oct 25, 2016 10:58 am
by Douglas6 » Fri Oct 28, 2016 7:06 pm
Most welcome. It's nice to hear about the successes.
0 0
原创粉丝点击