Last active
August 1, 2018 15:42
-
-
Save AungWinnHtut/7b50189f8fc40945abb0c8e9c36b777d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial gsm(5, 4); | |
void setup() { | |
Serial.begin(115200); | |
gsm.begin(1200); | |
Serial.println("\GSM test started"); | |
} | |
void loop() { | |
char cmd = 'p'; | |
int brate = 115200; | |
while (gsm.available() > 0) { | |
Serial.write(gsm.read()); | |
} | |
while (Serial.available() > 0) { | |
if (Serial.peek() == 'b') | |
{ | |
Serial.println(Serial.read()); | |
cmd = Serial.read(); | |
switch (cmd) { | |
case '1': brate = 115200; break; | |
case '9': brate = 9600; break; | |
case '0': brate = 1200; break; | |
default: Serial.println("Error command"); | |
} | |
gsm.begin(brate); | |
Serial.println(); | |
Serial.println("Baudrate change to"+String(brate)); | |
} | |
gsm.write(Serial.read()); | |
} | |
} | |
//Below are tested results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GSM test started | |
⸮⸮⸮98 | |
Baudrate change to-15872 | |
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮98 | |
Baudrate change to9600 | |
⸮⸮ | |
+CREG: 1,"1F57","9D3C" | |
+CGREG⸮ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment