Some sensors can only be interfaced with microcontrollers via the I2C protocol.
These include sensors such as UV light, inertial measurement unit (IMUs), barometric pressure, accurate temperature sensors. Some I2C devices are also output devices, such as 8x8 LED matrices, LCD displays etc.
Here we will focus on sensors, in our case a UV light index sensor.
The key to successfully working with I2C sensors is to find one that provides an extensive Arduino code library and examples that allow for easy setup and testing. One could write low-level libraries to interface with the sensor chip, but that can take a lot of time.
In our case, choose I2C sensors that can operate at 3.3V. The good news is most if not all I2C sensors are compatible with 3.3V.
Wiring is simple – just power, ground, a data line and a clock line. Code-wise, it all depends on the level of support provided by the author of the code library. Typically most Adafruit and Sparkfun-designed sensor boards have excellent documentation and examples.
As a reminder, you need to explicitly define the software I2C pins on the mote mini to 2 (SDA) and 14 (SCL) – refer to the code example below on how to do this.