Wio LTE (4G) / I2C_LED Display

Hey,

unfortunately I don’t have any proper code anymore. But I had a look into the “TCPConnect” example provided by seeed (https://wiki.seeedstudio.com/Wio_LTE_Cat.1/#play-with-arduino).

If I try the code example as it is with a SIM card with PIN protection I don’t get behind the “Accessing network…” status which is looping endless because there is no PIN authentication implemented by default, if I disabled the PIN protection on the SIM (like described before) it works fine.

In my case I had to set the APN to “internet” but this depends on the provider. You can figure it out by putting the SIM in your phone and check the mobile connection settings after you are connected to the network.

To use a SIM with PIN protection you have to add an additional AT command to unlock the SIM before the initialization is started:

// Unlock SIM with PIN, replace "1234" with your actual PIN
check_with_cmd("AT+CPIN=1234\r\n", "", CMD, 1);

// Initialization
while (!eth.init()) {
    delay(1000);
    SerialUSB.println("Accessing network...");
}

Be careful with this code because there is no protection to not enter your PIN wrong three times which will lead into a blocked SIM (best have your PUK code ready…).

The whole script:

#include "ethernet.h"

Ethernet eth = Ethernet();

// APN setting here
const char apn[25] = "internet";

const char URL[100] = "google.com";
char http_cmd[100] = "HEAD / HTTP/1.0\r\n\r\n";

int port = 80;
int ret = 0;

void setup() {

    // Power up the modem...
    SerialUSB.println("Begin...");
    eth.Power_On();
    while (false == eth.Check_If_Power_On()) {
        SerialUSB.println("Waitting for module to alvie...");
        delay(1000);
    }

    // Unlock SIM with PIN, replace "1234" with your actual PIN
    check_with_cmd("AT+CPIN=1234\r\n", "", CMD, 1);

    // Initialization
    while (!eth.init()) {
        delay(1000);
        SerialUSB.println("Accessing network...");
    }

    SerialUSB.println("Initialize done...");

    eth.join(apn);
    SerialUSB.print("\n\rIP: ");
    SerialUSB.print(eth.ip_string);

    if (eth.connect(URL, port, TCP)) {
        eth.write(http_cmd);
        while (MODULE_PORT.available()) {
            serialDebug.write(MODULE_PORT.read());
        }
        eth.close(1);
    } else {
        SerialUSB.println("Connect Error!");
    }

}

void loop() {
    /* Debug */
    AT_bypass();
}

If everything works you should get a result similar to if you check the serial port monitor:

Waitting for module to alvie...
Waitting for module to alvie...
Waitting for module to alvie...




Initialize done...




IP: ##.###.169.137




+QIURC: "recv",0,567
HTTP/1.0 200 OK
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Date: Wed, 12 May 2021 11:47:31 GMT
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Expires: Wed, 12 May 2021 11:47:31 GMT
Cache-Control: private
Set-Cookie: NID=215=jzLvl3caiiscRCOzG-hiOitPen5gDJiSSQkLDsolhYQd_YAQDyt8X59HnUsawFJsNhO1zfQsLSWGUFagE1j9vyOkH4Oyo_cU2JpF5NPs9hA_Ssfp45O_Sgh2N0tendcGNF3kKGt89U2pR7Y2b0DMEmUNFfFu8ntdCfwz6azTE8Q; expires=Thu, 11-Nov-2021 11:47:31 GMT; path=/; domain=.google.com; HttpOnly



+QIURC: "closed",0

I hope this helps you!

Greetings
Patrick