Examples

get ambient light

Read ambient light value from BH1750FVI
==========================================================

Basic example to read the current value of ambient light from Rohm sensor BH1750FVI.
################################################################################
# Ambient light Example
#
# Created: 2020-08-03
# Author: S. Torneo
#
################################################################################

import streams
from rohm.bh1750fvi import bh1750fvi

streams.serial()

try:
    # Setup sensor 
    print("start...")
    sensor = bh1750fvi.BH1750FVI(I2C0)
    print("Ready!")
    print("--------------------------------------------------------")
except Exception as e:
    print("Error: ",e)

try:
    while True:
        ambient_light = sensor.get_value()
        print("Ambient light: ", ambient_light, "lx")
        print("--------------------------------------------------------")
        sleep(1000)
except Exception as e:
    print("Error2: ",e)