Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RXD2 17
- #define TXD2 16
- #define RST 4
- unsigned long cur_time, old_time;
- #define TINY_GSM_MODEM_SIM7600
- #include <TinyGsmClient.h>
- #define SerialMon Serial
- #define TINY_GSM_DEBUG SerialMon
- #define SerialAT Serial2
- #ifdef DUMP_AT_COMMANDS
- #include <StreamDebugger.h>
- StreamDebugger debugger(SerialAT, SerialMon);
- TinyGsm modem(debugger);
- #else
- TinyGsm modem(SerialAT);
- #endif
- bool hold = 0;
- void setup() {
- // put your setup code here, to run once:
- SerialMon.begin(115200);
- SerialAT.begin(9600, SERIAL_8N1, RXD2, TXD2);
- delay(1000);
- Serial.println("test at mulai");
- pinMode(RST, OUTPUT);
- //pinMode(PKEY, OUTPUT);
- //digitalWrite(PKEY, LOW);
- digitalWrite(RST, LOW); delay(1000);
- digitalWrite(RST, HIGH); delay(1000);
- wRespon(10000);
- //change_baud();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- Serial.println("SEND AT");
- /*SerialAT.println("ATI");
- wRespon(1500);
- */
- send_at("AT");
- send_at("ATI");
- send_at("AT+IPR?");
- send_at("AT+CFUN?");
- send_at("AT+CPIN?");
- send_at("AT+CSMINS?");
- send_at("AT+COPS?");
- send_at("AT+CSQ");
- send_at("AT+CREG?");
- send_at("AT+CGREG?");
- }
- void send_at(char *_command) {
- SerialAT.println(_command);
- wRespon(1000);
- }
- void wRespon(long waktu) {
- cur_time = millis();
- old_time = cur_time;
- while (cur_time - old_time < waktu ) {
- cur_time = millis();
- while (SerialAT.available() > 0) {
- Serial.print(SerialAT.readString());
- }
- }
- }
- void change_baud(){
- SerialAT.println("AT");
- wRespon(1000);
- SerialAT.println("AT+IPR?");
- wRespon(1000);
- SerialAT.println("AT+IPR=9600");
- wRespon(1000);
- SerialAT.println("AT&W");
- wRespon(1000);
- SerialAT.begin(9600, SERIAL_8N1, RXD2, TXD2);
- while (1) {
- SerialAT.println("AT");
- wRespon(1000);
- SerialAT.println("ATI");
- wRespon(1000);
- SerialAT.println("AT+IPR?");
- wRespon(1000);
- }
- }
- /*
- */
Add Comment
Please, Sign In to add comment