SiFive HiFive1 Rev B with BH1750 I2C Light Sensor

This is a library used for SiFive Hifive 1 Rev B board to communicate with BH1750 Digital Light Sensor and examples of how to use this it. The library used BH1750 GY-302 module to develop and test.


git clone

Build Examples

  • Use FreedomStudio IDE to create a new SiFive project for HiFive 1 Rev B board.
  • Copy library files include BH1750.c, BH1750.h, delay.c to the project
  • Select and copy an example source file in `examples` folder to the project
  • And build

Hardware Requirements

  • SiFive Hifive 1 Rev B board
  • BH1750 GY-302 module

Wire Connections

    HiFive1 Rev B      BH1750
    3V3           <--> VCC (3V3 or 5V)
    GND           <--> GND
    IO19 (SCL)    <--> SCL
    IO18 (SDA)    <--> SDA
    GND           <--> ADD (not connected or GND)

ADD pin is used to set sensor I2C address. If it has voltage greater or equal to 0.7VCC voltage (e.g. you’ve connected it to VCC) the sensor address will be 0x5C. In other case (if ADD voltage less than 0.7 * VCC) the sensor address will be 0x23 (by default).

Example of connect to one BH1750 Light Sensor
Example of connect to two BH1750 Light Sensors

Run Examples

Print values of two sensors

Development tools

SiFive IDE: FreedomStudio- (


Icons made by Freepik from