techstudio-design / SimpleNB

A simple Arduino library for communication with NB-IoT/Cat-M1 modules
GNU Lesser General Public License v3.0
32 stars 4 forks source link

Expressif MCU support #7

Closed jftaylorMn closed 1 year ago

jftaylorMn commented 1 year ago

[ x] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[ ] Request to support a new module

[ ] Bug or problem compiling the library [ ] Bug or issue with library functionality (ie, sending data over TCP/IP) [ x] Question or request for help

What are you working with?

Modem: SImcon 7080G Main processor board: ESP32 SimpleNB version: latest Code: AllFunctionsTest

Scenario, steps to reproduce

Maybe this is just a request to improve the readme file...

I have very high hopes for this implementation of TinyGSM, but am stuck before any real testing can happen. Using an ESP32 "DevKitC" Development board in conjunction with a 7080G development board (with separate power supply). When running the AllFunctionsTest script, I see the modem is responding to the power pulldown, and changes form a quick flash to "connected" (once per 3 seconds) flash. The cellular provider is seeing "zero byte" connections, which suggests that the modem has basic communications. But nothing is successful after that.

[19] Powering Up... [3519] Communicate at baud rate 38400 ... [13619] No response from modem, check your hardware connection [24623] Failed to initialize modem, delaying 10s and retrying forever...

From the message, it appears that I don't know what pins to connect for rx and tx. I understand that rx on the mcu should connect to the tx on the modem and vice versa. I have tried GPIO 1 and 3, 16 and 17 in various combinations without luck. I have entered the APN into the script, but don't think we are where that will matter.

I have not done anything with serial communications on the ESP32 before - except for using the serial monitor in the Arduino IDE. From what I can tell, the ESP32 can use HardwareSerial to access the three different uarts. Before I dive deeper into the code, SHOULD this sketch work "out of the box" with ESP32?

Expected result

Connection to the cell modem would be established and selected tests would run

Actual result

"No response from modem, check your hardware connection"

Debug and AT command log

AT commands have not been entered yet. When I connect to the modem via USB, I get an "OK" when passing "AT" (as expected), so have no reason to suspect that the modem is bad.

techstudio-design commented 1 year ago

If you don't mind, can you tell us which country you are in and carrier you are using(this give us better understanding of your network and technology)?

Your description of LED seems to suggest that the module is able to register to the network, but somehow you are not be able to communicate with the Module via serial port. Pin 16 and 17 on ESP32 is for Serial2 which is the default we used for allFunctions.ino, in fact we test most of examples using an ESP32. So yes, ESP32 should work "out of the box". APN is not necessary for NB-IoT unless you are connecting via older 3G technology.

Here is the suggestions that we could think of for isolating the root cause: 1) Sim7080G is operated on 1.8V power domain, and your MCU could be either 3.3V or 5V, we don't know what SIM7080G development board you have, but in general there is a level-shifter on the interface (including Serial port) between the MCU and the SIM7080G, and in most of the design, there is a level-shifter enable pin that need to be connected to either the 3.3V or 5V depend on your MCU operating voltage. This is board specific and we don't know all the boards design available in the market, especially those from the Chinese markets. But this is the first thing I could think of when unable to communicate with Serial port, assumed TX/RX are connected correctly. 2) Uncomment the #define DUMP_AT_COMMANDS of the example code and download the StreamDebugger library in order to be able to see all the AT Commands communication between the module and the MCU. 3) If you have an USB-TTL Adaptor, instead of running an Arduino sketch, you can connect directly to your SIM7080G development board and manually interacts with the SIM7080G using AT commands until you are sure it works first. We describe this in our Getting Started with TechStudio SIM7080 Development Board.

BTW, here is the data log for the communication between an ESP32 using Serial2 and our very own SIM7080G development board, using http_get example with StreamDebugger code add-in to replace the line SimpleNB modem(SerialAT);.

[63] Powering Up...
[3563] Communicate at baud rate 115200 ...
[6072] Initializing modem...
[6072] ### SimpleNB Version: 1.0.0
[6072] ### SimpleNB Compiled Module:  SimpleNBClientSIM7080
AT
AT
OK
ATE0
ATE0
OK
AT+CMEE=2

OK
AT+GMM

SIMCOM_SIM7080

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

+CPIN: READY

OK
[6115] Waiting for network registration...
AT+CSQ

+CSQ: 22,99

OK
AT+CEREG?

+CEREG: 0,1

OK
[6132] Activate Data Network...
AT+CNACT=0,1

OK

+APP PDP: 0,ACTIVE
[7162] Connecting to postman-echo.com port 80
AT+CACLOSE=0

+CME ERROR: operation not allowed
AT+CACID=0

OK
AT+CASSLCFG=0,SSL,0

OK
AT+CAOPEN=0,0,"TCP","postman-echo.com",80

+CAOPEN: 0,0

OK
AT+CASEND=0,16

>GET /ip HTTP/1.1 
OK
AT+CASEND=0,2

>

OK
AT+CASEND=0,22

>Host: postman-echo.com 
OK
AT+CASEND=0,2

>

OK
AT+CASEND=0,17

>Connection: close 
OK
AT+CASEND=0,2

>

OK
AT+CASEND=0,2

>

OK
AT+CARECV?

OK
AT+CASTATE?

+CASTATE: 0,1

OK
AT+CARECV?

OK
AT+CASTATE?

+CASTATE: 0,1

OK

+CADATAIND: 0
[8746] ### Got Data on socket: 0

+CASTATE: 0,0
[8750] ### Closed socket: 0
AT+CARECV?

+CARECV: 0,353

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV=0,63

+CARECV: 63,HTTP/1.1 200 OK
Date: Tue, 06 Dec 2022 01:59:44 GMT
Content-T

OK
AT+CARECV?

+CARECV: 0,290

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV=0,63

+CARECV: 63,ype: application/json; charset=utf-8
Content-Length: 22
Conne

OK
AT+CARECV?

+CARECV: 0,227

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV=0,63

+CARECV: 63,ction: close
ETag: W/"16-PVkhkwm67Ps7Z9YKW1v+BVifcgw"
Vary: A

OK
AT+CARECV?

+CARECV: 0,164

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV?

+CARECV: 0,164

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV=0,63

+CARECV: 63,ccept-Encoding
set-cookie: sails.sid=s%3A7Hr2ub2Xx_dyieIvhxHb9

OK
AT+CARECV?

+CARECV: 0,101

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV=0,63

+CARECV: 63,e8I6kkp5etW.Hg%2FE2GS22RgvGcKzoVW4ZnTtJaAAH8ReKwaJc9NG9ag; Path

OK
AT+CARECV?

+CARECV: 0,38

OK
AT+CASTATE?

+CASTATE: 0,0

OK
AT+CARECV=0,38

+CARECV: 38,=/; HttpOnly

{"ip":"111.65.56.238"}

OK
AT+CARECV?

OK
AT+CASTATE?

+CASTATE: 0,0

OK
[9094] Your IP address is: xxx.xx.56.238
AT+CACLOSE=0

OK
[9104] Deactivate Data Network... 
AT+CNACT=0,0

OK
[9119] Powering Down...
[10319] Done!

Hope this will help.

jftaylorMn commented 1 year ago

Thank you for your prompt reply. With the popularity of the ESP32, I would have been surprised if you said you haven't tested. The short answer is that you can close this issue. My only suggestion is to update the readme to provide mention of ESP32 and which pins will be enabled. I became sidetracked when I found information on ESPSoftwareSerial and HardwareSerial.

Read ahead if you want to know more details.

A fresh allfunction.ino sketch ran with expected results after confirming that ground, rx, tx (and external power) were properly connected, Knowing that Serial2 (GPIO16 and 17) were being used is probably the root cause of my issues. I am using a hologram SIM card which picks the best available network. I am located in Minnesota in an urban area. The serial output says that's T-Mobile with signal quality of 30. My intended use for this is in the north woods where cell towers are farther away. I'm not sure what technology I'll find available there.

After un-commenting line 90, I got a compile error related to StreamDebugger.h which was resolved with importing the library.

The only section of the output that looked a bit wrong in my output was

,,, [7338] Connecting to postman-echo.com port 80 AT+CACLOSE=0

+CME ERROR: operation not allowed AT+CACID=0

OK ... This text is also in your output, so I think it's fine.

I will test some other options (e.g. SMS) tomorrow.

FYI.. This is the dev board I am using. -> https://www.aliexpress.us/item/2255800849405910.html?spm=a2g0o.order_list.order_list_main.31.663a1802yMKn4J&gatewayAdapt=glo2usa4itemAdapt&_randl_shipto=USIt is similar but not identical to yours. The only pin that I haven't connected is the standby pin. It's not clear why there need to be two ground pins, but I did connect both,

Thanks again for your help, and the library! It should help my project tremendously.

John

On Mon, Dec 5, 2022 at 8:06 PM Tech Studio Design @.***> wrote:

If you don't mind, can you tell us which country you are in and carrier you are using(this give us better understanding of your network and technology)?

Your description of LED seems to suggest that the module is able to register to the network, but somehow you are not be able to communicate with the Module via serial port. Pin 16 and 17 on ESP32 is for Serial2 which is the default we used for ]allFunctions.ino]( https://github.com/techstudio-design/SimpleNB/blob/master/examples/AllFunctions/AllFunctions.ino#L28), in fact we test most of examples using an ESP32. So yes, ESP32 should work "out of the box". APN is not necessary for NB-IoT unless you are connecting via older 3G technology.

Here is the suggestions that we could think of for isolating the root cause:

  1. Sim7080G is operated on 1.8V power domain, and your MCU could be either 3.3V or 5V, we don't know what SIM7080G development board you have, but in general there is a level-shifter on the interface (including Serial port) between the MCU and the SIM7080G, and in most of the design, there is a level-shifter enable pin that need to be connected to either the 3.3V or 5V depend on your MCU operating voltage. This is board specific and we don't know all the boards design available in the market, especially those from the Chinese markets. But this is the first thing I could think of when unable to communicate with Serial port, assumed TX/RX are connected correctly.
  2. Uncomment the line 90 https://github.com/techstudio-design/SimpleNB/blob/master/examples/AllFunctions/AllFunctions.ino#L90 of the example code and download the https://github.com/vshymanskyy/StreamDebugger library in order to be able to see all the AT Commands communication between the module and the MCU.
  3. If you have an USB-TTL Adaptor, instead of running an Arduino sketch, you can connect directly to your SIM7080G development board and manually interacts with the SIM7080G using AT commands until you are sure it works first. We describe this in our Getting Started with TechStudio SIM7080 Development Board https://www.techstudio.design/getting-started-with-techstudio-sim7080-development-board/ .

BTW, here is the data log for the communication between an ESP32 using Serial2 and our very own SIM7080G development board, using http_get example with StreamDebugger code add-in to replace the line SimpleNB modem(SerialAT);.

[63] Powering Up... [3563] Communicate at baud rate 115200 ... [6072] Initializing modem... [6072] ### SimpleNB Version: 1.0.0 [6072] ### SimpleNB Compiled Module: SimpleNBClientSIM7080 AT AT OK ATE0 ATE0 OK AT+CMEE=2

OK AT+GMM

SIMCOM_SIM7080

OK AT+CLTS=1

OK AT+CBATCHK=1

OK AT+CPIN?

+CPIN: READY

OK [6115] Waiting for network registration... AT+CSQ

+CSQ: 22,99

OK AT+CEREG?

+CEREG: 0,1

OK [6132] Activate Data Network... AT+CNACT=0,1

OK

+APP PDP: 0,ACTIVE [7162] Connecting to postman-echo.com port 80 AT+CACLOSE=0

+CME ERROR: operation not allowed AT+CACID=0

OK AT+CASSLCFG=0,SSL,0

OK AT+CAOPEN=0,0,"TCP","postman-echo.com",80

+CAOPEN: 0,0

OK AT+CASEND=0,16

GET /ip HTTP/1.1 OK AT+CASEND=0,2

OK AT+CASEND=0,22

Host: postman-echo.com OK AT+CASEND=0,2

OK AT+CASEND=0,17

Connection: close OK AT+CASEND=0,2

OK AT+CASEND=0,2

OK AT+CARECV?

OK AT+CASTATE?

+CASTATE: 0,1

OK AT+CARECV?

OK AT+CASTATE?

+CASTATE: 0,1

OK

+CADATAIND: 0 [8746] ### Got Data on socket: 0

+CASTATE: 0,0 [8750] ### Closed socket: 0 AT+CARECV?

+CARECV: 0,353

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV=0,63

+CARECV: 63,HTTP/1.1 200 OK Date: Tue, 06 Dec 2022 01:59:44 GMT Content-T

OK AT+CARECV?

+CARECV: 0,290

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV=0,63

+CARECV: 63,ype: application/json; charset=utf-8 Content-Length: 22 Conne

OK AT+CARECV?

+CARECV: 0,227

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV=0,63

+CARECV: 63,ction: close ETag: W/"16-PVkhkwm67Ps7Z9YKW1v+BVifcgw" Vary: A

OK AT+CARECV?

+CARECV: 0,164

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV?

+CARECV: 0,164

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV=0,63

+CARECV: 63,ccept-Encoding set-cookie: sails.sid=s%3A7Hr2ub2Xx_dyieIvhxHb9

OK AT+CARECV?

+CARECV: 0,101

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV=0,63

+CARECV: 63,e8I6kkp5etW.Hg%2FE2GS22RgvGcKzoVW4ZnTtJaAAH8ReKwaJc9NG9ag; Path

OK AT+CARECV?

+CARECV: 0,38

OK AT+CASTATE?

+CASTATE: 0,0

OK AT+CARECV=0,38

+CARECV: 38,=/; HttpOnly

{"ip":"111.65.56.238"}

OK AT+CARECV?

OK AT+CASTATE?

+CASTATE: 0,0

OK [9094] Your IP address is: xxx.xx.56.238 AT+CACLOSE=0

OK [9104] Deactivate Data Network... AT+CNACT=0,0

OK [9119] Powering Down... [10319] Done!

Hope this will help.

— Reply to this email directly, view it on GitHub https://github.com/techstudio-design/SimpleNB/issues/7#issuecomment-1338625820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENX2LU55PX333A43BSYD5LWL2NUBANCNFSM6AAAAAASUV3BUY . You are receiving this because you authored the thread.Message ID: @.***>

techstudio-design commented 1 year ago

Glad everything works out for you.

For SMS, you might want to check with your carrier (Hologram -> T-Mobile) as majority of the NB-IOT/CAT M networks in the world does not has the provisioning to support SMS over NB-IoT/CAT M network unless you are on 3G/LTE network, I think among all the US carriers, AT&T is the only support SMS over NB-IoT...