1733 views|3 replies

119

Posts

2

Resources
The OP
 

【DFRobot wireless communication module】+GSM communication [Copy link]

This post was last edited by xiyue521 on 2019-11-21 08:20




This content is originally created by EEWORLD forum user xiyue521 . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

Note: The board was obtained from the EEWorld event and provided by DFRobot.

Product link: http://www.dfrobot.com.cn/goods-1442.html

1. Initialization


#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10);  // TX-Pin11, RX-Pin10
void updateSerial()
{
  delay(2000);
  while (Serial.available()) {
    mySerial.write(Serial.read());//如果Serial收到数据则通过mySerial输出
  }
  while(mySerial.available()) {
    Serial.write(mySerial.read());//如果mySerial收到数据则通过Serial输出
  }
  
}   

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()
{ 
  mySerial.println("AT");          //握手测试,成功则返回OK 
  updateSerial();
    
  mySerial.println("AT+CSQ");      //信号质量测试,值为0-31,31表示最好
  updateSerial();
    
  mySerial.println("AT+CCID");    //读取SIM,可以检测是否有SIM卡或者是否接触良好
  updateSerial();
  
  mySerial.println("AT+CREG?");    //检测是否注册网络
  updateSerial();    
 
  mySerial.println("AT+SNFS=0");  //调整为耳机模式(AT+SNFS=1 表示扬声器模式)   
  updateSerial();
     
  mySerial.println("AT+CRSL=2");  //调整音量,值为0-15,15表示音量最大
  updateSerial();
    
  while(1)
  { 
    if(mySerial.available()) 
    {
      Serial.write(mySerial.read());//如果mySerial收到数据则通过Serial输出
    }
    if(Serial.available())
    {
      mySerial.write(Serial.read());//如果Serial收到数据则通过mySerial输出
    }   
  }
}

2. Send AT commands through the Ardunio serial port to make and receive calls

ATD+dial number; //dial the specified number

Ring //Incoming call

ATA //Answer incoming calls

ATH //Hang up the current call

3. Send SMS


#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10);  // TX-Pin11, RX-Pin10
void updateSerial()
{
  delay(2000);
  while (Serial.available()) {
    mySerial.write(Serial.read());//如果Serial收到数据则通过mySerial输出
  }
  while(mySerial.available()) {
    Serial.write(mySerial.read());//如果mySerial收到数据则通过Serial输出
  }
  
}   

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()
{ 
  mySerial.println("AT");          //握手测试,成功则返回OK 
  updateSerial();
  mySerial.println("AT+CMGF=1");   //配置短信模式为TEXT模式,只能发送英文短信! 
  updateSerial();
  mySerial.println("AT+CMGS=\"xxxxxxxxxxx\"");//xxxxxxxxxxx为电话号码
  updateSerial();
  mySerial.print("Hello, this is a test"); //短信内容
  updateSerial();
  mySerial.write(26);
  while(1)
  { 
    if(mySerial.available()) 
    {
      Serial.write(mySerial.read());//如果mySerial收到数据则通过Serial输出
    }
    if(Serial.available())
    {
      mySerial.write(Serial.read());//如果Serial收到数据则通过mySerial输出
    }   
  }    
}                    

This post is from RF/Wirelessly

Latest reply

What calling card do you use?   Details Published on 2019-11-21 10:34
 

119

Posts

2

Resources
2
 

1

This post is from RF/Wirelessly
 
 

256

Posts

0

Resources
3
 

What calling card do you use?

This post is from RF/Wirelessly

Comments

A6 supports China Mobile and China Unicom  Details Published on 2019-11-21 23:12
 
 
 

119

Posts

2

Resources
4
 
viphotman posted on 2019-11-21 10:34 What phone card do you use

A6 supports China Mobile and China Unicom

This post is from RF/Wirelessly
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list