byte i2c_device_address=0x65;byte starting_register=0x00byte device_type;byte version_number;Wire.beginTransmission(i2c_device_address);Wire.write(staring_register);Wire.endTransmission();Wire.requestFrom(i2c_device_address,(byte)2);device_type = Wire.read();version_number = Wire.read();Wire.endTransmission();
import smbus
# General i2c device class so that other devices can be added easily
class i2c_device:
def __init__(self, addr, port):
self.addr = addr
self.bus = smbus.SMBus(port)
def write(self, byte):
self.bus.write_byte(self.addr, byte)
def read(self):
return self.bus.read_byte(self.addr)
def read_nbytes_data(self, data, n): # For sequential reads > 1 byte
return self.bus.read_i2c_block_data(self.addr, data, n)
ph = i2c_device(0x65, 2)
ph.write(0x00)
device_type = ph.read()version_number = ph.read()print(device_type)
print(version_number)
HW: Beaglebone seeedstudio green wireless
OS: Debian GNU/Linux 8.8 (jessie)
Kernel: Linux beaglebone 4.4.30-ti-r64
Python: Python 2.7.9
The HW it's OK, I check with an arduino and example code and I can write registers with my python script on the beaglebone.
debian@beaglebone:~$ i2cdetect -y -r 2 0 1 2 3 4 5 6 7 8 9 a b c d e f00: -- -- -- -- -- -- -- -- -- -- -- -- --10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --60: -- -- -- -- 64 65 -- -- -- -- -- -- -- -- -- --70: -- -- -- -- -- -- -- --
1, 1, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
import smbusimport time
class i2c_device: def __init__(self, addr, port): self.addr = addr self.bus = smbus.SMBus(port)
def write(self, byte): self.bus.write_byte(self.addr, byte)
def write_i2c_block_data(self, byte, array): self.bus.write_i2c_block_data(self.addr, byte, array)
def read(self): return self.bus.read_byte(self.addr)
def read_nbytes_data(self, data, n): # For sequential reads > 1 byte return self.bus.read_i2c_block_data(self.addr, data, n)
ph = i2c_device(0x65, 2)ph.write(0x00)
i=0while (i <= 25): print(ph.read()) time.sleep(0.5) i+=1
1,4,1,65,0,1,0,1,0,0,0,0,0,0,0,0,9,C4,0,0,9,C4,0,0,16
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/589b19eb-9c6a-4ed9-aca3-3f3f1241ed4b%40googlegroups.com.--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Lyxv7E3yIvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
import smbusimport time
# General i2c device class so that other devices can be added easilyclass i2c_device: def __init__(self, addr, port): self.addr = addr self.bus = smbus.SMBus(port)
def write_i2c_block_data(self, byte, array): self.bus.write_i2c_block_data(self.addr, byte, array)
def read_nbytes_data(self, data, n): # For sequential reads > 1 byte return self.bus.read_i2c_block_data(self.addr, data, n)
ph = i2c_device(0x65, 2)
print(ph.read_nbytes_data(0x00, 25)) //read all registers
ph.write_i2c_block_data(0x05,[0x00]) // off LED
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
import smbus# General i2c device class so that other devices can be added easilyclass i2c_device:def __init__(self, addr, port):self.addr = addrself.bus = smbus.SMBus(port)
def write_i2c_block_data(self, byte, array):self.bus.write_i2c_block_data(self.addr, byte, array)
def read_nbytes_data(self, data, n): # For sequential reads > 1 bytereturn self.bus.read_i2c_block_data(self.addr, data, n)ph = i2c_device(0x65, 2)
ph.write_i2c_block_data(0x05,[0x00]) // off LED
print(ph.read_nbytes_data(0x00, 25)) // read all registers
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Lyxv7E3yIvs/unsubscribe.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/8d476212-153b-4816-aae1-7216e00e8994%40googlegroups.com.To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.