Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

This is a MicroPython library for the Raspberry Pi Pico and the BH1750 digital Ambient Light Sensor.

License

NotificationsYou must be signed in to change notification settings

flrrth/pico-bh1750

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a MicroPython library for the Raspberry Pi Pico and theBH1750 digital Ambient Light Sensor.

Example

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.

Fritzing wiring for the example code.

Customizing configuration

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp