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");
}