Erriez BH1750 library for Arduino  1.1.2
This is a GY-302 breakout with an I2C BH1750 digital light sensor.
Public Member Functions | Protected Member Functions | List of all members
BH1750 Class Reference

BH1750 class. More...

#include <ErriezBH1750.h>

Public Member Functions

 BH1750 (uint8_t addrPinLevel=LOW)
 Constructor. More...
 
void begin (BH1750_Mode_e mode, BH1750_Resolution_e resolution)
 Set mode and resolution. More...
 
void powerDown ()
 Power down. Call startConversion() to power-up automatically.
 
void startConversion ()
 Start conversion.
 
bool isConversionCompleted ()
 Wait for completion. More...
 
bool waitForCompletion ()
 Wait for completion. More...
 
uint16_t read ()
 Read light level asynchronous from sensor The application is responsible for wait or checking a completed conversion, otherwise the last conversion value may be returned which may not be correct. The last value is also returned when the device is in power-down. More...
 

Protected Member Functions

void writeInstruction (uint8_t instruction)
 Write instruction to sensor. More...
 
void setTimestamp ()
 Save current time + minimum delay before reading next conversion in ms.
 

Detailed Description

BH1750 class.

Definition at line 53 of file ErriezBH1750.h.

Constructor & Destructor Documentation

◆ BH1750()

BH1750::BH1750 ( uint8_t  addrPinLevel = LOW)
explicit

Constructor.

Parameters
addrPinLevelSensor I2C address: ADDR pin = LOW: 0x23 (default) ADDR pin = HIGH: 0x5C

Definition at line 44 of file ErriezBH1750.cpp.

Member Function Documentation

◆ begin()

void BH1750::begin ( BH1750_Mode_e  mode,
BH1750_Resolution_e  resolution 
)

Set mode and resolution.

Parameters
modeModeContinuous for continues mode Continues conversion requires more power ModeOneTime for one-time conversion mode Set in low power when conversion completed
resolutionResolution05Lux for high resolution (max 180ms conversion) Resolution1Lux for normal resolution (max 180ms conversion) Resolution4Lux for low resolution (max 24ms conversion, low power)

Definition at line 66 of file ErriezBH1750.cpp.

◆ isConversionCompleted()

bool BH1750::isConversionCompleted ( )

Wait for completion.

Returns
true: Conversion completed false: Conversion busy

Definition at line 105 of file ErriezBH1750.cpp.

◆ read()

uint16_t BH1750::read ( )

Read light level asynchronous from sensor The application is responsible for wait or checking a completed conversion, otherwise the last conversion value may be returned which may not be correct. The last value is also returned when the device is in power-down.

Returns
Light level in lux (0..65535) In high resolution, the last digit is the remainder

Definition at line 162 of file ErriezBH1750.cpp.

◆ waitForCompletion()

bool BH1750::waitForCompletion ( )

Wait for completion.

Returns
true: Conversion completed false: Not initialized, or timeout

Definition at line 125 of file ErriezBH1750.cpp.

◆ writeInstruction()

void BH1750::writeInstruction ( uint8_t  instruction)
protected

Write instruction to sensor.

Parameters
instructionSensor instruction

Definition at line 215 of file ErriezBH1750.cpp.


The documentation for this class was generated from the following files: