http://www.circuitshops.com/articles/42137968/Arduino-Send-SMS--%E0%B9%81%E0%B8%AA%E0%B8%99%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2.html
Arduino Send SMS GSM Module แสนง่าย

Arduino Send SMS GSM Module แสนง่าย
วันนี้เรามาทดสอบให้ arduino ติดต่อ GSM module , sim900 ส่ง SMS กัน
บทความนี้จะค่อนข้างงายเพราะเราจะไม่ใช้ library ดังนั้นการเขียน code จะไม่ยาวมากนะครับ
ลิงค์สินค้าบอร์ด SIM 900 ของบริษัท ETT
http://etteam.com/prod2013/et-base%20gsm%20sim900/et-base%20gsm%20sim900.html
การต่อสายระหว่า arduino กับ sim900 ต่อจาก ขา rxtx ของ GSM module ไปยัง D0 D1 ของ arduino
โดยต่อ RX GSM module ---> TX D1 arduino
โดยต่อ TX GSM module ---> RX D0 arduino
GND to GND
ใช้เพียงแค่ สาม ขานะครับส่วน gsm module ก็จ่ายไปเลี้ยงทิ้งไว้ครับแล้วอย่าลืมกดเปิดตัวgsm module ด้วยนะครับ
และตัว GSM module ก็ต้องอย่างลืมตั้งค่าให้ติดต่อสื่อสารแบบสามสายด้วยนะครับตรงนี้ทางผู้เขียนไม่ขออธิบายนะครับเพราะสามารถหาอ่านได้ทั่วไป โดยใช้คำสั่ง “AT+IFC=1,1” ตามภาพนี้นะครับ

ค่า Configuration ที่แนะนำ
AT+CMGF=1 (SMS Message = Text Mode)
ATE=1 (Echo Mode ON)
AT+CSCLK=0 (Disable Sleep Mode)
การต่อสายระหว่าง arduino กับ Sim 900

เมื่อเราตั้งค่า module เสร็จแล้วก็มาถึง code arduino
Serial.print("AT+CMGS=\"+6685xxxxxxx\"\r"); //ใส่เบอร์โทรครับ
Serial.print("Test SMS 123\r"); // ส่งข้อความ
//*****************************
code arduino ส่ง sms
//*****************************
void setup()
{
Serial.begin(9600); //Baud rate of the GSM/GPRS Module
Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial.print("AT+CMGS=\"+6685xxxxxxx\"\r"); //ใส่เบอร์โทรครับ
delay(1000);
Serial.print("Test SMS 123\r"); // ส่งข้อความ
delay(1000);
Serial.write(0x1A);
delay(1000);
}
void loop()
{
}
void setup()
{
Serial.begin(9600); //Baud rate of the GSM/GPRS Module
Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial.print("AT+CMGS=\"+6685xxxxxxx\"\r"); //ใส่เบอร์โทรครับ
delay(1000);
Serial.print("Test SMS 123\r"); // ส่งข้อความ
delay(1000);
Serial.write(0x1A);
delay(1000);
}
void loop()
{
}
upload code ครับเมื่อเสร็จแล้วรอประมาณ 5-8 วินาทีตัว arduino ก็จะสั่งให้ GSM module ส่ง SMS ไปยังเบอร์มือถือที่คุณต้องการครับ
คำว่า Test SMS 123
ความคิดเห็น
แสดงความคิดเห็น