![]() |
Erriez BH1750 library for Arduino
1.1.2
This is a GY-302 breakout with an I2C BH1750 digital light sensor.
|
#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. | |
BH1750 class.
Definition at line 53 of file ErriezBH1750.h.
|
explicit |
Constructor.
| addrPinLevel | Sensor I2C address: ADDR pin = LOW: 0x23 (default) ADDR pin = HIGH: 0x5C |
Definition at line 44 of file ErriezBH1750.cpp.
| void BH1750::begin | ( | BH1750_Mode_e | mode, |
| BH1750_Resolution_e | resolution | ||
| ) |
Set mode and resolution.
| mode | ModeContinuous for continues mode Continues conversion requires more power ModeOneTime for one-time conversion mode Set in low power when conversion completed |
| resolution | Resolution05Lux 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.
| bool BH1750::isConversionCompleted | ( | ) |
Wait for completion.
Definition at line 105 of file ErriezBH1750.cpp.
| 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.
Definition at line 162 of file ErriezBH1750.cpp.
| bool BH1750::waitForCompletion | ( | ) |
Wait for completion.
Definition at line 125 of file ErriezBH1750.cpp.
|
protected |
Write instruction to sensor.
| instruction | Sensor instruction |
Definition at line 215 of file ErriezBH1750.cpp.
1.8.13