Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RXD2 17
- #define TXD2 16
- #define PKEY 2
- #define RST 4
- unsigned long cur_time, old_time;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(115200);
- Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
- delay(1000);
- Serial.println("test at mulai");
- pinMode(RST, OUTPUT);
- //pinMode(PKEY, OUTPUT);
- //digitalWrite(PKEY, HIGH);
- digitalWrite(RST, HIGH);delay(1000);
- digitalWrite(RST, LOW);delay(1000);
- digitalWrite(RST, HIGH);delay(1000);
- delay(1000);
- wRespon(15000);
- /*Serial2.println("AT");
- wRespon(1000);
- Serial2.println("AT+IPREX?");
- wRespon(1000);
- Serial2.println("AT+IPREX=9600");
- wRespon(1000);
- Serial2.println("AT&W");
- wRespon(1000);
- Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
- */
- }
- void loop() {
- // put your main code here, to run repeatedly:
- Serial.println("SEND AT");
- /*Serial2.println("ATI");
- wRespon(1500);
- */
- Serial2.println("AT");
- wRespon(1000);
- Serial2.println("ATI");
- wRespon(1000);
- Serial2.println("AT+IPR?");
- wRespon(1000);
- /*Serial2.println("AT+SIMEI=?");
- wRespon(1000);
- Serial2.println("AT+SIMEI?");
- wRespon(1000);
- Serial2.println("AT+SIMEI=353957064579992");
- wRespon(1000);
- Serial2.println("AT+SIMEI?");
- wRespon(1000);
- while(1){
- }
- */
- Serial2.println("AT+CPIN?");
- wRespon(1000);
- //Serial2.println("AT+CGMR");
- //wRespon(1000);
- Serial2.println("AT+CSQ");
- wRespon(1000);
- Serial2.println("AT+CREG?");
- wRespon(1000);
- Serial2.println("AT+CPSI?");
- wRespon(1000);
- delay(1000);
- }
- void wRespon(long waktu){
- cur_time = millis();
- old_time = cur_time;
- while(cur_time - old_time < waktu ){
- cur_time = millis();
- while(Serial2.available()>0){
- Serial.print(Serial2.readString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement