สร้างเว็บEngine by iGetWeb.com
Cart รายการสินค้า (0)

arduino + sim900 มีบางคนถามมาครับ เอาไปฝึกลองสั่งเปิดปิดอุปกรณ์ไฟฟ้านะครับ

(อ่าน 5299/ ตอบ 3)

เว็บมาสเตอร์



arduino + sim900 มีบางคนถามมาครับลองเอาไปฝึกเล่นดูนะครับ


เอาไปฝึกลองสั่งเปิดปิดอุปกรณ์ไฟฟ้านะครับ




#include <GSM_Shield.h>
//for enable disable debug rem or not the string       #define DEBUG_PRINT
// definition of instance of GSM class
GSM gsm;



void setup() {
  Serial.begin(9600);
  Serial.println("system startup"); 
  //gsm.InitSerLine(9600);   //initialize serial 1 
  gsm.TurnOn(9600);              //module power on
  //gsm.InitSerLine(9600);   //initialize serial 1 
  gsm.InitParam(PARAM_SET_1);//configure the module  
  gsm.Echo(1);               //enable AT echo 
}


void loop()
{
  
    int reg;
    reg=gsm.CheckRegistration();
    switch (reg){    
      case REG_NOT_REGISTERED:
        Serial.println("not registered");
        break;
      case REG_REGISTERED:
        Serial.println("GSM module is registered");      
        break;
      case REG_NO_RESPONSE:
        Serial.println("GSM doesn't response");
        break;
      case REG_COMM_LINE_BUSY:
        Serial.println("comm line is not free");
        break;
    }
    delay(2000);
    
    reg=gsm.IsRegistered();
      Serial.print("Registration ");
      Serial.println(reg);
    
    delay(50000);
}














อันนี้ก็เป็นอีกตัวอย่างนึงครับ








#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;

//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 send and receive SMS.

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

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(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  
  if(started){
    //Enable this two lines if you want to send an SMS.
    if (sms.SendSMS("+971505393365", "Arduino SMS"))
      Serial.println("\nSMS sent OK");
  }

};

void loop() 
{
  if(started){
    //Read if there are messages on SIM card and print them.
    if(gsm.readSMS(smsbuffer, 160, n, 20))
    {
      Serial.println(n);
      Serial.println(smsbuffer);
    }
    delay(1000);
  }
};




Webboardแสดงความคิดเห็น
เยี่ยม   แย่   แย่   แย่   เขิน   หยอกล้อ  ตกใจ  ร้องไห้   สงสัย   ขอโทษ   หดหู่   อย่าน่ะ   ต่อว่า   โอเค
รูปภาพ
(นามสกุลไฟล์ควรเป็น [ jpg , jpeg , gif ] และไฟล์ไม่เกิน 3 MB.)
*ชื่อ
*สถานะ  
*อีเมล
ลิงค์ที่เกี่ยวข้อง
*รหัสยืนยัน

หมายเหตุ : : กรุณากรอกข้อมูลที่มี * ทุกช่อง

view