Arduino Forum

Using Arduino => Interfacing w/ Software on the Computer => Topic started by: InsertPotatoHere on Jun 12, 2019, 06:22 am

Title: Bluetooth AT Command Not Working (Resolved)
Post by: InsertPotatoHere on Jun 12, 2019, 06:22 am
I have a HC-06 and HC-08 bluetooth module, and it doesn't seem to respond to any AT commands I give it. I can connect to it no problem, but when I try to send data, even the AT command doesn't return anything. I've tried switching around the TX and RX pins in the code, but nothing works. I have the RX pin on the bluetooth module on a voltage divider that I checked with a voltmeter that works. I've also tried 38400 baud rate, yet still doesn't work. Module is from DSD Tech if that helps. Does anyone know why the AT command doesn't work?
Code: [Select]

#include <SoftwareSerial.h>

SoftwareSerial mySerial(11,10); // RX, TX PIN

String str;

void setup() {
  Serial.begin(9600);
  Serial.println("Enter AT Commands:");
  mySerial.begin(9600);
}

void loop() {
  if(mySerial.available()){
    Serial.write(mySerial.read());
  }
  if(Serial.available()){
    mySerial.write(Serial.read());
  }
}
Title: Re: Bluetooth AT Command Not Working
Post by: ieee488 on Jun 12, 2019, 03:24 pm
I only have used the HC-05 and even with the HC-05 there are a few varieties.
As I recall, you need to set the module into AT mode.
Title: Re: Bluetooth AT Command Not Working
Post by: Nick_Pyner on Jun 12, 2019, 04:40 pm
Your post makes no sense. Which one is not working, or are both not working? HC-06 is in AT mode by default - no messing with buttons or wires.  And "connect" is a loose term anyway. If you connect via Bluetooth, it means you are in communications mode - not AT mode. The AT command is AT, no enter or /r/n. I'm sure the HC-08 is BLE and thus also in AT mode by default, irrespective of what the breakout board might suggest. I assume the common commands are the same as HC-06.
Title: Re: Bluetooth AT Command Not Working
Post by: InsertPotatoHere on Jun 13, 2019, 03:22 am
Your post makes no sense. Which one is not working, or are both not working? HC-06 is in AT mode by default - no messing with buttons or wires.  And "connect" is a loose term anyway. If you connect via Bluetooth, it means you are in communications mode - not AT mode. The AT command is AT, no enter or /r/n. I'm sure the HC-08 is BLE and thus also in AT mode by default, irrespective of what the breakout board might suggest. I assume the common commands are the same as HC-06.
Both aren't working, both the HC06 and HC08. I'm not sure when it is in AT mode, but even when it is not paired with my phone, any AT command still doesn't work. In the serial monitor, I have set it to no new line or carriage return, but despite any configurations, sending AT returns nothing into the serial monitor
Title: Re: Bluetooth AT Command Not Working
Post by: Nick_Pyner on Jun 13, 2019, 07:22 am
As I said, both are in AT mode by default - apply power and you are in AT mode, and will stay that way until you either start communicating or power off. Both use 9600 for AT mode - no exceptions for HC-06, and probably not for HC-08. And there only one way to connect - Tx>Rx and Rx>Tx - no exceptions, ever.

This can't be that hard, and I am certainly not going to suggest that Bluetooth might be faulty, so try again with all the above in place at the same time.
Title: Re: Bluetooth AT Command Not Working
Post by: InsertPotatoHere on Jun 14, 2019, 05:26 am
As I said, both are in AT mode by default - apply power and you are in AT mode, and will stay that way until you either start communicating or power off. Both use 9600 for AT mode - no exceptions for HC-06, and probably not for HC-08. And there only one way to connect - Tx>Rx and Rx>Tx - no exceptions, ever.

This can't be that hard, and I am certainly not going to suggest that Bluetooth might be faulty, so try again with all the above in place at the same time.
So here's what I have:
RX on a 1k + 2k voltage divider connected to the 5v output of pin 11
TX connected to pin 10
GND to ground
VCC to 5v

Image here:
https://imgur.com/a/MaewBlE

Code is as above, I type in AT into the serial monitor running at a 9600 baud rate with "No line ending", and no output. The serial monitor does output the "Enter AT Commands" in the setup(), but does not seem to print anything else
Title: Re: Bluetooth AT Command Not Working
Post by: cattledog on Jun 14, 2019, 08:10 am
Quote
RX on a 1k + 2k voltage divider connected to the 5v output of pin 11
TX connected to pin 10
Code: [Select]
SoftwareSerial mySerial(11,10); // RX, TX PIN


Your connections are not Tx>Rx and Rx>Tx. The software serial constructor is from the point of view of the Arduino. The RX arduino pin 11 should be connected to the module Tx. The Tx Arduino pin10 should connect over the voltage divider to the module Rx.
Title: Re: Bluetooth AT Command Not Working
Post by: InsertPotatoHere on Jun 14, 2019, 09:04 pm
Code: [Select]
SoftwareSerial mySerial(11,10); // RX, TX PIN

Your connections are not Tx>Rx and Rx>Tx. The software serial constructor is from the point of view of the Arduino. The RX arduino pin 11 should be connected to the module Tx. The Tx Arduino pin10 should connect over the voltage divider to the module Rx.
2nd Try: https://imgur.com/a/01NUUmE

Actually, I got some serial output now:
Code: [Select]
79
75


So it's printing the ASCII values for OK, so I'm assuming its good from here?
Title: Re: Bluetooth AT Command Not Working
Post by: Nick_Pyner on Jun 15, 2019, 04:31 am
You have certainly solved the wiring problem, and now know that transmitters transmit to receivers - not other transmitters. I'm not entirely sure that the configuration command formats are the same for HC-06 and BLE. Check the Martyn Currey website.