New GSM module test



  • I just got the new GSM module (M6315). I can burn the EasyLoader successfully. After reboot, it shows a BLANK screen. If I burnt the GSM sample code from Arduino IDE to the M5stack, it shows a BLANK screen also. Is there anything I can try or have I missed anything?



  • Hi @zw29 did you look at the Arduino code?

    #include <M5Stack.h>
    
    void IotWriteCommand(char cmd[],char date[]){
      char buf[256] = {0};
      if(cmd == NULL)
      sprintf(buf,"AT\r\n");
      else if(date == NULL)
      sprintf(buf,"AT+%s\r\n",cmd);
      else
      sprintf(buf,"AT+%s=%s\r\n",cmd,date);
    
      Serial2.write(buf);
    }
    //AT+CSQ=?
    void get_time(void){
      IotWriteCommand("CSQ=?",NULL);
      while(Serial2.available()){
        uint8_t ch = Serial2.read();
        Serial.write(ch);
        M5.Lcd.write(ch);
      }
    }
    
    void setup() {
      M5.begin();
      Serial.begin(115200);
      Serial2.begin(115200, SERIAL_8N1, 16, 17);
      pinMode(2, OUTPUT);
      digitalWrite(2, 0);
      delay(3000);
      digitalWrite(2, 1);
    }
    
    void loop() {
     if(M5.BtnA.wasReleased()){
        M5.Lcd.fillScreen(TFT_BLACK); 
        M5.Lcd.setCursor(60,80,2);
        get_time();
      }
    }
    
    

    The code really doesn't seem to do much other than fill the screen with black and supposedly print the time to the screen, Was there any output on the serial terminal?

    It looks as though it is simply a template and you need to add in your own AT commands. I do not have a GSM module to test unfortunately,What is your intended use for the project?



  • @lukasmaximus Thank you for your suggestion. And sorry for the very late reply. The above code does not work for me. it is a blank screen.



  • I modified the Button example and can get "OK" in the result. But I need to press the "A" button twice to get the result. Not sure if this is correct.

    #include <M5Stack.h>

    void setup() {
    // init lcd, serial, but don't init sd card
    M5.begin(true, false, true);
    M5.Power.begin();

    M5.Lcd.clear(BLACK);
    M5.Lcd.setTextColor(YELLOW);
    M5.Lcd.setTextSize(2);
    M5.Lcd.setCursor(65, 10);
    M5.Lcd.println("GSM TEST");

    Serial2.begin(115200, SERIAL_8N1, 16, 17);

    // to power on the gsm module
    pinMode(2, OUTPUT);
    digitalWrite(2, 0);
    delay(3000);
    digitalWrite(2, 1);
    delay(1000*60);
    M5.Lcd.println("Init done!");
    }

    // Add the main program code into the continuous loop() function
    void loop() {
    if (M5.BtnA.wasReleased()) {
    get_time();
    } else if (M5.BtnB.wasReleased()) {
    M5.Lcd.clear(BLACK);
    M5.Lcd.setCursor(0, 0);
    }
    // update button state
    M5.update();
    }

    void IotWriteCommand(char cmd[],char date[])
    {
    char buf[256] = {0};
    if(cmd == NULL)
    sprintf(buf,"AT\r\n");
    else if(date == NULL)
    sprintf(buf,"AT+%s\r\n",cmd);
    else
    sprintf(buf,"AT+%s=%s\r\n",cmd,date);

    Serial2.write(buf);
    }

    //AT+CSQ=?
    void get_time(void){
    IotWriteCommand("CSQ",NULL);
    while(Serial2.available()){
    uint8_t ch = Serial2.read();
    M5.Lcd.write(ch);
    }
    }



  • It will help a lot if M5STACK can publish more sample code in sms/mqtt communication.