4136| 0
|
[求助] 十万火急!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[10]; 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[10]; 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++; } } } } |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed