Grove Sunlight Sensor Library doesn't Work

Hi, Ive bought 2 Grove Sunlight Sensors from the Arduino Store (Advertised as Rev. 1 with Si1145 Chip) but recieved the Rev. 2 (Si1151 Chip?) and Ive attempted to communicate with the sensor using the 1151 Library, but It doesnt work
Using a Nano RP2040 / MKR WiFi 1010 with Arduino IDE 2.2.1
The I2C Connection does get recognized

Using a Library from Grove - Sunlight Sensor | Seeed Studio Wiki

#include <Wire.h>

#include <SI114X.h>
#include <Si115X.h>

Si115X si1151;

#define WIRE Wire

/**
 * Setup for configuration
 */
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!");

}

/**
 * Loops and reads data from registers
 */
void loop()
{
  Serial.println(si1151.ReadHalfWord());
    Serial.println(si1151.ReadHalfWord_VISIBLE());
    Serial.println(si1151.ReadHalfWord_UV());
    delay(100);

  delay(5000);           // wait 5 seconds for next scan
}

but it doesnt recognize “ReadHalfWord”

Does anyone have working Code or a Fuctioning Library for this sensor?
Any ideas how I can troubleshoot this?

Hi, I am also attempting to use this sensor. Did you manage to get it working? The online libraries don’t seem to work for me

what are you working with?

With the MKR WiFi 1010 it simply isnt possible as it is missing parts in its library. Seeed said they are looking into the issue of the newer chip not having an updated library. So far Ive gotten it to work only on a simple arduino uno, and partly on a a Nano RP2040 but with exactly 3x the actual values.

I am working with the XIAO esp32s3 and the expansion board just trying to get any reading from the sensor. I wrote some code to check if there was an I2C address and there is, but I cannot seem to read any values from it.

Hi there,
Can you post the code , let us try it. See where it’s failing?
I don’t see that Keyword used “readHalfWord*”
I do see this , change the code and try it ?

SI114X	KEYWORD2
Begin	KEYWORD2
Reset	KEYWORD2
DeInit	KEYWORD2
ReadParamData	KEYWORD2
WriteParamData	KEYWORD2
ReadVisible	KEYWORD2
ReadIR	KEYWORD2
ReadProximity	KEYWORD2
ReadUV	KEYWORD2

HTH
GL :slight_smile: PJ
Try this one, from the GitHub.

#include "Si115X.h"

Si115X si1151;

/**
 * Setup for configuration
 */
void setup()
{
    Wire.begin();
    Serial.begin(115200);
    if (!si1151.Begin()) {
        Serial.println("Si1151 is not ready!");
        while (1) {
            delay(1000);
            Serial.print(".");
        };
    }
    else {
        Serial.println("Si1151 is ready!");
    }
}

/**
 * Loops and reads data from registers
 */
void loop()
{
    Serial.print("IR: ");
    Serial.println(si1151.ReadIR());
    Serial.print("Visible: ");
    Serial.println(si1151.ReadVisible());

    delay(500);
}

I tried this and it still did not work. I just got it to say IR with no values being printed. I have attached pictures of everything I have tried:

Hi there,
Looks to me like it’s a Library version issue, what errors do you get? also Try some other BSP’s roll back maybe or Check the Wire.Lib version your using. It’s a problem somewhere between the Keyboard and the Floor. :wink: :v:
your close though, Which BSP are you using, I would try the latest first(2.0.11) then, roll back to 2.0.8 and Go again. I bet that fixes it.
HTH
GL :slight_smile: PJ

I was using the 2.0.14 BSP but then I changed it to 2.0.8 and 2.0.11 and nothing seems to fix it. Somehow the program builds and I get no errors, and everything works until the IR value is not printed. I do get some warnings about the Wire and I am unsure where to go to fix that.

I even tried to just read the visible light readings and I don’t think any of the sensors are being read.

I think the halfword is meaning half of a bite from a register… so either a coms problem or maybe the version is using a different register?

Hi there,
Yes, the wire errors need fixing b4 it’s gonna work.
Seems strange, should work. Try removing the Version of Wire.lib you have and see if it finds the alternate. ( I would stay with 2.0.8.) see if you can fix the Wire issue first.
my .02
HTH
GL :slight_smile: PJ

Hi,
Do you know how I would change the version of Wire.lib. Is it the oneWire lib I have or is it something else I have to change. I have also tried uninstalling and reinstalling the Arduino Application and it doesn’t seem to do much

Hi there,
Can you be sure the Compiler is in verbose output and Post it up after you compile the code, The first 20 lines and the last 20 lines is sufficient.
Allot of folks Uninstall IDE and that never fixes anything, really.
Stick with troubleshooting the LIB’s I’m pretty sure that’s why it’s NOT working IMO.
HTH
Gl :slight_smile: PJ

I have attached the pictures:

Hi there,
OK, I was able to duplicate the build, and even with older BSP it has issue with Si1115.h
Try this I combined them and see if it gives any data, does compile same errors.


#include <Wire.h>
#include "Arduino.h"
#include "Si115X.h"
#include "SI114X.h"

SI114X SI1145 = SI114X();
Si115X si1151;

/**
 * Setup for configuration
 */
void setup()
{
    Wire.begin();
    Serial.begin(115200);
    if (!si1151.Begin()) {
        Serial.println("Si1151 is not ready!");
        while (1) {
            delay(1000);
            Serial.print(".");
        };
    }
    else {
        Serial.println("Si1151 is ready!");

        Serial.println("Beginning Si1145!");

    while (!SI1145.Begin()) {
        Serial.println("Si1145 is not ready!");
        delay(1000);
    }
    Serial.println("Si1145 is ready!");
    }
}

/**
 * Loops and reads data from registers
 */
void loop()
{
    Serial.print("IR: ");
    Serial.println(si1151.ReadIR());
    Serial.print("Visible: ");
    Serial.println(si1151.ReadVisible());
//the real UV value must be div 100 from the reg value , datasheet for more information.
    Serial.print("UV: ");  Serial.println((float)SI1145.ReadUV() / 100);
    delay(1000);
  Serial.print("//--------------------------------------//\r\n");
    Serial.print("Vis: "); Serial.println(SI1145.ReadVisible());
    Serial.print("IR: "); Serial.println(SI1145.ReadIR());
    //the real UV value must be div 100 from the reg value , datasheet for more information.
    Serial.print("UV: ");  Serial.println((float)SI1145.ReadUV() / 100);
    delay(1000);
}

HTH
GL :slight_smile: PJ