十万火急!SIM7000C接收不到AT指令
MEGA2560装配了SIM7000C,采用7.4V锂电池作为外部电源,跑样例代码无响应,SIM7000C的ON灯亮着,NET灯会闪烁,但是得不到数据,一直是"Turn ON SIM7000......",真的很着急,求大佬帮忙!#include <Wire.h>#include <DFRobot_SIM7000.h>
#define PIN_TX 7
#define PIN_RX 8
SoftwareSerial mySerial(PIN_RX,PIN_TX);
DFRobot_SIM7000 sim7000;
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
while(!Serial);
sim7000.begin(mySerial);
Serial.println("Enter anything to get positioning ");
char loge;
readSerial(loge);
Serial.println("Getting position......");
Serial.println("Turn ON SIM7000......");
if(sim7000.turnON()){ //Turn ON SIM7000
Serial.println("Turn ON !");
}
Serial.println("Set baud rate......");
while(1){
if(sim7000.setBaudRate(19200)){ //Set SIM7000 baud rate from 115200 to 19200 reduce the baud rate to avoid distortion
Serial.println("Set baud rate:19200");
break;
}else{
Serial.println("Faile to set baud rate");
delay(1000);
}
}
Serial.println("Check SIM card......");
if(sim7000.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you h ave insert SIM card and restart SIM7000");
while(1);
}
Serial.println("Init positioning function......");
while(1){
if(sim7000.initPos()){
Serial.println("Positioning function initialized");
break;
}else{
Serial.println("Fail to init positioning function");
delay(1000);
}
}
}
void loop(){
Serial.println("Enter anything end with CRLF to get positioning ");
char loge;
readSerial(loge);
Serial.println("Getting position......");
if(sim7000.getPosition()){ //Get the current position
Serial.print(" Longitude : ");
Serial.println(sim7000.getLongitude()); //Get longitude
Serial.print(" Latitude : ");
Serial.println(sim7000.getLatitude()); //Get latitude
}else{
Serial.println("Wrong data try again");
}
}
int readSerial(char result[]){
int i = 0;
while(1){
while(Serial.available() > 0){
char inChar = Serial.read();
if(inChar == '\n'){
result = '\0';
Serial.flush();
return 0;
}
if(inChar != '\r'){
result = inChar;
i++;
}
}
}
}
麻烦发一下具体的接线图哦 你用的是什么卡啊,楼上说的应该是用mage的话 需要短接D8和D10 COM打印出来的结果是什么 看一下接线 我原来也是这样的,主要是因为程序里的引脚设置没改。
将D8和D10短接后,将程序中的:
#define PIN_TX 7
#define PIN_RX 8
改为:
#define PIN_TX 7
#define PIN_RX 10
即可,可以试试,希望有帮助~ 将换行符 改成NL CL
检查接线,检查程序,检查硬件 额,我不会啊 不要只给程序,接线和其他数据也很重要 我的用的UNO,能跑起来,但到了Getting position的这句后,输入任意内容回车后,显示Wrong data try again.
我用的是手机sim卡,不是NB-iot的卡,是不是不行?
页:
[1]