简体   繁体   English

Arduino通过蓝牙将垃圾值发送到Android App(App Inventor 2)

[英]Arduino Sends Junk value to Android App (App Inventor 2) via Bluetooth

I just used an arduino code to send text data to an android application which I made in app inventor. 我只是使用arduino代码将文本数据发送到我在app inventor中制作的android应用程序。 I used Bluetooth module HC-05 for connectivity.It almost works but instead of sending few characters, it sends junk data. 我使用蓝牙模块HC-05进行连接,它几乎可以正常工作,但发送的不是垃圾字符,而是发送垃圾数​​据。 Here's the arduino code: 这是arduino代码:

   void setup()
{
  Serial.begin(9600);

}
void loop()
{
  Serial.println("h");
  delay(500);
  Serial.println("s");
  delay(500);
  Serial.println("o");
  delay(500);
}

And here's the App blocks and Design: 这是应用程序块和设计: 积木 设计

And here's the screenshot when I ran the app: 这是我运行该应用程序时的屏幕截图: 屏幕截图

I click "Show" and I get these random junk data. 我单击“显示”,然后得到这些随机的垃圾数据。 And the next time I click show, I don't get any data at all. 下次单击“显示”时,我什么都没有。 Can anybody explain how to solve this ? 有人可以解释如何解决这个问题吗?

For Junk values, Try to change the baud rate! 对于垃圾值,请尝试更改波特率!

I think you are sending a data from BT device to android device only one time. 我认为您仅一次将数据从BT设备发送到android设备。 try running the code continuously in arduino device. 尝试在arduino设备中连续运行代码。

while(1){ loop(); }

  • Check if you connected BT module to USART0 (RX0, TX0) port 检查是否将BT模块连接到USART0(RX0,TX0)端口
  • try change baud rate, usually HC05 has 9600, but it may have also 19200 and sometimes 115200. 尝试更改波特率,通常HC05具有9600,但可能也具有19200,有时甚至是115200。
  • note, that HC05 has 3.3V, and almost all Arduino boards are 5V. 请注意,HC05具有3.3V,几乎所有Arduino板均为5V。 So you need to use level shifters. 因此,您需要使用电平转换器。 Else specify what board and module you use 其他指定使用的板卡和模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM