Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 25969|回復: 19
打印 上一主題 下一主題

藍芽與arduino通訊問題

[複製鏈接]
跳轉到指定樓層
1#
發表於 2011-11-26 18:17:10 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
我想用android手機經由藍芽傳送訊號給arduino http://arduino.cc/en/Main/ArduinoBoardUno

  所以買了一個bluetooth V3的藍芽模組,http://goods.ruten.com.tw/item/show?21106153954524#auc

  我直接用藍芽的TX,RX連接arduino的RX,TX  然後再用電腦程式teraterm經由serial port com4與藍芽模組連接,

  但終端機只收的到經由arduino傳送的字元   Serial.print('a');

  卻不能經由終端機傳訊號給藍芽模組,再經由藍芽模組TX給arduino RX

  量測模組TX端的電壓都在4.46V左右,當由傳送指令時略為變小,不知道這有沒有關係,

  我對藍芽的理解是  電腦(傳送字元)-->bluetooth moudule(TX)-->arduino(RX)-->指行動作

                     而  arduino(TX)-->bluetooth(RX)-->電腦-->顯示字元

  目前只有後者動作有出來,前者用電腦傳送字元,arduino完全沒反應 RX綠燈也沒亮?

  對藍芽很不瞭解,仿間也找不到藍芽的實作書籍,請問我該怎麼解決這問題呢?

  或者從哪邊去找到這些相關資料呢?
2#
發表於 2011-11-27 15:08:02 | 只看該作者
回復 1# k29645806


    你有沒有裝usb to serial驅動程式?
3#
 樓主| 發表於 2011-11-27 21:37:31 | 只看該作者
應該不是serial的問題,因為我是直接把訊號給arduino
我查到的是這個:

因為arduino RX的電阻值太高導致沒辦法接收到訊號,但似乎沒有solution
但判斷0跟1的訊號不是看電壓嗎?怎麼會跟電阻有關,
目前還是沒有想到解決的辦法~
http://ppt.cc/xU;v

http://ppt.cc/nKQ2



4#
發表於 2011-11-28 18:22:29 | 只看該作者
本帖最後由 vegewell 於 2011-11-28 18:28 編輯

回復 3# k29645806


    他的意思是:
[The only way is to modify the resistor.  Replace the 1k resistor to 4.7k will do the work. ]

也許你要在arduino RX端 接一顆 3.7K電阻(with 1k resistor 串聯)然後再接線到 Bluetooth
5#
發表於 2011-11-29 13:06:23 | 只看該作者
把你連接的硬體拍個照post上來看看,以及你的arduino 程式也post上來. 藍芽傳輸控制不是很難! 你說的TX  4.46V不是問題所在. 有空可以參考我的blog. http://sinocgtchen.blogspot.com
6#
 樓主| 發表於 2011-11-29 23:21:39 | 只看該作者
回復 5# sinocgt

char c;
void setup()
{
  pinMode(13,OUTPUT);
  Serial.begin(9600);
}
void loop()
{  
  Serial.println("hello");
  delay(200);
  if(Serial.available())
  {
    c=Serial.read();
    Serial.println(c);   
    if(c=='a')
    digitalWrite(13,HIGH);
    if(c=='b')
    digitalWrite(13,LOW);   
  }  
}

程式部分很簡單,就只是測試,左邊是Tera term 用com4與藍芽連接,
bluetooth V3燈亮表示連線成功

可以接收到bluetooth傳的hello字串,
但傳送a與b都沒有反應,我不知道還有哪種程式可以傳送跟接受字元,
但用過同學的手機測試的確有從電腦傳字元出去

感謝您的回覆,但我現在也不知道怎麼回事,我覺得是電壓沒有降下來的關係
但總覺得跟電阻沒有關係

你的blog我之前就有看過了,裡面很棒,但我很多都不會,也不知道從和學起~~
7#
 樓主| 發表於 2011-11-29 23:26:46 | 只看該作者
回復 4# vegewell


加電阻測試後,還是無效~
而且他不是說電阻值過高嗎?怎麼還要加電阻~
8#
發表於 2011-11-30 08:26:29 | 只看該作者
你的藍芽Vcc是接多少電壓? 5V or 3.3V? 試者接3.3V!
9#
發表於 2011-11-30 19:50:01 | 只看該作者
回復 7# k29645806


    我想如果連 DFRobot Forum 的 Administrator Ricky ,
都說[we have identified that DF-Bluetooth V3 is not compatible with offical Arduino UNO Mega 2560. ]

如果你去買 Arduino Diecimila 或是Arduino Mega 1280來用,應該就可以了,
多買一塊Arduino板子也是好的,反正你以後也可能用到,
Arduino UNO就是不行:
http://www.youtube.com/watch?v=rT31q1vdhAg
10#
 樓主| 發表於 2011-11-30 20:35:16 | 只看該作者
回復 8# sinocgt

我是用3.3V供電的,
嘗試用示波器看TX的波形,發現丟不同字串的確有不同的方波波型,大小約3.3V

用npn升壓至5V還是行不通,的確不是電壓的問題,

但波形都出來了,為什麼還會接收不到?

是訊號有檢查碼,還是該多對訊號做什麼處理嗎?不是就是serial的傳輸方式嗎?

還是arduino UNO的RX根本是有問題的,有辦法檢查嗎?
11#
 樓主| 發表於 2011-11-30 20:50:16 | 只看該作者
回復 9# vegewell

我當初也不太想弄通訊的問題,畢竟我們實驗室不是搞通訊的,裡面也沒人會

但要製作機器人總要用無線的,才會想選用藍芽,以為藍芽是有效又簡單的通訊裝置


一直以為是傳輸端的問題,所以不僅用teraterm android手機 甚至用labview丟字串給它都無效


也一直找不到有關於藍芽原理或是實作的書...


其實我原本的用意只是想找一個簡單的無線通訊裝置,但這一直克服不了


請問大家都是用哪種無線裝置跟arduino溝通啊?


Xbee wifi bluetooth ethernet? 哪種比較簡單??
12#
發表於 2011-11-30 20:59:10 | 只看該作者
1.給3.3V時, 你有檢查arduino RX嗎? 也是3.3V?
2.TX, RX有問題的話應該不能燒入程式,我想arduino版子應該沒問題.
3.有試bluetooth module AT mode可以更改Baud rate? V3.0要注意AT mode跟normal mode的切換!
13#
 樓主| 發表於 2011-12-1 00:19:55 | 只看該作者
回復 12# sinocgt

1.給3.3V時, 你有檢查arduino RX嗎? 也是3.3V?
2.TX, RX有問題的話應該不能燒入程式,我想arduino版子應該沒問題.
3.有試bluetooth module AT mode可以更改Baud rate? V3.0要注意AT mode跟normal mode的切換!

是,我用示波器bluetooth V3的TX也就是接到arduino的RX的接點約3.3V(電腦傳訊號時)
baud rate的default設定在9600應該是沒問題,因為電腦也確實收到bluetooth V3給的訊號

AT mode我調在數字的位置,也就是ON的另一邊所以應該是normal mode沒錯

請問arduino RX TX端當有訊號傳進傳出RX TX燈沒亮是正常現象嗎?
還是我有什麼東西沒開?
14#
發表於 2011-12-1 20:38:04 | 只看該作者
本帖最後由 vegewell 於 2011-12-1 20:43 編輯
回復  vegewell

其實我原本的用意只是想找一個簡單的無線通訊裝置,但這一直克服不了


請問大家都是用哪種無線裝置跟arduino溝通啊?


Xbee wifi bluetooth ethernet? 哪種比較簡單??k29645806 發表於 2011-11-30 20:50



不必先找別的無線裝置,
還是先試試 連接 Arduino Diecimila 或是Arduino Mega 1280 或是 DFRduino Duemilanove 來用,
不想買用借的也行,

你說你的電腦,用電腦程式teraterm經由serial port com4與藍芽模組連接,
我沒有看到與電腦連線的圖片,
你能秀出來嗎?
你所謂的 [serial port com4與藍芽模組連接,]
是九針的 RS-232 Port還是 USB port 與藍芽模組連接?
15#
 樓主| 發表於 2011-12-5 22:50:41 | 只看該作者
回復 14# vegewell


是九針的 RS-232 Port還是 USB port 與藍芽模組連接?

不好意思,最近比較忙,晚回了
我想應該是透過藍芽經過serial port連結吧
我電腦與arduino並沒有連接再一起是 bluetooth與arduino接再一起


16#
發表於 2011-12-7 19:25:08 | 只看該作者
回復 15# k29645806


我想你現在應該沒有問題了,
如果你捨棄Arduino Uno, 而改用 Arduino Diecimila 或是Arduino Mega 1280 或是 DFRduino Duemilanove ,
問題就解決了,

我是想看你的整組連接的圖,
就我所知,
Arduino board and pc through Bluetooth protocol.
其裝置如下展示:
(請從part 3, 2分50秒處看起)
http://www.youtube.com/watch?v=eF2G5MSy118

你的接法應該一樣吧,
17#
 樓主| 發表於 2011-12-8 02:42:14 | 只看該作者
回復 16# vegewell

很謝謝你,但我身邊朋友其實沒有甚麼人在玩arduino所以也沒有板子可以借

問題其實就像是外國論壇所述,電阻的問題,但我不知道是過高還是過低,總之在bluetooth TX與她連接之後


再用示波器量測 bluetooth TX的訊號就變成了只剩0.幾V,所以arduino一定讀不到


解決方法是用http://www.cedmagic.com/tech-info/data/7407.pdf 這顆晶片

把TX訊號先拉到5V再輸入,這樣才不會被arduino內部的阻抗把電壓拉低,測試過後就可以了
18#
發表於 2012-8-9 11:18:48 | 只看該作者
回復  vegewell

很謝謝你,但我身邊朋友其實沒有甚麼人在玩arduino所以也沒有板子可以借

問題其實就像 ...
k29645806 發表於 2011-12-8 02:42



    我的情況跟你一樣,沒有其他人借來試。  花了三天才看到這文章。
如果用 softserial, 可否改用其他 pin 來收訊息?
http://arduino.cc/hu/Reference/SoftwareSerial

Example
  /*
  Software serial multple serial test

Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.

The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)

Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

Not all pins on the Leonardo support change interrupts,
so only the following can be used for RX:
8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

created back in the mists of time
modified 25 May 2012
by Tom Igoe
based on Mikal Hart's example

This example code is in the public domain.

*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}
19#
發表於 2012-8-14 12:33:33 | 只看該作者
成功!
再次改 BAUD RATE。 其實早前做過但不成功。
今次又得。
可參考 : http://coopermaa2nd.blogspot.hk/ ... to-ttl-adapter.html

code 及 schematic  : http://arduino.cc/playground/Learning/Tutorial01
20#
發表於 2014-12-3 08:55:05 | 只看該作者
其實露天或Y拍有些 實習套件 可用手機藍芽控制四組插座開關 ,整套arduino,藍芽,四組插頭都做好,還附上arduino 跟android手機的source code,程式碼說明等等...改成自己想要的功能很方便。電路圖也有,不用自己在研究老半天... 搜尋 arduino+藍芽...
http://goods.ruten.com.tw/item/show?21449881951934
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-4-29 21:13 , Processed in 0.319353 second(s), 9 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表