m5stack / M5-ProductExampleCodes

All example codes of products supplied by M5Stack have been collected in this reposity.
MIT License
339 stars 485 forks source link

Stuck getting started on COM.NB-IoT (SIM7020G) with Core2 #47

Open torntrousers opened 2 years ago

torntrousers commented 2 years ago

Have a new COM.NB-IoT (SIM7020G) with Core2 but can't get get anything much to work.

Have an external 5v power supply for the COM.NB-IoT and inserted a SIM card and attached to the Core2. POwering on the external power supply starts LEDs flashing in the COM.NB-IoT and the Core2 boots up, so that looks like its all connected together properly.

Flashing the Core2 with the EasyLoader from the COM.NB-IoT doc page and connecting a Serial Monitor shows: M5Stack initializing... AT+CSQ AT+CSQ AT+CSQ AT+CSQ with the AT+CSQ repeating every 10 seconds.

So it looks like there is a problem with the serial connection to the COM.NB-IoT.

Hunting around I found this repo, and in there this example: https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Module/COMX_NB-IoT

That uses #include which doesn't appear to work with the Core2 so changing it to #include and adding #include to fix another compile error, and this doc page https://shop.m5stack.com/products/com-nb-iot-modulesim7020g talks about changing the M5 and Serial2 begin, so I've done that and this is the diff to this repo:

git diff
diff --git a/Module/COMX_NB-IoT/COMX_NB-IoT.ino b/Module/COMX_NB-IoT/COMX_NB-IoT.ino
index 50a9284..b322485 100644
--- a/Module/COMX_NB-IoT/COMX_NB-IoT.ino
+++ b/Module/COMX_NB-IoT/COMX_NB-IoT.ino
@@ -1,4 +1,5 @@
-#include <M5Stack.h>
+#include <M5Core2.h>^M
+#include <AXP192.h>^M
 #include <stdint.h>
 #include <vector>
 #include "TFTTerminal.h"
@@ -303,8 +304,10 @@ uint8_t restate;
 void setup()
 {
        // put your setup code here, to run once:
-       M5.begin();
-       Serial2.begin(115200, SERIAL_8N1, 5, 13);
+       //M5.begin();^M
+       //Serial2.begin(115200, SERIAL_8N1, 5, 13);^M
+        M5.begin(true, true, true, false, kMBusModeInput);^M
+        Serial2.begin(115200, SERIAL_8N1, 13, 14);^M

        Disbuff.createSprite(320,20);
        Disbuff.fillRect(0,0,320,20,BLACK);
diff --git a/Module/COMX_NB-IoT/TFTTerminal.h b/Module/COMX_NB-IoT/TFTTerminal.h
index 6142e42..2b6d1d6 100644
--- a/Module/COMX_NB-IoT/TFTTerminal.h
+++ b/Module/COMX_NB-IoT/TFTTerminal.h
@@ -1,7 +1,7 @@
 #ifndef _TFTTERMINAL_H_
 #define _TFTTERMINAL_H_

-#include <M5Stack.h>
+#include <M5Core2.h>^M
 #include <Print.h>

 class TFTTerminal : public Print

Flashing the Core2 with that and connecting serial monitor shows this and just the repeating AT+CSQ:

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:12804
ho 0 tail 12 room 4
load:0x40080400,len:3032
entry 0x400805e4
M5Core2 initializing...axp: vbus limit off
axp: gpio1 init
axp: gpio2 init
axp: rtc battery charging enabled
axp: esp32 power voltage was set to 3.35v
axp: lcd backlight voltage was set to 2.80v
axp: lcd logic and sdcard voltage preset to 3.3v
axp: vibrator voltage preset to 2v
E (1435) ledc: ledc_channel_config(369): gpio_num argument is invalid
touch: FT6336 ready (fw id 0x10 rel 1, lib 0x300E)
OK
AT+CSQ
AT+CSQ
AT+CSQ
...

What am I doing wrong?

Thanks for any help!