connection problem

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
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
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
介绍STM32CubeMX 5.0.0 STM32CubeMX是32位ARM®Cortex®STM32微控制器的图形工具。它是STMCube“计划的一部分,既可以作为独立应用程序使用,也可以作为集成开发环境(IDE)集成的Eclipse插件使用 .STM32CubeMX具有以下主要功能: 轻松的微控制器选择涵盖整个STM32产品组合 从STMicroelectronics板列表中选择电路板。 简单的微控制器配置(引脚,时钟树,外设,中间件)和相应的初始化C代码的生成。 通过将先前保存的配置导入新的MCU项目,可轻松切换到属于同一系列的另一个微控制器。 生成配置报告。 为选择的集成开发环境工具链生成IDE就绪项目。STM32CubeMX项目包括生成的初始化C代码,STM32 HAL驱动程序,用户配置所需的中间件堆栈以及在所选IDE中打开和构建项目所需的所有相关文件。 用户定义的应用程序序列的功耗计算。 自我更新允许用户使STM32CubeMX保持最新状态。 下载和更新用户应用程序开发所需的STM32Cube“嵌入式软件”(有关STM32Cube嵌入式软件产品的详细信息,请参阅附录E:STM32Cube嵌入式软件包)。 安装并运行STM32CubeMX 5.0.0 支持的操作系统和体系结构 Windows®7:32位(x86),64位(x64) Windows®8:32位(x86),64位(x64) Windows®10:32位(x86),64位(x64) Linux®:32位(x86)和64位(x64)(在RedHat,Ubuntu和Fedora上测试) 由于STM32CubeMX是32位应用程序,因此某些版本的Linux 64位 发行版需要安装32位兼容软件包,如作为ia32-libs。 MacOS:64位(x64)(在OS X Yosemite上测试) 软件要求 在Windows和Linux上:Java运行时环境(最低版本1.7.0_45) 在MacOS上:Java开发工具包(最低版本1.7.0_45) 安装STM32CubeMX 要安装STM32CubeMX,请执行以下步骤: 将最新的STM32CubeMX安装包的全部内容从http://www.st.com/stm32cubemx解压缩(解压缩)到同一目录中 在Windows上 确保您拥有管理员权限 双击SetupSTM32CubeMX-5.0.0.exe文件 在Linux上 确保您具有目标安装目录的访问权限,您可以以root(或sudo)身份运行安装,以在共享目录上安装STM32CubeMX 在SetupSTM32CubeMX-5.0.0.linux文件上双击(或从控制台窗口启动) 在MacOS上 确保您具有目标安装目录的访问权限,您可以以root(或sudo)身份运行安装,以在共享目录上安装STM32CubeMX 在SetupSTM32CubeMX-5.0.0应用程序上双击(或从控制台窗口启动) 安装后,您可以安全地从磁盘中删除zip的内容。 有关系统要求或其他可能安装的更多详细信息,请参阅STM32CubeMX用户手册。 运行STM32CubeMX 在Windows上 从Program Files> ST Microelectronics> STM32CubeMX中选择STM32CubeMX。 或者双击桌面上的STM32CubeMX图标。 在Linux上 从STM32CubeMX安装目录启动STM32CubeMX可执行文件 在MacOS上 从启动板启动STM32CubeMX应用程序 卸载STM32CubeMX 要卸载STM32CubeMX,请执行以下步骤: 在Windows上 打开Windows控制面板。 选择“程序和功能”以显示计算机上安装的程序列表。 右键单击STM32CubeMX并选择卸载功能。 在Linux上 使用文件资源管理器,进入STM32CubeMX安装的卸载程序目录,然后双击startuninstall桌面快捷方式 或使用java -jar /Uninstaller/uninstaller.jar手动启动卸载 在MacOS上 使用文件资源管理器,进入STM32CubeMX安装的Uninstaller目录,然后双击uninstaller.jar 或直接将STM32CubeMX应用程序移动到回收站中

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值