Advertisement
mikroavr

modem_lte_test_at_command

Nov 12th, 2020
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define RXD2 17
  2. #define TXD2 16
  3. #define PKEY 2
  4. #define RST 4
  5. unsigned long cur_time, old_time;
  6.  
  7. void setup() {
  8.   // put your setup code here, to run once:
  9.   Serial.begin(115200);
  10.   Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  11.   delay(1000);
  12.   Serial.println("test at mulai");
  13.   pinMode(RST, OUTPUT);
  14.   //pinMode(PKEY, OUTPUT);
  15.   //digitalWrite(PKEY, HIGH);
  16.   digitalWrite(RST, HIGH);delay(1000);
  17.   digitalWrite(RST, LOW);delay(1000);
  18.   digitalWrite(RST, HIGH);delay(1000);
  19.   delay(1000);
  20.   wRespon(15000);
  21.   /*Serial2.println("AT");
  22.   wRespon(1000);
  23.   Serial2.println("AT+IPREX?");
  24.   wRespon(1000);
  25.   Serial2.println("AT+IPREX=9600");
  26.   wRespon(1000);
  27.   Serial2.println("AT&W");
  28.   wRespon(1000);
  29.   Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  30.   */
  31. }
  32.  
  33. void loop() {
  34.   // put your main code here, to run repeatedly:
  35.   Serial.println("SEND AT");
  36.   /*Serial2.println("ATI");
  37.   wRespon(1500);
  38.  
  39.   */
  40.   Serial2.println("AT");
  41.   wRespon(1000);
  42.   Serial2.println("ATI");
  43.   wRespon(1000);
  44.   Serial2.println("AT+IPR?");
  45.   wRespon(1000);
  46.  
  47.  
  48.  
  49.   /*Serial2.println("AT+SIMEI=?");
  50.   wRespon(1000);
  51.   Serial2.println("AT+SIMEI?");
  52.   wRespon(1000);
  53.   Serial2.println("AT+SIMEI=353957064579992");
  54.   wRespon(1000);
  55.   Serial2.println("AT+SIMEI?");
  56.   wRespon(1000);
  57.   while(1){
  58.    
  59.   }
  60.  
  61.   */
  62.  
  63.   Serial2.println("AT+CPIN?");
  64.   wRespon(1000);
  65.   //Serial2.println("AT+CGMR");
  66.   //wRespon(1000);
  67.   Serial2.println("AT+CSQ");
  68.   wRespon(1000);
  69.   Serial2.println("AT+CREG?");
  70.   wRespon(1000);
  71.   Serial2.println("AT+CPSI?");
  72.   wRespon(1000);
  73.   delay(1000);
  74. }
  75. void wRespon(long waktu){
  76.   cur_time = millis();
  77.   old_time = cur_time;
  78.   while(cur_time - old_time < waktu ){
  79.     cur_time = millis();
  80.     while(Serial2.available()>0){
  81.       Serial.print(Serial2.readString());
  82.     }
  83.   }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement