Medicus3453
Posts: 1
Joined: Wed May 22, 2019 8:06 pm

I2C Read Error- SparkFun Sensor-

Wed May 22, 2019 8:19 pm

Hey you all,

I got some troubles with my Pi Zero W (Stretch) and my SparkFun AS7265x Sensor(https://cdn.sparkfun.com/assets/c/2/9/0 ... asheet.pdf):
I connected them over my GPIOs to create a I2C Bus;
- I detected my sensor at 0x49 via i2cdetect -y 1;
- I configured my rapsi-config (enable i2c)
- I install the drivers i2c-tools, use the mods i2c-dev and i2c-bcm2708 and edited to my boot/config.txt additionally dtoverlay=i2c1-bcm2708

--> Now I want to read out some registers e.g. the temperature (0x06) but everything I get is a 0x00 (i2cget -y 1 0x49 0x06 b)
--> The only register I can read is 0x00 and their I get 0x80 (but default should be 0x40)

so I tried pyserial, but when I want to use: serial.Serial("/dev/i2c-1", 115200) --> I get a cannot configure port error 25
if I write cat /dev/i2c-1 (as explained in some stack overflow topics) I get an I/O-Error.....

I am pretty keyless now.... Maybe there is a clock stretching??



Would be likely if anybody could help me :)

Cheers!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6640
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C Read Error- SparkFun Sensor-

Thu May 23, 2019 10:01 am

Medicus3453 wrote:
Wed May 22, 2019 8:19 pm
Hey you all,

I got some troubles with my Pi Zero W (Stretch) and my SparkFun AS7265x Sensor(https://cdn.sparkfun.com/assets/c/2/9/0 ... asheet.pdf):
I connected them over my GPIOs to create a I2C Bus;
- I detected my sensor at 0x49 via i2cdetect -y 1;
- I configured my rapsi-config (enable i2c)
- I install the drivers i2c-tools, use the mods i2c-dev and i2c-bcm2708 and edited to my boot/config.txt additionally dtoverlay=i2c1-bcm2708
Why are you manually modifying config.txt if you have already detected the sensor at 0x49?
raspi-config will have already added i2c-dev. i2c-bcm2708 should never be manually loaded as it is configured via device-tree.
Medicus3453 wrote:--> Now I want to read out some registers e.g. the temperature (0x06) but everything I get is a 0x00 (i2cget -y 1 0x49 0x06 b)
--> The only register I can read is 0x00 and their I get 0x80 (but default should be 0x40)

so I tried pyserial, but when I want to use: serial.Serial("/dev/i2c-1", 115200) --> I get a cannot configure port error 25
if I write cat /dev/i2c-1 (as explained in some stack overflow topics) I get an I/O-Error.....
The device supports I2C or UART, but needs hardware mods to switch from the default of I2C. See the "Serial UART Interface" section of https://learn.sparkfun.com/tutorials/sp ... okup-guide for instructions on how to do this. You can't simply open a different device under Linux.

It's a shame that Sparkfun's reference example code will only talk via the UART. It won't work in the default configuration.

A quick Google has picked up C code for talking to the sensor - https://github.com/jdesbonnet/as7265x I'd suggest you try using code actually designed for talking to these devices instead of i2cget which is for talking to SMBus sensors (this device does not appear to be SMBus, although it is vaguely similar)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Interfacing (DSI, CSI, I2C, etc.)”