MKR IoT Carrier - Faulty Light Sensor?

This code is in the loop for all of the IoT projects that involve light detection, and it completely kills my programs:

while (!carrier.Light.colorAvailable()) {
delay(5);
}

If I leave this block inside my loop() function, either:

  • No output ever appears on the serial monitor. Arduino shows as offline on the Things setup page.
  • Serial outputs 3 loop iterations and then stops. Arduino shows as offline on the Things setup page.

Example of the output from #2:

Sd card not detected
WiFi.status(): 0
Current WiFi Firmware: 1.4.3
Gyroscope: X: 0.73 Y: -2.56 Z: -4.21
Light: 693
PIR State: 0
Gyroscope: X: 0.61 Y: -2.44 Z: -4.21
Light: 601
PIR State: 0
Gyroscope: X: 0.73 Y: -2.44 Z: -4.09
Light: 581
PIR State: 0

After this, the device just stops doing anything. I've tried increasing the delay in the loop to 1000 just to see what happens, and in that case the program only outputs 2 iterations of the loop instead of 3.

If I don't run this loop, the light sensor seems to give me a random nonsense value (either 0 or 252) for the fourth parameter:

carrier.Light.readColor(none, none, none, light);

The "light" variable will just randomly switch between 0 and 252 no matter what the ambient light of the room is.

I've tried just calling carrier.Light.colorAvailable() in the loop without putting it inside the while(), and that lets my programs run but it doesn't fix the output of the sensor being random.

So any ideas? Is my light sensor just faulty? I am having issues with the buttons on this carrier as well (it is constantly detecting Button 0 presses), at this point I am wondering if my unit is defective.

EDIT - So I put in a variable to monitor the return value of the colorAvailable() function, and it seems to only return 1 one time at the start of my program and then returns 0 forever after (see red lines below):

Sd card not detected
WiFi.status(): 0
Current WiFi Firmware: 1.4.3
ColorAvail: 0
Gyroscope: X: 0.67 Y: -2.44 Z: -4.09
Light: 0
PIR State: 0
ColorAvail: 1
Gyroscope: X: 0.61 Y: -2.44 Z: -4.15
Light: 690
PIR State: 0
ColorAvail: 0
Gyroscope: X: 0.73 Y: -2.56 Z: -3.97
Light: 690
PIR State: 0
ColorAvail: 0
Gyroscope: X: 0.73 Y: -2.50 Z: -3.97
Light: 690
PIR State: 0

After hours of debugging, I finally found the culprit but I don't know what to do about it...

I put the Read_Colors sketch example for the MKR IoT Carrier onto my kit and it worked. I copied the body of the loop() of that sketch and pasted it into mine, commenting out everything else except for the call to ArduinoCloud.update(). I ran this, and it still would break after a couple of loop iterations.

But then I commented out the call to ArduinoCloud.update(), and it ran just fine. So something about this ArduinoCloud.update() function does not work with the light sensor reading functions.

If I leave the ArduinoCloud.update(); function commented though, I can't use any of the IoT features which was the whole point of the kit. So until they fix this ArduinoCloud library I guess I am stuck choosing between using IoT features and using the light sensor...

I don't seem to have that problem with my Opla kit - the light sensor seems to work as advertised, most of the time.

The Arduino Cloud integration does seem very fragile - in running the Opla/IoT Carrier project sketches, often takes 2 or 3 tries to have that connection work and then data updates start and stop frequently.

The temperature sensor on my Opla board reads about 8 degrees higher than my house thermostats and an Adafruit Si7021 sensor module I have running with an Uno board. I thought maybe it was because of the case restricting air flow, but took the board back out of the case and the same.

I agree here, arduino cloud connection seems too fragile and not self healing. @k3tn I have the same issue, 7-8 degrees difference at 21 degrees celsius which is basically useless for thermostat purposes. But it's a fun product. It should be possible to map the difference though, if you have a good thermometer and maybe measure at 0 and 30 degrees I think a decent result can be achieved with a simple map command. I think the display and board itself gives a little heat away, maybe that is the true culprit here.

when connection to the cloud in setup function try changing to this:
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

I’ve tried that - did seem to make connecting to the ArduinoCloud easier. Then, did seem to stay connected longer but still frequent loss of cloud connectivity and dashboards showing old data.

I was tweaking my sketch and went to upload and the IDE said I needed to now update WiFi1010 firmware, as a new release that improved connectivity was available. Right now I am enjoying about 4 hours of solid connectivity but I’ll see how long this will last!

same here. Temperature is reading 27 degrees on a cold windy raining UK day. Anyone who lives in UK will realise how ridiculous a 27 degree temperature reading is.

Really disappointing as I wanted a display with temp, guess will have to look elsewhere.

Just got my Opla today and tested it with the sample project on the temperature sensor. I too am disappointed the sensor is not accurate. It is about 4-6c warmer than the room temperature.

Anyone has any idea on how to the calibration the sensor?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.