Partial fix for MKRWIFI1010 not reading values from MKRIOTCarrier

I have the Explore IoT kit and when I tried running the code from Activity 2 (sending data to a dashboard) exactly as it was documented in the lesson, it did not work. There were 2 issues and I believe I have a solution for the first one.
The code to read the temperature and humidity sensors was returning 0.00 with the original code.
I added carrier.begin(); to the end of the setup function because I saw it used in most other examples and the result was that I was able to retrieve the correct values. They still aren't making the trip to the dashboard yet, so I'm still working on that.
It just seems odd to me that the published code does not work. Are they leaving that as a lesson for the students to figure out? I also had the same issue with the 'blink' example. It does not light the LED on my carrier, even though I checked the specs and found that it was using the correct pin. I never did get that to work.
I did not duplicate the code here because it's exactly as posted in the lesson, except for the addition I mentioned above.

Hello taarnac,
Welcome.

The problem with not duplicating the code here is you are assuming we are familiar with the tutorial you are using. I certainly am not and I suspect none of the regular contributors are either.

Please post your code and a link to the tutorial, and some information about the other parts you are using.

Thank you

Ah, my bad! Sorry, I assumed that since it was here on the Arduino site, everyone would have access to it.
I also am slapping my forehead because it appears that the carrier.begin() was in the original code and I must have had a cut-and-paste malfunction. I hope that doesn’t ruin my reputation… I really do try to do my due diligence before asking for help.

Here’s the link to the original code : https://explore-iot.arduino.cc/iotsk/module/iot-starter-kit/lesson/graphing-data-in-the-cloud, and I will post my code as well, with the diagnostic messages.

One other odd thing that I can’t seem to figure out is why it runs (almost) twice, and then just stops.
Here is the serial monitor output…

Connected to “BXMWR”
ArduinoCloud.connected = 0
ArduinoCloud.connected = 0
Sd card not detected
Apparently, we got us a connection…
Hey, we’re loopin here!
Connected to Arduino IoT Cloud
Got past the update
26.73,38.84
Temp:26.47
Wait just a second now!
Hey, we’re loopin here!
Got past the update
26.45,40.31
Temp:

Then… nothing!

/*
  Sketch generated by the Arduino IoT Cloud Thing "Activity2"
  https://create.arduino.cc/cloud/things/98537f73-8c41-4a4a-8db9-e05e2bbc3eb6

  Arduino IoT Cloud Properties description

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

  float humidity;
  float temperature;

  Properties 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"
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
bool CARRIER_CASE = false;

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(4);
  ArduinoCloud.printDebugInfo();

  //Wait to get cloud connection to init the carrier
  while (ArduinoCloud.connected() != 1) {
    Serial.print("ArduinoCloud.connected = ");
    Serial.println(ArduinoCloud.connected());
    ArduinoCloud.update();
    delay(500);
  }
  carrier.begin();
  Serial.println("Apparently, we got us a connection...");
}

void loop() {
  Serial.println("Hey, we're loopin here!");
  ArduinoCloud.update();
  Serial.println("Got past the update");
  
  //temperature = carrier.Env.readTemperature(FAHRENHEIT);
  humidity = carrier.Env.readHumidity();
  temperature = carrier.Env.readTemperature();

  Serial.print(temperature);
  Serial.print(",");
  Serial.println(humidity);
  
  Serial.print("Temp:");
  Serial.println(carrier.Env.readTemperature());

  Serial.println("Wait just a second now!");

  delay(1000);

}

taarnac:
Ah, my bad! Sorry, I assumed that since it was here on the Arduino site, everyone would have access to it.

The educational content is only accessible to those with the registration code that comes with the kit. Probably few of the forum regulars have purchased Arduino Education products.

So you should definitely be careful to provide all the relevant information when asking questions about the educational products here on the forum.

Hi Taarnac,

As Pert says, most if not all of the regular contributors don't have an educational kit and don't therefore have access to that part of this web site. For myself I have been messing with electronics since the age of about 6 when my dad helped me build a 'lighthouse' with a large cardboard tube, torch bulb and battery. I have no need for electronics kits. That link is therefore no use to me and probably no use to the other people who might be able to help.

Update : I kept experimenting and ended up commenting out where it was attempting to read the temperature a second time and pass it to the Serial.println function. This allowed the loop to continue. I'm not sure why that would have caused it to hang, but after I finish the lesson, I'll probably circle back and see if it was timing, or something else.

Thank you for replying. I also have a background in practical and industrial electronics from trade school back in the 70's (tube theory). Yup, I'm old :). Currently, I'm a professional data warehouse programmer in Intersystems Cache' language, but I'm about to retire and wanted to get back into electronics as a hobby, but of course, the landscape has changed since the 70's.

I look forward to some day helping others on this forum once I get some more experience.

I look forward to some day helping others on this forum once I get some more experience.

Go for it!