sim800c
Article directory
foreword
Recently, I need to use sim800c for a project, so let’s drive it with arduino.
When using sim800c, it’s better to use 12v1A power supply, so that the test will be very stable. Sometimes the communication of SMS and phone has a lot to do with the power supply. .
Use STXD and RTXD for wiring, remember to share the same ground, otherwise the communication will fail.
1. Arduino code
#include <SoftwareSerial.h> // 采用软件的串口
SoftwareSerial SIM800C(10, 11); // Serial RX, TX
boolean bState, bOldState;
int incomingByte = 0; // for incoming serial data
int Infrared_NUM = 0;
void setup() {
// put your setup code here, to run once:
// Open serial communications and wait for port to open
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
digitalWrite(13,LOW);
digitalWrite(12,LOW);
Serial.begin(9600);
SIM800C.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (SIM800C.available()) {
Serial.write(SIM800C.read());
digitalWrite(13, HIGH);// 如果通信成功,则把Arduino上面的L13 LED 灯打开
}
if (Serial.available()) {
SIM800C.write(Serial.read());
// incomingByte = Serial.read();
// Serial.print("I received: ");
// Serial.println(incomingByte, DEC);
// digitalWrite(13, !digitalRead(13));
}
sendMeg();//发送短信例程代码
SIM800C.println("AT");
delay(2000);
SIM800C.println("ATD173**********;\r");//12345678900改成你要拨打的电话号码
}
//发送短信例程代码
void sendMeg()
{
SIM800C.println("AT");
delay(2000);
SIM800C.println("AT+CMGF=1");
delay(2000);
SIM800C.println("AT+CMGS=\"173********\"");//这里改成你的号码 \"转义
delay(2000);
SIM800C.print("fire");//这里写内容
delay(2000);
SIM800C.write(0x1A);//发送:0x1A,即“CTRL+Z”的键值,用于告诉 SIM800C,要执行发送操作
//发送: 0x1B,即“ESC”的键值,用于告诉 SIM800C,取消本次操作,不执行发送。
}
The phone number filled in will receive calls and text messages.