Portenta H7 not connecting to iot.arduino.cc

hey, please i have the same issue as reported at Uno R4 WiFi not connecting to iot.arduino.cc, but i use a portenta h7 and a 4G GLOBAL module. I have provisioned the device twice, but it is still not working. Does anyone has an idea of what I should do ?? @arduino_team. Below is the code...
#include "thingProperties.h"
#include <Arduino_Cellular.h>
#include <Timezone.h>

ArduinoCellular cellular;

const int LED_PIN = LED_BUILTIN; // Using built-in LED

// Example rules (adjust the specifics to match your locale)
/
// with DST starting on the second last Sunday in March and ending on the first Sunday in November.
TimeChangeRule dstRule = {"DST", Second, Sun, Mar, 2, 1 * 3600}; // DST offset: +1 hours
TimeChangeRule stdRule = {"STD", First, Sun, Nov, 2, 0 * 3600}; // Standard time: +0 hours
Timezone myTZ(dstRule, stdRule);

String getCurrentTime() {
// Retrieve the current UTC time from ArduinoCloud
long utcTime = ArduinoCloud.getLocalTime();

if (utcTime < 100000) {
return "Time not available";
}

// Convert to local time using the Timezone library
time_t localTime = myTZ.toLocal(utcTime);

// Convert Unix timestamp to human-readable format
struct tm *timeInfo = localtime(&localTime);
char buffer[80];
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeInfo);

return String(buffer);
}

/

void setup() {
// Initialize serial and wait for port to open:
Serial.begin(115200);
Serial1.begin(115200);
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }

// Defined in thingProperties.h
initProperties();
cellular.setDebugStream(Serial); // Enable debug output
cellular.begin();
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { }
Serial.println("Connecting to cellular network...");
if (!cellular.connect()) {
Serial.println("Failed to connect to cellular network!");
while (1);
}
Serial.println("Connected to cellular network!");

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4 OR DBG_INFO
*/
setDebugMessageLevel(DBG_INFO);
ArduinoCloud.printDebugInfo();

/*
Invoking addCallback on the ArduinoCloud object allows you to subscribe
to any of the available events and decide which functions to call when they are fired.

  The functions `doThisOnConnect`, `doThisOnSync`, `doThisOnDisconnect`
  are custom functions and can be named to your likings and for this example
  they are defined/implemented at the bottom of the Sketch

*/
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::CONNECT, doThisOnConnect);
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::SYNC, doThisOnSync);
ArduinoCloud.addCallback(ArduinoIoTCloudEvent::DISCONNECT, doThisOnDisconnect);
}
unsigned long lastTimePrint = 0;
void loop() {
ArduinoCloud.update();
/
digitalWrite(LED_PIN, (millis() % 2000) < 1000);
/if (millis() - lastTimePrint > 10000) {
Serial.println("Current UK Time: " + getCurrentTime());
lastTimePrint = millis();
}
/

}

void doThisOnConnect(){
/* add your custom code here /
Serial.println("Board successfully connected to Arduino IoT Cloud");
}
void doThisOnSync(){
/
add your custom code here /
Serial.println("Thing Properties synchronised");
}
void doThisOnDisconnect(){
/
add your custom code here */
Serial.println("Board disconnected from Arduino IoT Cloud");
}

2 posts were split to a new topic: SIM card not detected

Hi, i have tried connecting to the cloud using the h7 and the midcarrier. Each time i face this issue of ntp server. does any one has an idea of how i could solve it?

IF you need any extra information please let me know.

Manually set the APN in your code. Example:

modem.gprsConnect("your_apn", "username", "password");

Use the correct APN for your SIM provider (e.g., internet, web.gprs.mtnnigeria.net, etc.).

Hi, i have done that. it still did not work. I was looking at the time in the modem to see if there was any issue with it, i used AT commands to check it and fixed the time. I equally tried to see if it blocked connections by doing some pings and the pings worked.

hello everyone, just to know,the time issue is not appearing anymore, but now it does something else, it disconnects the serial port after sometime. And the connection to the cloud is not established yet. This happens when it is trying to connect to the 4g network. Note, it can do the other things like sending a message without an issue.

hey, i have connected as shown, but still have the same issue.


Hello, i am unable to connect to the arduino cloud using the standard code provided and have the following issue..., can someone help me? Below is my code and my outcome..

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/654ebe8f-1413-4eb0-a2ce-b3b0e728ed4b 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  - No variables have been created, add cloud variables on the Thing Setup page
    to see them declared here

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}
// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char GPRS_APN[]      = "prepay.tesco-mobile.com";
const char PINNUMBER[]     = "";
const char GPRS_LOGIN[]    = "tescowap";
const char GPRS_PASSWORD[] = "password";



void initProperties(){


}

CellularConnectionHandler ArduinoIoTPreferredConnection(PINNUMBER, GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);

This is the outcome...

hi, can someone help? Atleast view my issue. I can see topics that came after have far less views.

@alfmich1 are you using the Portenta Mid Carrier? Are you providing the 5V power supply from J4 Screw terminal block ?

hello, yes. I am using the portenta mid carrier and i use a 5v power supply connected to the gpio 5V i and gnd.

picture of the connections.

@alfmich1 from the image seems that you are not using J4 to provide the power supply to the MidCarrier. Please follow this link for the MidCarrier hardware setup.

Thanks pennam, i will do it right away.

1 Like

After you have completed the hardware setup and before loading an IoT sketch, you can try some examples from the ArduinoCellular library to test that everything works correctly.

hi, i have done that and i tried the modem terminal as well as the sendsms. They both work well.

Good, you can also try HTTPClient.ino to test internet connectivity :slightly_smiling_face:

just to add, when i try retrieving the time from the network(NITZ protocol), i have an empty quotes("").

ok, will do now.

Network time is retrived with the following commands:

Network NTP sync TinyGSM/src/TinyGsmClientBG96.h at f05bfa11ec770d45a335da2ba8300ccf58dfb0d0 · vshymanskyy/TinyGSM · GitHub

AT+QNTP=<contextID>,<server>[,<port>][,<autosettime>]

and then get time call

+QLTS=2