วันพุธที่ 22 กุมภาพันธ์ พ.ศ. 2560

GSM Module SIM800L Arduino ส่ง SMS โทรเข้า โทรออก

GSM Module SIM800L Arduino ส่ง SMS โทรเข้า โทรออก 


 

สอน วิธี ใช้งาน GSM Module SIM800L Arduino พร้อมโคด ตัวอย่าง Arduino SIM800L ใช้ได้ภายใน 3 นาที


SIM800L Module SIM800L GPRS Module
บอร์ด SIM800L Module นี้มีขนาดเล็กที่สุดในโลก มาพร้อมเสาอากาศให้ 2 ชิ้นพร้อมใช้งานกับ micro sim   โม ดูล SIM800L Module สำหรับใช้ในการรับส่ง SMS โทรศัพท์หาเบอร์ที่ต้องการ เชื่อมต่ออินเตอร์เน็ตและอื่น ๆ ได้เหมือนบอร์ด GSM รุ่นใหญ่ ๆ เลย แต่ไม่สามารถคุยได้ เพราะตัดขาลำโพงกับไมค์ออก จึงเหมาะกับงานเฉพาะด้านที่ต้องการความคุ้มค่า การใช้งานไลบารีเหมือน SIM900 มีไลบารีมาให้พร้อมใช้งาน การต่อขาใช้เพียง 2 เส้นคือ RX และ TX ใช้ไฟที่ 3.7-4.2 โวลต์กระแสสูงสุด 2A ถ้าบอร์ด Arduino ที่ใช้ไฟจาก usb อาจจะกระแสไม่พอ ต้องต่อไฟเพิ่ม ทำงานทันทีที่จ่ายไฟ มี LED แสดงผลสัญญาณ ถ้าจับสัญญาณโทรศัพท์ได้จะกระพริบช้า ๆ แต่ถ้าจับไม่ได้จะกระพริบถี่ ๆ
บอร์ด SIM800L Module สามารถ ต่อกับ Battery Li-ion ได้โดยตรง แต่ถ้าไปใช้กับไฟเลี้ยง 5V   จะต้องต่ออนุกรมกับ Diode 1N4001 (หรือเบอร์อื่นๆ) ร่วมกับตัวเก็บประจุตามรูป เพื่อปรับระดับแรงดันไฟฟ้าลงให้เหมาะสม


 
ข้อมูล SIM800L Module SIM800L GPRS Module
  • Operating voltage: 3.7 ~ 4.2V (peak current 2A, please be prepared to handle)
  • Module size: 2.2cmx1.8cm
  • TTL serial port can be used with a direct link to the microcontroller. No need MAX232
  • Power on the module automatically boot automatically search network
  • Onboard signal lights (with signal flash slowly, no signal flash quickly)
  • The world's smallest size, absolutely no smaller than this GSM module.
  • ข้อมูล DataSheet SIM800L
 


โมดูลนี้ใช้กับไลบารี SIM900 ได้ โดย ดาวน์โหลดจากที่นี่ GSMSIM900

วิธีการต่อใช้งาน
  • TX - 2
  • RX - 3
  • VCC - 3.4-4.4V หรือไฟ 5V จากบอร์ด Arduino ผ่านไดโอด
  • Gnd - Gnd
การใส่ SIM ใส่ตามช่องที่มีสัญลักษณ์รูป SIM

*** โมดูลนี้แนะนำใช้ไฟ 4.0V สามารถจ่ายกระแสสูงสุด 2A แหล่งจ่ายไฟแนะนำ โมดูลเรกูเลต 2596

ก็อปปีโคดตัวอย่างนี้ แล้วดูผมลัพธ์ที่ SerialMonitor
#include "SIM900.h"
#include "SoftwareSerial.h"
//#include "inetGSM.h"
//#include "sms.h"
//#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to communicate with SIM900 through AT commands.

//InetGSM inet;
//CallGSM call;
//SMSGSM sms;

int numdata;
char inSerial[40];
int i=0;


void setup()
{
     //Serial connection.
     Serial.begin(9600);
     Serial.println("GSM Shield testing.");
     //Start configuration of shield with baudrate.
     //For http uses is raccomanded to use 4800 or slower.
     if (gsm.begin(9600))
          Serial.println("\nstatus=READY");
     else Serial.println("\nstatus=IDLE");
};

void loop()
{
     //Read for new byte on serial hardware,
     //and write them on NewSoftSerial.
     serialhwread();
     //Read for new byte on NewSoftSerial.
     serialswread();
};

void serialhwread()
{
     i=0;
     if (Serial.available() > 0) {
          while (Serial.available() > 0) {
               inSerial[i]=(Serial.read());
               delay(10);
               i++;
          }

          inSerial[i]='\0';
          if(!strcmp(inSerial,"/END")) {
               Serial.println("_");
               inSerial[0]=0x1a;
               inSerial[1]='\0';
               gsm.SimpleWriteln(inSerial);
          }
          //Send a saved AT command using serial port.
          if(!strcmp(inSerial,"TEST")) {
               Serial.println("SIGNAL QUALITY");
               gsm.SimpleWriteln("AT+CSQ");
          } else {
               Serial.println(inSerial);
               gsm.SimpleWriteln(inSerial);
          }
          inSerial[0]='\0';
     }
}

void serialswread()
{
     gsm.SimpleRead();
}

1. ทดสอบการส่ง SMS
2. ทดสอบการโทรออก
3. ทดสอบการรับสาย

หมายเหตุ บอร์ดนี้ใช้กระแสสูงสุด 2A ทำให้บางครั้งอาจพบปัญหาที่ปกติใช้ได้แล้วอยู่ ๆ ใช้ไม่ได้ เพราะกระแสไม่ถึงครับ




 เพียงเท่านี้เราก็สามารถใช้งาน SIM800L ได้แล้ว สำหรับการใช้งานเพิ่มเติม สามารถทำงานได้แบบ SIM900 ในบทความนี้ คลิกที่นี่

ไม่มีความคิดเห็น:

แสดงความคิดเห็น