Sending AT commands from serial monitor/ arduino

hi, i am having problems sending AT commands from the arduino both from serial monitor and from the code itself.

i am using the standard Software serial example from the IDE. I have read online that i can just use my.Serial to send and receive data, but that does not seem to work =( i know the device is working and i am sure of the commands as i use tera term to confirm the commands and it works fine there. Am i missing anything?

thanks!

Am i missing anything?

The code you are using, your wiring connections, info on your "device, etc.

hi,

#include <SoftwareSerial.h>

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

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

im using the standard serial software from the arduino IDE, same wiring as asked by the sketch.

The device i am using is called the HM 10 cc2540 bluetooth module. here is the link

http://wiki.iteadstudio.com/SERIAL_PORT_BLE_MODULE_(MASTER/SLAVE):_HM-10

So, i want to send AT commands via arduino to this module. it works for tera term but not the arduino.

thanks

Read the datasheet. It might have a pin you are supposed to pull HIGH or LOW to get into AT Command Mode.

o, i want to send AT commands via arduino to this module. it works for tera term but not the arduino.

Does the below play into the mix in any way?

The Bluetooth UART RS232 serial Converter Module can easily transfer the UART data through the wireless Bluetooth, without complex PCB layout or deep knowledge in the Bluetooth software stack,

hi, so i solved the problem. it turns out that all i needed to do was to change the serial monitor settings to No line ending at it worked =P.

I have another question as a followup to the previous. so now, i can receive the data transmitted from the bluetooth module. Now i want to write a reply to the module. My project is basically an ANCS data receiver from an iOS device. So i have got the receiving data part. Now to get further data, i need to send back a command to the iOS via serial. I have written a code to transmit but after doing so, it broke the receiving bit and breaks the whole thing…

#include <SoftwareSerial.h>


const int ANCS8SIZE = 8 + 8;
const int INDEX_EVENT = 8;
const int INDEX_CATEGORY = 9;
char UID [14];
int j=0;

SoftwareSerial mySerial(10, 11);
void setup()
{

  Serial.begin(9600);
  Serial.println("Setup");
  
  mySerial.begin(9600);

}
String buffer = "";
void loop() 
  {


  if (mySerial.available()) {
    
    buffer += (char)mySerial.read();
  
  }
    

  if (ANCS8SIZE > buffer.length()) {
    return;
  }
  for (;;) {

    int indexANCS8 = buffer.indexOf("OK+ANCS8");
   
    if (-1 == indexANCS8) continue;
    boolean complete = (indexANCS8 + ANCS8SIZE) <= buffer.length();
    if (!complete) continue;
    String string = buffer.substring(indexANCS8, indexANCS8 + ANCS8SIZE);
    buffer = buffer.substring(indexANCS8 + ANCS8SIZE);
   
    
    switch (string.charAt(INDEX_CATEGORY)) {
    case '1':
    
      Serial.println(" Calling");
      break;
    case '2':
     Serial.println(" Missed Call");
      break;
    case '4':
      
      Serial.println(" SMS");
      break;
      case '6':
    
      Serial.println(" Email");
      break;
    }
    
    Serial.print("UID : ");
   
    UID[0] ='A';
    UID[1] ='T';
    UID[2] ='+';
    UID[3] ='A';
    UID[4] ='N';
    UID[5] ='C';
    UID[6] ='S';
    UID[7] = string.charAt(12);
    UID[8] = string.charAt(13);
    UID[9] = string.charAt(14);
    UID[10] =string.charAt(15);
    UID[11] ='1';
    UID[12] ='1';
    UID[13] ='1';


  break;
 
   
  }

    for(j =0; j<14; j++)
   {
      Serial.print(UID[j]);
  
    }
 
   //my transmit code
  // I need to send UID and read the response
 mySerial.write(UID);
  if (mySerial.available()) {
   
    Serial.write(mySerial.read());
   
  }
  
}

In short, in reference to my code, i am trying to write UID containing the data back to the iOS and receive back from the serial monitor.

Can anyone help me debug and help identify why the code stops working after i receive the first data. Thanks!

Hi,

i am using a esp8266 once, i am using NodeMCU flasher after my esp8266 has not working for ATcommands. i am not able to working that ATcommands. please help me..

thanks

vengadeshwaran:
Hi,

i am using a esp8266 once, i am using NodeMCU flasher after my esp8266 has not working for ATcommands. i am not able to working that ATcommands. please help me..

thanks

open a different post, dont hijack an existing one.

 for (;;)

your code going into an endless for loop. No need to use an end less for loop inside an already endless 'loop()'