Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BH1750 Class Reference
Interface for Luminosity sensor, BH1750. More...
#include <BH1750.h>
Public Member Functions | |
BH1750 (PinName p_sda, PinName p_scl) | |
Configure data pin. | |
BH1750 (I2C &p_i2c) | |
Configure data pin (with other devices on I2C line) | |
float | lux (void) |
Get Illuminance, unit of Lux. | |
void | set_sensitivity (uint8_t parameter) |
Set sensor sensitivity adjustment. | |
void | frequency (int hz) |
Set I2C clock frequency. | |
void | power_up (void) |
Power Up/Down. |
Detailed Description
Interface for Luminosity sensor, BH1750.
#include "mbed.h" #include "BH1750.h" // I2C Communication BH1750 lum(dp5,dp27); // BH1750 SDA, SCL // If you connected I2C line not only this device but also other devices, // you need to declare following method. I2C i2c(dp5,dp27); // SDA, SCL BH1750 lum(i2c); // BH1750 SDA, SCL (Data available every 120mSec) int main() {; while(true){ printf("Illuminance: %+7.2f [Lux]\r\n", lum.lux()); wait(1.0); } }
Definition at line 71 of file BH1750.h.
Constructor & Destructor Documentation
BH1750 | ( | PinName | p_sda, |
PinName | p_scl | ||
) |
BH1750 | ( | I2C & | p_i2c ) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition
Definition at line 29 of file BH1750.cpp.
Member Function Documentation
void frequency | ( | int | hz ) |
float lux | ( | void | ) |
Get Illuminance, unit of Lux.
- Parameters:
-
none
- Returns:
- Lux
Definition at line 44 of file BH1750.cpp.
void power_up | ( | void | ) |
void set_sensitivity | ( | uint8_t | parameter ) |
Set sensor sensitivity adjustment.
- Parameters:
-
sensitivity parameter
- Returns:
- none
Definition at line 64 of file BH1750.cpp.
Generated on Tue Jul 12 2022 18:55:47 by
