Ciao a tutti,
ho acquistato una shield BT per Arduino, il modello e' N97DG
Qui il sito:
http://www.maplin.co.uk/p/bluetooth-shield-for-arduino-n97dg
PREMESSA: ho trovato molto poco, L'unica guida che e' linkata tra le reviews di quel prodotto e' questa, che pero' non fa al caso mio, poiche' io uso un MAC.
1)Bluetooth Shield for Arduino - LinkSprite Playgound
Ho poi cercato di mettere insieme piu' pezzi, leggendo altri tutorial e guardando video:
- http://www.robotshop.com/media/files/pdf/bluetooth-shield-sld63030p.pdf
- http://arduinobasics.blogspot.ie/2013/01/arduino-basics-bluetooth-tutorial.html
Sono riuscita a far girare un programma di test, facilmente reperibile online:
#include <SoftwareSerial.h>
#define RxD 7
#define TxD 6
SoftwareSerial BlueToothSerial(RxD,TxD);
void Test_BlueTooth()
{
unsigned char t=0;
String RXD = "";
Serial.println("Test BlueTooth ...");
BlueToothSerial.print("AT\r\n");
delay(100);
while(BlueToothSerial.available()>0)
{
RXD += char( BlueToothSerial.read() );
delay(1);
}
do{
t++;
delay(400);
Serial.println("Test Failed ! Retrying ...");
}while( ((RXD[0]!='O')&&(RXD[1]!='K'))&&(t<5));
if(t<5) Serial.println("Test Successful !\r\n");
else { Serial.println("Retry Failed !"); while(1); }
}
void sendBlueToothCommand(char *Command)
{
BlueToothSerial.print(Command);
Serial.print(Command);
delay(100);
while(BlueToothSerial.available())
{
Serial.print(char(BlueToothSerial.read()));
}
}
void setupBlueTooth()
{
Serial.println("Bluetooth Initialization ...");
sendBlueToothCommand("AT+NAME=Master\r\n");
sendBlueToothCommand("AT+ROLE=1\r\n");// 1:Master 0:Slave
sendBlueToothCommand("AT+PSWD=1234\r\n");
sendBlueToothCommand("AT+UART=38400,0,0\r\n");
sendBlueToothCommand("AT+CMODE=1\r\n");
sendBlueToothCommand("AT+INIT\r\n");
sendBlueToothCommand("AT+PAIR=12,11,230317,10\r\n");//slave address
for(int i=0;i<5;i++) delay(1000);
BlueToothSerial.flush();
Serial.println("Bluetooth Initialized Successfully !\r\n");
}
void setup()
{
Serial.begin(38400);
BlueToothSerial.begin(38400);
delay(500);
Test_BlueTooth();
setupBlueTooth();
}
void loop()
{
if(BlueToothSerial.available())
{
Serial.print(char(BlueToothSerial.read()));
}
if(Serial.available())
{
BlueToothSerial.print(char(Serial.read()));
}
}
Facendo girare questo programma, aprendo la finestra per leggere sul Serial, ho letto queste stringhe:
===============================
Test BlueTooth ...
Test Failed ! Retrying ...
Test Successful !
Bluetooth Initialization ...
AT+NAME=Master
OK
AT+ROLE=1
OK
AT+PSWD=1234
OK
AT+UART=38400,0,0
OK
AT+CMODE=1
OK
AT+INIT
ERROR:(17)
AT+PAIR=12,11,230317,10
Bluetooth Initialized Successfully !
FAIL
===============================
Ho poi fatto riferimento a questo tutorial: Arduino Bluetooth Serial Control Tutorial - YouTube
Ma il risultato e' che il mio Mac non rileva nessun Bluetooth chiamato "Master"! Anche usando questo software non vedo la porta con Master nella finestra delle porte Seriali...
Non so cos'altro potrei provare!
Qualche esperto che mi da' una mano?
Manu