I'm trying to use AT commands through the Arduino serial monitor, however, it seems like the HM-10 module just acts as if it is normal data being added to the custom characteristic value.

I'm using the TX and RX pins on my Arduino Mega 2560, and I'm able to transmit via bluetooth and receive values via bluetooth. However, the problem is that I want the bluetooth module to interpret the data as commands.

This is my arduino code:

char c=' ';
boolean NL = true;

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.print("Sketch:   ");   Serial.println(__FILE__);
  Serial.print("Uploaded: ");   Serial.println(__DATE__);
  Serial.println(" ");

  Serial.println("Serial1 started at 9600");

// the loop function runs over and over again forever
void loop() {

  // Read from serial monitor and transmit to Bluetooth
  if (Serial.available()) {
    c = Serial.read();

    if (c!=10 & c!=13 ) {  

    // Echo the user input to the main window. 
    // If there is a new line print the ">" character.
    if (NL) { Serial.print("\r\n>");  NL = false; }
    if (c==10) { NL = true; }

  // Read from Bluetooth and write to serial monitor
  if (Serial1.available()) {
    c = Serial1.read();
  • \$\begingroup\$ Using the command: AT+NAME? gives any result? \$\endgroup\$ – Simeon R Jan 31 at 20:15
  • \$\begingroup\$ @SimeonR Not in the serial monitor, however I tried writing Serial1.write("AT\r\n"); in setup, and it worked. Is there some way to expand the serial monitor in Arduino so that I can add \r\n? It seems like I bought a clone \$\endgroup\$ – Gjert G Jan 31 at 20:17
  • \$\begingroup\$ @SimeonR AT+NAME? didnt get me anything. Just OK followed by +NAME? \$\endgroup\$ – Gjert G Jan 31 at 20:18
  • \$\begingroup\$ At the base of the serial monitor window, next to the baud rate selection, there's a drop-down box that gives options for what to attach at the end of a string when you send it. Select newline and carriage return. See if that helps \$\endgroup\$ – Simeon R Jan 31 at 20:22
  • \$\begingroup\$ @SimeonR Not any luck with that. Seems to only work whenever I use it in setup. \$\endgroup\$ – Gjert G Jan 31 at 20:27

Your Answer

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

Browse other questions tagged or ask your own question.