IoT BASE cycles continuously (Core2 stacked on top)



  • I have taken the stock example for the IoT BASE and updated it for the Core2. Similarly, it has been modified to remove the MQTT functions, for now, to just allow AT commands for debug. I changed IoT BASE library changed for pin 27 (instead of 12 for the orginal Core).

    However, on initial load from Arduino IDE I get the following error message:
    E (1659) I2C: i2s_driver_uninstall(2047): I2S port 0 has not installed

    The Core2 starts without other issues, begins to connect to the network, etc. However, when I actually checked the wayside I could see that the device was creating and deleting a session about every 7 seconds, wierd. When using the AT commands I could see similar OK---OK, --- , OK---OK, etc. In the IoT BASE there is an LED, hard to see from exterior, so I took the case off. From power up I could see almost exactly the same in hardware from the LED on (about 7 secs), off (about 3 secs), and repeat. I can't find anything in the SIM7080G spec that could do this.

    My questions are this:
    #1 What is the cause of the error message, is it related, and how to solve?
    #2 Is the IoT BASE faulty?
    #3 Is there another conflict Core2 vs IoT BASE that this is a symptom of?
    #4 Does anyone have a working Core2 IoT BASE example I could try?
    #5 Have I missed anything else in my ported example from Core to Core2?

    // #include <M5GFX.h>
    #include "IoT_BASE_SIM7080.h"
    #include <PubSubClient.h>
    #include <TinyGsmClient.h>
    #include <time.h>
    #include <sys/time.h>
    
    
    #define MQTT_BROKER "mqtt.m5stack.com"
    #define MQTT_PORT 1883
    #define MQTT_USERNAME "IoT_BASE_CATM"
    #define MQTT_PASSWORD "IoT_BASE_PWD"
    #define MQTT_D_TOPIC "IoT_BASE_CATM/D"
    #define MQTT_U_TOPIC "IoT_BASE_CATM/U"  //  上传数据主题
    
    #define UPLOAD_INTERVAL 10000
    uint32_t lastReconnectAttempt = 0;
    
    TinyGsm modem(SerialAT);
    
    TinyGsmClient tcpClient(modem);
    PubSubClient mqttClient(MQTT_BROKER, MQTT_PORT, tcpClient);
    
    void mqttCallback(char *topic, byte *payload, unsigned int len);
    bool mqttConnect(void);
    void nbConnect(void);
    
    // Your GPRS credentials, if any
    const char apn[] = "soracom.io";
    const char gprsUser[] = "sora";
    const char gprsPass[] = "sora";
    
    struct tm now;
    char s_time[50];
    
    // M5GFX display;
    // M5Canvas canvas(&display);
    
    // Module baud rate
    uint32_t rate = 0;  // Set to 0 for Auto-Detect
    
    void log(String info) {
      // canvas.println(info);
      // canvas.pushSprite(0, 0);
      M5.Lcd.print(info);
      SerialMon.println(info);
    }
    
    void setup() {
      M5.begin();
      iotBaseInit();
      // display.begin();
      // canvas.setColorDepth(1);  // mono color
      //canvas.setFont(&fonts::efontCN_14);
      // canvas.createSprite(display.width(), display.height());
      // canvas.setTextSize(2);
      // canvas.setPaletteColor(1, GREEN);
      // canvas.setTextScroll(true);
      // canvas.println(">>IoT BASE MQTT TEST");
      // canvas.pushSprite(0, 0);
      M5.Lcd.setTextSize(2);
      M5.Lcd.print(">>IoT BASE MQTT TEST");
      SerialAT.begin(SIM7080_BAUDRATE, SERIAL_8N1, IoT_BASE_SIM7080_RX,
                     IoT_BASE_SIM7080_TX);
      nbConnect();
    }
    
    void loop() {
      if (!rate) {
        rate = TinyGsmAutoBaud(SerialAT);
      }
    
      if (!rate) {
        SerialMon.println(F("***********************************************************"));
        SerialMon.println(F(" Module does not respond!"));
        SerialMon.println(F("   Check your Serial wiring"));
        SerialMon.println(F("   Check the module is correctly powered and turned on"));
        SerialMon.println(F("***********************************************************"));
        delay(30000L);
        return;
      }
    
      // SerialAT.begin(rate);
    
      // Access AT commands from Serial Monitor
      SerialMon.println(F("***********************************************************"));
      SerialMon.println(F(" You can now send AT commands"));
      SerialMon.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
      SerialMon.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
      SerialMon.println(F("***********************************************************"));
    
      while (true) {
        if (SerialAT.available()) {
          SerialMon.write(SerialAT.read());
        }  // else {
        //log("no SerialAT");
        //}
        if (SerialMon.available()) {
          SerialAT.write(SerialMon.read());
        }  //else {
        //  log("no SerialMon");
        //}
        delay(50);
      }
    }
    
    void nbConnect(void) {
      unsigned long start = millis();
      log("Initializing modem...");
      while (!modem.init()) {
        log("waiting...." + String((millis() - start) / 1000) + "s");
      };
    
      start = millis();
      log("Waiting for network...");
      while (!modem.waitForNetwork()) {
        log("waiting...." + String((millis() - start) / 1000) + "s");
      }
    
      log("Waiting for GPRS connect...");
      if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
        log("waiting...." + String((millis() - start) / 1000) + "s");
      }
      log("success");
    }


  • Hello @gavin67890

    the sample code is incorrect. I've created a PR for that issue about a year ago; unfortunately M5Stack engineers haven't yet integrated my fix. See here.

    Thanks
    Felix



  • @felmue,

    Ha, I was literally working your post. I checked Issues, not Pull Requests on GitHub. I have raised an Issue to second your observation.

    I changed mine to:

    void iotBaseInit() {
        pinMode(IoT_BASE_SIM7080_EN, OUTPUT);
        digitalWrite(IoT_BASE_SIM7080_EN, LOW);
        delay(5000);
        digitalWrite(IoT_BASE_SIM7080_EN, HIGH);
        delay(2000);
        digitalWrite(IoT_BASE_SIM7080_EN, LOW);
    };
    

    I don't get the slow on off blink on the LED, it stays solid. How sensitive are the timings, I noticed your other example below was quite rapid:

    digitalWrite(27, 0)
      wait_ms(100)
      digitalWrite(27, 1)
      wait_ms(100)
      digitalWrite(27, 0)
      wait_ms(100) # GB: Required?
    

    With the value top above a long 5s high pulse the LED held steady from the Arduino upload. The behaviour from the Core2 reset button is odd, I think it turned the modem off, so more fiddling. But IOU a virtual beer!!!

    Also, I made a tiny mod to the IoT BASE with a small round file. Now the LED is visible for fault finding.
    0_1699120920082_Screenshot 2023-11-04 at 17.58.48.png



  • Hello @gavin67890

    check this document here; section 3.2 Power on/Power off Function

    Other SIMCOM modems have specific times for the on pulse vs. off pulse (e.g. shorter to power on and longer for power off). However the SIM7080G only has minimal values specified for both and they are even overlapping. So yes, it could be that when the modem is already running the pulse turns it off.

    Thanks
    Felix



  • Cool, thanks, @felmue. I might put the modem on/off on a button instead for a bit more control while testing.