- Notifications
You must be signed in to change notification settings - Fork3
This is a MicroPython library for the Raspberry Pi Pico and the BH1750 digital Ambient Light Sensor.
License
flrrth/pico-bh1750
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a MicroPython library for the Raspberry Pi Pico and theBH1750 digital Ambient Light Sensor.
frommachineimportPin,I2Cfromutimeimportsleepfrombh1750importBH1750i2c0_sda=Pin(8)i2c0_scl=Pin(9)i2c0=I2C(0,sda=i2c0_sda,scl=i2c0_scl)bh1750=BH1750(0x23,i2c0)whileTrue:print(bh1750.measurement)sleep(1)
This is the circuit for the example code above. It uses theGY-302 BH1750 breakout board.
By default, the BH1750 class uses the following settings:
- Measurement mode: 'one time' (it measures once and then shuts down, a next measurement automatically powers thedevice back on and configures it again),
- Resolution: high (1 lx)
- Measurement time: 120 ms
These values can be changed via theconfigure
method:
bh1750.configure(BH1750.MEASUREMENT_MODE_CONTINUOUSLY,BH1750.RESOLUTION_HIGH_2,BH1750.MEASUREMENT_TIME_MAX)
The example above configures the BH1750 to measure continuously, use a higher resolution (0.5 lx) and the maximummeasurement time. Configuration can greatly affect the measurement time. The BH1750 class has a generator function thatattempts to calculate the correct 'sleep time' between measurements based on the chosen configuration:
formeasurementinbh1750.measurements():print(measurement)
About
This is a MicroPython library for the Raspberry Pi Pico and the BH1750 digital Ambient Light Sensor.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.