概述
sim800c
文章目录
- sim800c
- 前言
- 一、arduino代码
前言
最近要做一个项目需要用到sim800c,就用arduino驱动一下吧,用的是正点原子的sim800c
使用的时候最好使用12v1A供电,这样测试会很稳定有时候短信电话无法通讯和电源有很大关系。
接线的使用STXD和RTXD,记得共个地,不然也会通讯不成功。
一、arduino代码
#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,取消本次操作,不执行发送。
}
填写的手机号会收到来电和短信。
最后
以上就是清新篮球为你收集整理的Arduino——正点原子sim800c模块sim800c前言一、arduino代码的全部内容,希望文章能够帮你解决Arduino——正点原子sim800c模块sim800c前言一、arduino代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复