tsaG
Posts: 80
Joined: Thu Jun 26, 2014 1:30 pm

Interfacing ISL29023 Brightness sensor

Fri Jul 24, 2015 10:12 pm

Hi,

I'd like to write a class for my ISL29023 brightness sensor. I already got it working using C and the Arduino framework but I struggle to get it running under python

I wrote a class to test this, but somehow it won't work

Here is the C code I'd like to use: https://github.com/perelloc/isl29023/bl ... l29023.cpp

Here is my code. I stopped with the read function since I can't get even a single byte from the Sensor.

Code: Select all

import smbus, array
ISL29023_ADDR = 0x44

CMD1 = 0
CMD2 = 1
DATALSB = 2
DATAMSB = 3
dev_address = ISL29023_ADDR
i2cbus = smbus.SMBus(1)
i2cdata = array.array('H',[0,0,0])

# define a class
class isl:
    def __init__(self):
        #dev_address = 0x44
        i2cdata[0] = CMD1
        i2cdata[1] = 0b10100000
        i2cbus.write_byte_data(dev_address, i2cdata[0], i2cdata[1])
        
        i2cdata[0] = CMD2;
        i2cdata[1] = 0b00000011;
        i2cbus.write_byte_data(dev_address, i2cdata[0], i2cdata[1])

    def read(self):
    
        i2cdata[0] = DATAMSB
        i2cbus.write_byte(dev_address, i2cdata[0])
        i2cbus.write_quick(dev_address)
        print i2cbus.read_byte(dev_address)
Im calling it with

Code: Select all

brightness = isl9023.isl()
brightness.read()
All I get is:
0

Here is the data sheet for the sensor:
http://www.intersil.com/content/dam/Int ... l29023.pdf

Thank you!

User avatar
joan
Posts: 14763
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Interfacing ISL29023 Brightness sensor

Fri Jul 24, 2015 10:50 pm

Why isn't

Code: Select all

def read(self):
   
        i2cdata[0] = DATAMSB
        i2cbus.write_byte(dev_address, i2cdata[0])
        i2cbus.write_quick(dev_address)
        print i2cbus.read_byte(dev_address)
just

Code: Select all

def read(self):
           print i2cbus.read_byte_data(dev_address, DATAMSB)

ksr
Posts: 3
Joined: Sat Aug 06, 2016 6:50 am

Re: Interfacing ISL29023 Brightness sensor

Sat Apr 22, 2017 9:59 am

joan wrote:Why isn't

Code: Select all

def read(self):
   
        i2cdata[0] = DATAMSB
        i2cbus.write_byte(dev_address, i2cdata[0])
        i2cbus.write_quick(dev_address)
        print i2cbus.read_byte(dev_address)
just

Code: Select all

def read(self):
           print i2cbus.read_byte_data(dev_address, DATAMSB)
is it working solution?

Return to “Python”