Dear community,
I’m working on an IoT project using the Arduino Portenta H7 Lite Connected and the corresponding NB-IoT-GNSS Shield to build a remote device IoT-Device:
Version: 4.0.10 (Was not able to use 4.1.1 with Arduino IDE => Uploading failed)
I am facing multiple problems implementing the GSM functionalities to suit my project.
I’m trying to implement a measure-send-sleep-cycle where the device gathers data and sends it via TCP to a server and then goes to sleep in a reoccurring circular fashion. See the following code:
void setup() {
Serial.begin(9600);
Serial.println(data);
while(!Serial) {}
GSM.trace(Serial);
GSM.setTraceLevel(4);
Serial.println("Starting Carrier Network registration");
if(!GSM.begin(pin, apn, username, pass, CATNB, BAND_20 | BAND_19)){
Serial.println("The board was not able to register to the network...");
// do nothing forevermore:
while(1);
}
}
I simplified my code in the loop to a bare sending of data and receiving. Data are just some bytes of results which should be send to the server.
void loop() {
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, port)) {
Serial.println("connected to server");
client.print(data);
while (client.read() != -1);
Serial.println("finished sending.");
} else {
Serial.println("unable to connect to server");
}
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
Serial.write(c);
}
Serial.println("disconnecting from server.");
client.stop();
Serial.println("Test sleep...");
delay(30000);
Serial.println("Wakeup...");
}
The issue is now after tow successful sends, i can not send anymore. How is the correct usage of the GSM Class if i want to send every 10 Minutes a package to a remote server. The Example on the documentation is just a "one time send".