Forum: Mikrocontroller und Digitale Elektronik Maturaarbeit


von gertrud h. (falron1994)


Lesenswert?

Hi,

ich versuche als Teil einer Maturaarbeit eine Verbindung zwischen zwei 
Arduinos mit Hilfe von 2 Bluetooth-Modulen 
(https://www.sparkfun.com/products/10393) herzustellen. Hierzu habe ich 
jeweils die Bluetooth-Module mit den Arduinos (Leonardo, Uno) verbunden 
und ein kleines Testprogramm geschrieben.
Leider funktioniert dies nicht und auch mit Hilfe eines Testprogrammes 
aus dem Internet, konnte keine Verbindung hergestellt werden 
(https://github.com/yexiaobo-seeedstudio/Bluetooth_Shield/tree/master/BluetoothShieldDemoCode/examples).

Könnt ihr mir eventuell helfen und ein paar Tips sagen, wie ich eine 
Verbindung zwischen den Arduinos herstellen kann?

Slave:
1
#include <SoftwareSerial.h>
2
3
#define BTX 2  // TX-O pin of bluetooth mate, Arduino D2
4
#define BRX 3  // RX-I pin of bluetooth mate, Arduino D3
5
6
SoftwareSerial Bluetooth (BTX, BRX);
7
8
void setup() {
9
  Serial.begin(9600);
10
  Bluetooth.begin(115200);
11
  delay(320);                             // IMPORTANT DELAY! (Minimum ~276ms)
12
  Bluetooth.print("$$$");                 // Enter command mode
13
  delay(15);                            // IMPORTANT DELAY! (Minimum ~10ms)
14
  Bluetooth.println("U,9600,N");       // Temporarily Change the baudrate to 9600, no parity
15
  Bluetooth.println("SM,1");              // Slave-configuration
16
  Bluetooth.println("C, 000666605063");   //MAC-address
17
  Bluetooth.println("F,1");
18
  Bluetooth.println("---");
19
  Bluetooth.begin(9600);                  // Start bluetooth serial at 9600
20
  
21
  
22
}
23
24
void loop() {
25
  if(Bluetooth.available()){  // If the bluetooth sent any characters
26
    Serial.println(Bluetooth.read());
27
  }
28
}

Master:
1
#include <SoftwareSerial.h>  
2
3
int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
4
int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3
5
6
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
7
8
void setup()
9
{
10
  Serial.begin(9600);  // Begin the serial monitor at 9600bps
11
  bluetooth.begin(115200);     // The Bluetooth Mate defaults to 115200bps
12
  delay(320);                     // IMPORTANT DELAY! (Minimum ~276ms)
13
  bluetooth.print("$$$");         // Enter command mode
14
  delay(15);                      // IMPORTANT DELAY! (Minimum ~10ms)
15
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
16
  bluetooth.begin(9600);          // Start bluetooth serial at 9600
17
}
18
19
void loop()
20
{
21
  if(bluetooth.available())  // If the bluetooth sent any characters
22
  {
23
    // Send any characters the bluetooth prints to the serial monitor
24
    Serial.print((char)bluetooth.read());  
25
  }
26
  if(Serial.available())  // If stuff was typed in the serial monitor
27
  {
28
    // Send any characters the Serial monitor prints to the bluetooth
29
    bluetooth.print((char)Serial.read());
30
  }
31
  // and loop forever and ever!
32
}

von Otto (Gast)


Lesenswert?

Slave mode ist SM,0

Im Master hast du gar keine Konfiguration angegeben

von Otto (Gast)


Lesenswert?

Ausserdem beendest du den Konfigurationsmodus nicht durch"---"

von gertrud h. (Firma: HTL) (falron94)


Lesenswert?

slave ist SM,0? ok. danke
ich habe beim master nichts angegeben, da SM,0 default-mäßig ist. muss 
dann beim master SM,1 verwendet werden?

ja das beenden habe ich schon hinzugefügt gehabt, funktioniert trotzdem 
nicht :/
ich kann keine verbindung zwischen den modulen aufbauen, denn soviel ich 
mitbekommen habe, sollte, sobald eine verbindung besteht, eine andere 
LED am modul aufleuchten

von Otto (Gast)


Lesenswert?

Um das System in Betrieb zu nehmen solltest du am besten beidseitig an 
die BT-Module je einen PC mit Terminalprogramm anschließen, so dass du 
auch sehen kannst, was passiert.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.