Sparkfun AS7331 UV Sensor With Arduino R4 WiFi QWIIC Connector (wire1)

Hi there! I am trying to connect an AS7331 UV sensor to an Arduino R4 WiFi’s QWIIC connector (wire1), and cannot find how to set it up on Wire1. I am also using a SSD1306 OLED on the same wire1 bus (Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);).

I have set up the sensor per the Sparkfun Arduino library ( SfeAS7331ArdI2C myUVSensor; ), but do not know where to tell it to use I2C1 bus. Hopefully this will be a quick and easy answer. Thank you for your help.

Hi @electromechpro ,

This line of library code is the critical one. If your sensor is using the default 0x74 address, your code will be:

    Wire1.begin();

    // Initialize sensor and run default setup.
    if (myUVSensor.begin(0x74, Wire1) == false)
    {
        Serial.println("Sensor failed to begin. Please check your wiring!");
        Serial.println("Halting...");
        while (1)
            ;
    }

I hope this helps,
Paul

1 Like