Skocz do zawartości

HC-05 nie komunikuje się przez monitor


mice6

Pomocna odpowiedź

Witam serdecznie, mam problem z HC-05 wlutowanym w płytkę. Próbowałem podłączyć moduł HC-05 z aliexpress do arduino (uno, nano, mega), podłączyłęm tak jak na schemacie poniżej.

Wgrałem kod:

// Basic Bluetooth test sketch 5a for the Arduino Mega. 
// AT mode using button switch
// HC-05 with EN pin and button switch
//
// Uses serial with the host computer and serial1 for communication with the Bluetooth module
//
//  Pins
//  BT VCC to Arduino 5V out. Disconnect before running the sketch
//  BT GND to Arduino GND
//  BT RX (through a voltage divider) to Arduino TX1 (pin 18)
//  BT TX  to Arduino RX1 (no need voltage divider)   (pin 19)
//
// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the Bluetooth module and display the result.
//

char serialByte = '0';
const byte  LEDPIN = 13; 

void setup() 
{
   pinMode(LEDPIN, OUTPUT);

   // communication with the host computer
   Serial.begin(9600);  

   Serial.println("Do not power the BT module");
   Serial.println(" ");
   Serial.println("On the BT module, press the button switch (keep pressed, and at the same time power the BT module");
   Serial.println("The LED on the BT module should now flash on/off every 2 seconds");
   Serial.println("Can now release the button switch on the BT module");
   Serial.println(" ");
   Serial.println("After entering AT mode, type 1 and hit send");
   Serial.println(" ");


   // wait for the user to type "1" in the serial monitor
   while (serialByte !='1')
   {
       if ( Serial1.available() )   {  serialByte = Serial1.read();  }
   }  


   // communication with the BT module on serial1
   Serial1.begin(38400);

   // LED to show we have started the serial channels
   digitalWrite(LEDPIN, HIGH);  

   Serial.println(" ");
   Serial.println("AT mode.");
   Serial.println("Remember to to set Both NL & CR in the serial monitor.");
   Serial.println("The HC-05 accepts commands in both upper case and lower case");
   Serial.println(" "); 
}


void loop() 
{
   // listen for communication from the BT module and then write it to the serial monitor
   if ( Serial1.available() )   {  Serial.write( Serial1.read() );  }

   // listen for user input and send it to the HC-05
  if ( Serial.available() )   {  Serial1.write( Serial.read() );  }
}

Po podłączeniu zasilania LED na module mruga co 2 sekundy więc teoretycznie jest w trybie AT, niestety w monitorze nie odpowiada na wysłanie 1 ani jakiejkolwiek innej. Co może być przyczyną? Wgrywałem już kilka programów, żaden się nie komunikuje, zmieniałem prędkości i zakończenie linii.

Capture.thumb.PNG.ad48939069714721d0446bd3f84653b6.PNG

Link do komentarza
Share on other sites

mice6, a wprowadziłeś w jakiś sposób HC-05 w tryb AT? Samo podłączenie do zasilania na pewno tego nie robi. W niektórych wersjach modułu trzeba trzymać wciśnięty przycisk wlutowany na płytce, a w innych zewrzeć odpowiednio pin EN, który na Twoim schemacie "wisi w powietrzu".

Link do komentarza
Share on other sites

Dołącz do dyskusji, napisz odpowiedź!

Jeśli masz już konto to zaloguj się teraz, aby opublikować wiadomość jako Ty. Możesz też napisać teraz i zarejestrować się później.
Uwaga: wgrywanie zdjęć i załączników dostępne jest po zalogowaniu!

Anonim
Dołącz do dyskusji! Kliknij i zacznij pisać...

×   Wklejony jako tekst z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Twój link będzie automatycznie osadzony.   Wyświetlać jako link

×   Twoja poprzednia zawartość została przywrócona.   Wyczyść edytor

×   Nie możesz wkleić zdjęć bezpośrednio. Prześlij lub wstaw obrazy z adresu URL.

×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.