0

I am trying to link the Bluetooth module to my arduino UNO in order to wirelessly program a robot. The only issue that I am having is that the bluetooth module does not seem to pick up the arduino.

Here is how the bluetooth module is wired up to my arduino: enter image description here

The bluetooth module is paired to my PC via a bluetooth dongle. I know that the bluetooth module is working on port COM7. The LED then on the bluetooth module blinks quickly. After this I set the port to the correct port that the bluetooth module uses:

enter image description here

One thing that I found strange was that the name of the arduino board does not come up just like when I use a USB to upload the program.

When I open up the serial monitor the LED on the bluetooth module begins to blink more slowly possibly indicating it is connected. I afterwards try to send an AT command via the serial monitor to the arduino by typing in AT to the serial input at the top of the serial monitor and hitting enter and nothing happens. I then tried to send 3 different pieces of code separately to the arduino one at a time:

First code sample:

void setup() {

 Serial.begin(9600);

while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
 }

 Serial.println("ASCII Table ~ Character Map");
}

int thisByte = 33;

void loop() {

 Serial.write(thisByte);

 Serial.print(", dec: ");
 Serial.print(thisByte);

 Serial.print(", hex: ");
 Serial.print(thisByte, HEX);

 Serial.print(", oct: ");
 Serial.print(thisByte, OCT);

 Serial.print(", bin: ");
 Serial.println(thisByte, BIN);

 if (thisByte == 126) {   
   while (true) {
     continue;
   }
 }
 thisByte++;

}

Second code sample:

#include <SoftwareSerial.h>
SoftwareSerial BTSerial (2,3);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Enter AT Commands");
  BTSerial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(BTSerial.available()){
    Serial.write(BTSerial.read());
  }
  if(Serial.available()){
    BTSerial.write(Serial.read());
  }
}

Third code sample:

char inputByte;
void setup() {
 Serial.begin(9600);
 pinMode(13,OUTPUT);

}

void loop() {
while(Serial.available()>0){
  inputByte= Serial.read();
  Serial.println(inputByte);
  if (inputByte=='Z'){
  digitalWrite(13,HIGH);
  }
  else if (inputByte=='z'){
  digitalWrite(13,LOW);
  } 
  }
}

(The following situation occurs for all 3 samples of code I copied from online). When I set the port to COM7 and then click upload to the board, the IDE says "Uploading" and the LED begins to blink more slowly just like as I was mentioning before with the serial monitor. After a while eventually the following error messages came up:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

I looked online for answers. The internet suggested to use a larger baud rate so I switched it from 9600 to 57600 and also at the same time switch from Newline to Both NL and CR. Still nothing happened and I got the following error message. One final suggestion I saw on the internet was to put a resistor divider/voltage divider across the RX pin (I haven't done this as I don't see how this could make a difference, I could be wrong about it though and it could make the whole difference).

9
  • You have no method to reboot the Arduino into the bootloader. You can't just slap a bluetooth interface on and hope it works. You need to have some way of triggering a reset like the USB interface does through the DTR signal.
    – Majenko
    Sep 24, 2021 at 20:00
  • Also you have to manually configure the HC05's baud rate to match the baud rate of the bootloader (115200 baud IIRC) which you can only do through its serial interface pins.
    – Majenko
    Sep 24, 2021 at 20:02
  • @Majenko Only problem is that I am not that experienced... Sep 24, 2021 at 20:18
  • Then you need to read, read, read. Read how the HC-05 works. If there's something you don't understand then read up about that aspect. Keep reading until you understand it all.
    – Majenko
    Sep 24, 2021 at 20:24
  • @Majenko Is there a way I could use the reset pin on the arduino to solve the problem? Sep 24, 2021 at 20:53

1 Answer 1

1

The Bluetooth range is small so the robot can't be far from the computer for upload.


To solve the reset for the Bluetooth you could add a reset button on the robot and use it while avrdude attempts to upload the sketch. Baud rate on HC-05 must be set to 115200 baud.


As an alternative you could have USB connector on the robot. You can use a short USB extension cable as internal cable from the USB connector of the Arduino to the outer shell of the robot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.