Hello friends,
- To carry out applications with Bluetooth between Arduino and App Inventor, the HC-06 module is usually used. This module can only work as a client, enough for most of the projects that you will see in the tutorials, it is the most used and recommended. Default 9600.
- Another similar module is the HC-05, this can function as a server or a client. You may have to set the speed using AT commands to adapt it to App Inventor. It comes with 38400 baud and you will have to change it to 9600. Note that it has 6 terminals and a button.
1.- Change baud rate with AT commands. HC-05
- We are going to change the baud rate from 38400 to 9600 using AT commands.
On the internet you can find many tutorials on how to change the baud rate using AT commands, here I will put a small summary. This is a tutorial in Spanish.
- We make the connection and load this sketch.
#include <SoftwareSerial.h>
SoftwareSerial BT(10,11);
void setup()
{
BT.begin(38400);
Serial.begin(38400);
// BT.begin(9600);
// Serial.begin(9600);
}
void loop(){
if(BT.available()) {Serial.write(BT.read());}
if(Serial.available()){BT.write(Serial.read());}
}
- Programming in Mode 2
To program in Mode 2, we remove the red wire (5 V) from the module's power supply. We press the small button on the module. We connect the red wire to 5 V by holding down the button. When the red wire is connected, we release the button.
The module's LED will blink slowly.
-
Serial Monitor: 38400 bauds.
-
We wrote:
AT response OK
AT+UART? response +UART: 38400,0,0
AT+UART=9600,0,0 response OK
AT+UART? response +UART: 9600,0,0
Now module with 9600 bauds.