Opt3001
Python support library for the light sensor OPT3001 from Texas Instruments
Install / Use
/learn @perryrh0dan/Opt3001README
Description
Contents
Install
- sudo apt-get install -y python-smbus
- pip install opt3001
Usage
import opt3001 from opt3001
address = 0x44
opt = opt3001.OPT3001(address)
# Configure to run in Continuous conversions mode
opt.write_config_reg(opt3001.I2C_LS_CONFIG_CONT_FULL_800MS)
while(True):
print(opt.read_lux_float())
time.sleep(1)
Raspberry pi
Add following line to /etc/modules to start i2c module on startup:
i2c_dev
Run following commands to start the i2c modules manually:
$ modprobe i2c-bcm2708
$ modprobe i2c_dev
Install i2c-tools to test with the terminal
$ sudo apt-get install i2c-tools
Run following command to get the address of the opt3001
$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Run the following command to test the opt30001
$ i2cget -y 1 0x44 0x00
0x0b
Flight Manual
Constants
| Constant | Description | Value | | --- | --- | --- | | I2C_LS_CONFIG_DEFAULT | OPT3001 default settings | 0xc810 | | I2C_LS_CONFIG_CONT_FULL_800MS | settings for continuous measurement | 0xcc10 | | I2C_LS_REG_RESULT | Result Register | 0x00 | | I2C_LS_REG_CONFIG | Configuration Register | 0x01 | | I2C_LS_REG_LOWLIMIT | Low Limit Register | 0x02 | | I2C_LS_REG_HIGHLIMIT | High Limit Register | 0x03 | | I2C_LS_REG_MANUFACTURERID | Manufacturer ID | 0x7E | | I2C_LS_REG_DEVICEID | Device ID Register | 0x7F |
OPT3001
constructor
Input:
- address - i2c address of the opt3001
- bus - default 1
read_lux_fixpoint
Read the brightness of the opt3001 with two fixed decimal places
read_lux_float
Read the brightness of the opt3001 as float
read_manufacture_id
Read manufacture id of the opt3001
read_device_id
Read device id of the opt3001
write_config_reg
Write data to config register
Input:
- data - configuration data to write to registry
read_register_16bit
reads a register of the opt3001
write_register_16bit
Write to a register of the opt3001
Input:
- adr - registeradress to write to
- data - 16bit data to write to registry
Development
Build
python setup.py sdist bdist_wheel
Upload
twine upload dist/*
Team
- Thomas Pöhlmann (@perryrh0dan)
Licence
This repository was generated by tmpo
