Trouble with programs on the MKR1010 Wifi with IoT Carrier: not remembering program

I have just completed the first activity in the Explore IoT kit, but my board is behaving strangely. From what I understand, when I unplug the board's USB after uploading, it should remember the program. However, the program does not work after I disconnect and then reconnect.

My serial output is also frequently throwing errors and saying some of the sensors are not connected.

The program works when I first upload it, and then once I disconnect and reconnect I get the error messages and it doesn't run properly. I am stuck on what to do and haven't been able to find any answers online.

do you have while (!Serial); in setup()?

Yes I do have it in setup but my problem persists. After a fresh upload the L1 & L2 lights are both off, but when I disconnect and reconnect they are both on. Not sure if that has anything to do with the problem.

while (!Serial); means "while not Serial do nothing"
so it will wait until Serial (USB) is connected

void setup() {
  
  Serial.begin(9600);  // Baud rate of 9600 | standard
  
  delay(1500);  // Wait to open Serial monitor to start program and see error details
  while (!Serial);

  // Set if enclosure is mounted
  CARRIER_CASE = false;

  // Initialize IoTSK carrier and output errors to serial monitor
  carrier.begin();
}

This is my setup function. The board still does not seem to remember the program when I disconnect and reconnect the USB.

port changes?
try to close Serial Monitor before reconnecting USB a then open it again

The board is consistently assigned COM3, and I have been plugging it into the same physical USB port on my computer in case that matters. Serial monitor remains closed the entire time, during the upload process and when I disconnect and reconnect.

I'm wondering if something is wrong with the actual board?

try it without while (!Serial);

Still does not work :frowning:

test it with Blink

The blink code I copied from here doesn't even execute on my board: https://docs.arduino.cc/built-in-examples/basics/Blink

I can't see the LED blinking at all. The board is connected to the carrier if that changes anything, but I don't believe it would affect the LED_BUILTIN.

It seems my LED_BUILTIN is working strangely. The LED_BUILTIN only blinks if my board is not attached to the IoT carrier. It doesn't work when connected to the carrier.

It seems the main issue now is that carrier.begin() is throwing errors, saying that none of the sensors are connected.

Error detected!
Pressure sensor is not connected!
Environmental sensor is not connected!
Air quality sensor is not connected!

Reset the MKR1010 Wifi board by double tapping the reset button fast and check the status of the onboard "L" LED. If the onboard LED fade in and out slowly (pulsating), upload an example sketch (Blink LED) from the IDE to the board. This will reset your board.
After this, try running some Arduino_MKRIoTCarrier examples ( with the carrier also powered by the recommended batttery) from the IDE to check that your board is now working fine. If this works fine, then remove any piece of code you have in your own sketch that waits for a serial (USB) connection to run in your sketch.
If the Arduino_MKRIoTCarrier examples does not work, then contact Arduino Support via https://www.arduino.cc/en/contact-us/

@Dozie please read all comments

The board is working fine. The problem lies with the IoT carrier not being able to connect to its sensors when I run my program, unless the program is a fresh upload.

Try updating or reinstalling the Arduino_MKRIoTCarrier library.

I have updated to the latest release, 2.0.1, and the issue still persists.

Any ideas of what else it might be? The latest release doesn't work either.

This is my entire piece of code:

#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;

float temperature = 0;
float humidity = 0;

void setup() {

  while(!Serial);
  Serial.begin(9600);  // Baud rate of 9600 | standard

  // Enclosure not mounted to case
  carrier.noCase();

  // Initialize IoTSK carrier and output errors to serial monitor
  carrier.begin();
}

// Display functions
void displayTemperature() {

  // Configure
  carrier.display.fillScreen(ST77XX_RED);      // Red bg
  carrier.display.setTextColor(ST77XX_WHITE);  // White text
  carrier.display.setTextSize(6);

  // Display
  carrier.display.setCursor(30, 50);
  carrier.display.print("Temp: ");
  carrier.display.setTextSize(4);
  carrier.display.setCursor(40, 120);
  carrier.display.print(temperature);
  carrier.display.print(" C");
}

int humidity_safety(double humidity) {
  if (humidity > 80.0) {
    return ST77XX_RED;
  } else if (60.0 <= humidity && humidity <= 80.0) {
    return ST77XX_YELLOW;
  }

  return ST77XX_GREEN;
}

void displayHumidity() {

  // Configure
  carrier.display.fillScreen(humidity_safety(humidity));  // Bg depends on safety of humidity
  carrier.display.setTextColor(ST77XX_WHITE);             // White text
  carrier.display.setTextSize(6);

  // Display
  carrier.display.setCursor(30, 50);
  carrier.display.print("Humi: ");
  carrier.display.setTextSize(4);
  carrier.display.setCursor(40, 120);
  carrier.display.print(humidity);
  carrier.display.print(" %");
}

void loop() {

  // Read sensor values
  temperature = carrier.Env.readTemperature();
  humidity = carrier.Env.readHumidity();

  // Update touch buttons
  carrier.Buttons.update();

  // Display values to serial monitor and screen
  Serial.println(temperature);

  if (carrier.Buttons.onTouchDown(TOUCH0)) {
    displayTemperature();
  }

  if (carrier.Buttons.onTouchDown(TOUCH1)) {
    displayHumidity();
  }
}

Contact Arduino tehnical support via https://support.arduino.cc/hc/en-us as suggested earlier

1 Like