Post Top Ad

Post Top Ad

Kirim dan terima SMS SIM900A untuk project kontak me 085743320570 (taufik )

saya coba menggunakan versi 1.6.8
arduino  uno
vcc dapat 5volt
gnd dapat gnd
rx sim dapat pin 9,
tx sim dapat pin 8



#include <SoftwareSerial.h>
SoftwareSerial SIM900A(8, 9); // RX, TX
//                       arduino 9 , 8
String number = "+6285743320570";
String content = "Hello Taufik OK!";

void setup()
{
  Serial.begin(9600);
  Serial.print("test device");
 delay(3000);
   SIM900A.begin(9600);

   Serial.print("send message ...");




SIM900A.println("AT+CNMI=1,2,0,0,0"); // Turn on plain text mode
delay(1000);


SIM900A.println("AT+CMGF=1"); // Turn on plain text mode
delay(700);


SIM900A.println("AT+CMGS=\"" + number + "\"\r");
delay(700);
SIM900A.println(content);
SIM900A.println((char)26); // Done
delay (1500);

}

void loop ()
{
 String bufferku = readSIM900A();

    if (bufferku.startsWith("\r\n+CMT: "))
    {
        bufferku.remove(0, 51);
        int len = bufferku.length();
        bufferku.remove(len - 2, 2);
        Serial.print(bufferku);
        SIM900A.println("AT+CMGD=1,4");
        delay(3000);
    }
 


String readSIM900A()
{
    String bufferku;

    while (SIM900A.available())
    {
        char c = SIM900A.read();
       // Serial.print(c);
        bufferku.concat(c);
        delay(10);
    }

    return bufferku;
}