UPM C API for the DFRobot I2C BH1750 Light Sensor.
More...
This driver was developed with the DFRobot Light Sensor based on the BH1750. It has a sensitivity of .5 10 65535 Lux. It supports voltages from 3-5vdc and is connected via I2C.
while (shouldRun) {
cout <<
"Detected Light Level (lux): " << sensor.
getLux() << endl;
upm_delay(1);
}
BH1750 |
( |
int |
bus = BH1750_DEFAULT_I2C_BUS , |
|
|
int |
addr = BH1750_DEFAULT_I2C_ADDR , |
|
|
BH1750_OPMODES_T |
mode = BH1750_OPMODE_H2_ONCE |
|
) |
| |
BH1750 object constructor (Analog mode)
- Parameters
-
bus | The I2C bus to use |
addr | The I2C address of the device |
mode | The mode to start operation under. One of the BH1750_OPMODES_T values. The default is the highest precision, lowest power mode. |
Reset the device. This doesn't really have much purpose. The device must be powered up for this command to work. In addition, this command will simply clear the measurement register to 0.
Get the measured light intensity in Lux.
- Returns
- The measured light intensity in Lux.
void setOpmode |
( |
BH1750_OPMODES_T |
mode | ) |
|
Setup the device to match the selected operating mode.
- Parameters
-
mode | operating mode, one of the BH1750_OPMODES_T values |
void sendCommand |
( |
uint8_t |
cmd | ) |
|
|
protected |
Sends a command to the device via I2C.
- Parameters
-
cmd | The command to write, one of the BH1750_CMD* values |
Read the 2 result bytes from the device via I2C.
- Returns
- Data read in from the device as a uint16_t
The documentation for this class was generated from the following files: