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:
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:
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).