Si115X not running on MKR WiFi 1010

Hi, I'm trying to get the Grove Sunlight Sensor working with the manufacturer's example code...

With the Arduino UNO, I can make it work by connecting the SDA and SCL to the respective inputs on the UNO, in addition to the 5v and GND. But the same not with the Arduino MKR 1010 WIFI, neither connecting pins 11 and 12 (SDA and SCL) and 5v and GND on the board (without the carrier), nor connecting it by Glove cable to the TWI (Two-Wire Interface) connector of the MKR Connector Carrier.

Is it that to run on the Arduino MKR 1010 WIFI? Do I need to change the code or add something? Or maybe I'm connecting it wrong?

It's extremely hard to tell, from my side, as you didn't provide any photos or diagrams of your wiring. Or, any code. Did you read the forum instructions when you posted?

So what voltage do you supply to that sensor board?

It could be that it is a 5V board, in which case connecting it to a 3V3 MKR 1010 Board will damage the MKR unless you have an I2C level shifter between the two boards.

The sunlight sensor page you provided a link to says that it will operate from 3.0-5.5V at around 3.5mA. Supply it with 3.3V from your MKR1010 and your logic levels will be correct.

I'm not a MKR user so don't know if the I2C device scanner code works for your board. If it does, I'd start by seeing if your sensor can be detected.

I think so too. Thanks.

Connecting from the UNO, I tried both with the 3.3v output and the 5v output... both work. I don't think the problem is here, but thanks anyway.

Forgive me, I can try to be more explicit:

I've started with the manufacturer's example code, it's in the attached link, but I'll repeat it here too:

#include "Si115X.h"
Si115X si1151;
 
void setup() {
    uint8_t conf[4];
    Wire.begin();
    Serial.begin(115200);
    if (!si1151.Begin())
        Serial.println("Si1151 is not ready!");
    else
        Serial.println("Si1151 is ready!");
}
 
void loop()
{
    Serial.println(si1151.ReadHalfWord());
    Serial.println(si1151.ReadHalfWord_VISIBLE());
    Serial.println(si1151.ReadHalfWord_UV());
    delay(100);
}

With this code, with the Arduino UNO, connected to the Grove Sunlight Sensor at the SDA, SCL, 5v and GND inputs (I also tried it with 3.3v), everything goes well.

The same code, with the Arduino MKR 1010 WIFI, connecting to connectors 11 and 12 (which are supposed to be the SDA and SCL inputs of the MKR 1010) and also to 3.3v and GND... it doesn't work anymore, I get this error:

Arduino:1.8.19 (Linux), Board:"Arduino MKR WiFi 1010"
sketch/testes.ino.cpp.o: In function `loop':
/home/pi/Documents/Arduino projects/testes/testes.ino:27: undefined reference to `Si115X::ReadHalfWord()'
/home/pi/Documents/Arduino projects/testes/testes.ino:29: undefined reference to `Si115X::ReadHalfWord_VISIBLE()'
/home/pi/Documents/Arduino projects/testes/testes.ino:31: undefined reference to `Si115X::ReadHalfWord_UV()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino MKR WiFi 1010.

I hope that with that you have more information and can help me.
Thank you very much!

The code must compile without errors, before you can decide whether it works.

You need to include the sensor library that is correct for the MCU on your MKR board. One may not exist.

Please reply to post #4.

I don't think you understand what I am saying. Why post a question if you are going to dismiss an answer without even trying it. OK your loss.
Best of luck with your project, I will not reply again in this thread.
Goodbye.

The code compiles without errors on Arduino UNO.
I will look for MKR libs...
Thank you.

I don't think it's a 3.3 or 5v problem. Maybe, I don't know how to connect an I2C sensor, not directly through the pin connectors or the carrier...
It could also be that I need a lib for the Arduino MKR WiFi 1010 that the UNO already has on one's chip AVR board, and the other is SAMD)...
I'll keep trying; thanks!

First step when having i2c issues is to run an i2c scanner to see if your device is detected.

Great idea! I'll try it! :slightly_smiling_face:

Hi markd833,

Done! Running the i2c scanner on the Arduino UNO, I got one result. But, running the same on the Arduino MKR WiFi 1010, I got three results!!

---I2C Scanner---
Scanning...
I2C device found at address 0x53!
I2C device found at address 0x60!
I2C device found at address 0x6B!
done

So when I ran the code below on the Arduino UNO, where there was only one i2c device, everything worked perfectly!

#include "Si115X.h"
Si115X si1151;
 
void setup() {
    uint8_t conf[4];
    Wire.begin();
    Serial.begin(115200);
    if (!si1151.Begin())
        Serial.println("Si1151 is not ready!");
    else
        Serial.println("Si1151 is ready!");
}
 
void loop()
{
    Serial.println(si1151.ReadHalfWord());
    Serial.println(si1151.ReadHalfWord_VISIBLE());
    Serial.println(si1151.ReadHalfWord_UV());
    delay(100);
}

Running the same thing on the Arduino MKR WiFi 1010, the one where three i2c devices were found, I already get the error:

Arduino:1.8.19 (Linux), Board: "Arduino MKR WiFi 1010"
sketch/testes.ino.cpp.o: In function `loop':
/home/pi/Documents/Arduino projects/testes/testes.ino:27: undefined reference to `Si115X::ReadHalfWord()'
/home/pi/Documents/Arduino projects/testes/testes.ino:29: undefined reference to `Si115X::ReadHalfWord_VISIBLE()'
/home/pi/Documents/Arduino projects/testes/testes.ino:31: undefined reference to `Si115X::ReadHalfWord_UV()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino MKR WiFi 1010

So, I'm wondering if somehow instantiate this object:

Si115X si1151;

I shouldn't define what device_address 0xXX I'm trying to connect to get the results I need here:

Si1151.ReadHalfWord());
Si1151.ReadHalfWord_VISIBLE());
Si1151.ReadHalfWord_UV());)

What do you think?

Interesting, I unplugged my new i2c sensor of the MKR WiFi 1010, and now the scanner returns two devices... So, I understand that the i2c address of my new Grove Sunlight Sensor is 0x53! :wink:

The 2 other I2C devices are likely on-board your MKR1010 board. I don't have the details to hand at the moment so I can't enlighten you as to what they are.

EDIT: They are the crypto unit and the radio module.

So, I think the answer is about how to connect the object Si115X si1151 with address 0x53! :melting_face:

I'm looking for something like:

si1151(0x53)
si1151.parameter.I2CAddress = 0x53
Wire.begin(0x53);
si1151.Begin(0x53)

Check the library docs and/or code.

I look at the lib docs and found that they internally are already referring to that 0x53 address...

There are no problems running the Si1151 example on an Arduino UNO…

Is it not running because Arduino MKR Wifi 1010 has two other i2c devices onboard? :roll_eyes: