Hi All
Have any one of you used a SIM20 transceiver?
I would like to use it on a Mega2560 on Serilal1.
I am having problems when I send AT commands and I am not able to read the response.
When I put the SIM 20 in data mode and send data (from my PCB and Mega) I get data on the test kit but it is not the same data that I send.
Pointing me in the right direction would be really appreciated.
The schematic is attached.
Thank you
Best regards
Luan
Test kit:
int serIn; // var that will hold the bytes-in read from the serialBuffer
char serInString[128]; // array that will hold the different bytes 100=100characters;
// -> you must state how long the array will be else it won't work.
int serInIndx = 0; // index of serInString[] in which to insert the next incoming byte
int serOutIndx = 0; // index of the outgoing serInString[] array;
const int AC2DPin = 17;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial.println("Hello World");
pinMode(AC2DPin, OUTPUT);
digitalWrite(AC2DPin, HIGH);
delay(500);
digitalWrite(AC2DPin, LOW); //LOW for sending data
delay(500);
digitalWrite(AC2DPin, HIGH); //High for command mode
Serial1.println("AT+SRDuart=2,0");
Serial1.println("\r\n");
delay(500);
digitalWrite(AC2DPin, LOW); //LOW for sending data
delay(120);
}
void loop ()
{
//simple feedback from Arduino
//read the serial port and create a string out of what you read
//readSerialString(serInString, serInIndx);
//Serial.println("AT+SRDSN?\r\n");
Serial1.println("AT+SRDSN?\n");
//Serial1.print("\r\n");
//Serial1.print("\r");
//Serial1.print("\r\n");
//Serial1.print("\n");
delay(10);
readSerialString();
//do somenthing else perhaps wait for other data or read another Serial string
Serial.println ("------------ arduino is doing somenthing else ");
//try to print out collected information. it will do it only if there actually is some info.
printSerialString();
//slows down the visualization in the terminal
delay(2000);
}
//read a string from the serial and store it in an array
//this func uses globally set variable so it's not so reusable
//I need to find the right syntax to be able to pass to the function 2 parameters:
// the stringArray and (eventually) the index count
void readSerialString () {
int sb;
if(Serial1.available()) {
//Serial.print("reading Serial String: "); //optional confirmation
while (Serial1.available()){
sb = Serial1.read();
serInString[serInIndx] = sb;
serInIndx++;
//serialWrite(sb); //optional confirmation
}
//Serial.println();
}
}
//print the string all in one time
//this func as well uses global variables
void printSerialString() {
if( serInIndx > 0) {
Serial.print("Arduino memorized that you said: ");
//loop through all bytes in the array and print them out
for(serOutIndx=0; serOutIndx < serInIndx; serOutIndx++) {
Serial.print( serInString[serOutIndx] ); //print out the byte at the specified index
//serInString[serOutIndx] = ""; //optional: flush out the content
}
//reset all the functions to be able to fill the string back with content
serOutIndx = 0;
serInIndx = 0;
Serial.println();
}
}
SIM20_sch.pdf (13.1 KB)
SIM20_AT_Command_Manual_V1.04.pdf (396 KB)