techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Adding a second but different I2C device to the BMP085

Tue Mar 05, 2013 8:49 pm

Earlier in the thread I mentioned this to another poster who had an i2c monitor. You might want to talk to them or look at different libraries that will work on Arch.

You could just try chnaging the value in your code and see what happens.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

jbuehl
Posts: 32
Joined: Fri Jun 08, 2012 2:49 pm
Location: Los Angeles

Re: Adding a second but different I2C device to the BMP085

Tue Mar 05, 2013 9:16 pm

I tried a range of different values from 0 to 31. There are always 32 bytes read, even when I initialize the data array to a length of 4. The values are almost the same, but not quite, and the results are not repeatable, i.e. if I run the program again, the results aren't identical. I'm now wondering if the extra data is really coming from the device or if it's maybe just crap that the driver is returning. I have an ancient oscilloscope, so I should at least be able to see if there really is that much activity at the hardware level.

Code: Select all

import smbus
import time
b = smbus.SMBus(1)
addr = 0x27
for c in range(32):
    b.write_quick(addr)
    time.sleep(0.050)
    d = [0,0,0,0]
    d = b.read_i2c_block_data(addr, c)
    print "%02x:"%c, "%02x "*len(d)%tuple(d)

Code: Select all

[[email protected] ~]# python humidity.py 
00: 5b 9c 58 79 6e 71 61 e5 b9 c5 87 96 e7 16 1e 5b 9c 58 79 6e 71 61 e5 b9 c5 87 96 e7 16 1e 5b 9c 
01: 5b 98 58 81 6e 61 62 05 b9 85 88 16 e6 16 20 5b 98 58 81 6e 61 62 05 b9 85 88 16 e6 16 20 5b 98 
02: 5b 9e 58 89 6e 79 62 25 b9 e5 88 96 e7 96 22 5b 9e 58 89 6e 79 62 25 b9 e5 88 96 e7 96 22 5b 9e 
03: 5b 9e 58 89 6e 79 62 25 b9 e5 88 96 e7 96 22 5b 9e 58 89 6e 79 62 25 b9 e5 88 96 e7 96 22 5b 9e 
04: 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 
05: 5b 9e 58 89 6e 79 62 25 b9 e5 88 96 e7 96 22 5b 9e 58 89 6e 79 62 25 b9 e5 88 96 e7 96 22 5b 9e 
06: 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 
07: 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 
08: 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 58 91 6e 79 62 45 b9 e5 89 16 e7 96 24 5b 9e 
09: 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 
0a: 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 
0b: 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 
0c: 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 
0d: 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 
0e: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
0f: 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 58 99 6e 79 62 65 b9 e5 89 96 e7 96 26 5b 9e 
10: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
11: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
12: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
13: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
14: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
15: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
16: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
17: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
18: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
19: 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 58 9d 6e 79 62 75 b9 e5 89 d6 e7 96 27 5b 9e 
1a: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
1b: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
1c: 5b 9e 58 a9 6e 79 62 a5 b9 e5 8a 96 e7 96 2a 5b 9e 58 a9 6e 79 62 a5 b9 e5 8a 96 e7 96 2a 5b 9e 
1d: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
1e: 5b 9e 58 a9 6e 79 62 a5 b9 e5 8a 96 e7 96 2a 5b 9e 58 a9 6e 79 62 a5 b9 e5 8a 96 e7 96 2a 5b 9e 
1f: 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 58 a5 6e 79 62 95 b9 e5 8a 56 e7 96 29 5b 9e 
[[email protected] ~]# python humidity.py 
00: 5b 69 58 ad 6d a5 62 b5 b6 95 8a d6 da 56 2b 5b 69 58 ad 6d a5 62 b5 b6 95 8a d6 da 56 2b 5b 69 
01: 5b 69 58 ad 6d a5 62 b5 b6 95 8a d6 da 56 2b 5b 69 58 ad 6d a5 62 b5 b6 95 8a d6 da 56 2b 5b 69 
02: 5b 69 58 b5 6d a5 62 d5 b6 95 8b 56 da 56 2d 5b 69 58 b5 6d a5 62 d5 b6 95 8b 56 da 56 2d 5b 69 
03: 5b 6b 58 b9 6d ad 62 e5 b6 b5 8b 96 da d6 2e 5b 6b 58 b9 6d ad 62 e5 b6 b5 8b 96 da d6 2e 5b 6b 
04: 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 
05: 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 
06: 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 
07: 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 58 b9 6d 9d 62 e5 b6 75 8b 96 d9 d6 2e 5b 67 
08: 5b 67 58 c1 6d 9d 63 05 b6 75 8c 16 d9 d6 30 5b 67 58 c1 6d 9d 63 05 b6 75 8c 16 d9 d6 30 5b 67 
09: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
0a: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
0b: 5b 6b 58 c5 6d ad 63 15 b6 b5 8c 56 da d6 31 5b 6b 58 c5 6d ad 63 15 b6 b5 8c 56 da d6 31 5b 6b 
0c: 5b 67 58 c1 6d 9d 63 05 b6 75 8c 16 d9 d6 30 5b 67 58 c1 6d 9d 63 05 b6 75 8c 16 d9 d6 30 5b 67 
0d: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
0e: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
0f: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
10: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
11: 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 
12: 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 58 c5 6d 9d 63 15 b6 75 8c 56 d9 d6 31 5b 67 
13: 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 
14: 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 
15: 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 
16: 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 
17: 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 58 cd 6d ad 63 35 b6 b5 8c d6 da d6 33 5b 6b 
18: 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 
19: 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 
1a: 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 
1b: 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 
1c: 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 58 cd 6d 9d 63 35 b6 75 8c d6 d9 d6 33 5b 67 
1d: 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 
1e: 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 58 d1 6d 9d 63 45 b6 75 8d 16 d9 d6 34 5b 67 
1f: 5b 67 58 d5 6d 9d 63 55 b6 75 8d 56 d9 d6 35 5b 67 58 d5 6d 9d 63 55 b6 75 8d 56 d9 d6 35 5b 67 

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Adding a second but different I2C device to the BMP085

Tue Mar 05, 2013 10:29 pm

That would make sense to check what is actually happening on I2C.

Also try changing the value so it goes fro 1 to 128 by multipling by 2 as well, only 8 steps.

If I had one here and the time I would monitor it myself as I have a digital scope with I2C capture modes
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

jbuehl
Posts: 32
Joined: Fri Jun 08, 2012 2:49 pm
Location: Los Angeles

Re: Adding a second but different I2C device to the BMP085

Wed Mar 06, 2013 12:07 am

I can see a burst of data on the SDA line that lasts about 34 milliseconds. It looks like the clock period is 10 microseconds, so that would indicate that there are approximately 34 bytes being transferred (340 clock cycles) and that's consistent with 2 bytes being sent from the master and the slave sending 32 bytes. What I think might be happening is that my driver may not be sending the NAK bit after it receives the 4th byte so the device must keep sending data as long as the master keeps replying with ACKs. The data seems to repeat after the 15th byte and maybe the device is sending additional data after the humidity and temperature bytes that isn't documented. I can't see any of the bits with my scope so this is just a theory.

I'm going to start digging into the driver to see what it is really doing. Maybe I'll wind up modifying it to handle this case, although it would be an extension to the SMBus spec. I don't see anywhere that this device claims to conform to the SMBus spec, just I2C, so really this isn't technically a bug in the driver.

jbuehl
Posts: 32
Joined: Fri Jun 08, 2012 2:49 pm
Location: Los Angeles

Re: Adding a second but different I2C device to the BMP085

Wed Mar 06, 2013 3:56 pm

Looking at the code for read_i2c_block_data() it turns out there is a 3rd argument for specifying the length of data to read. If it is not specified, the default is 32. Setting it to 4 causes only 4 bytes to be returned.

This still doesn't fix the problem of the status being set to 1. I would be interested to know if someone else has been able to get 4 bytes of data and a zero status. sd_read reported that it was working, but didn't mention this detail.

jbach
Posts: 15
Joined: Tue Oct 29, 2013 3:41 pm

Re: Adding a second but different I2C device to the BMP085

Mon Jul 21, 2014 4:01 pm

ditto, What is the I2C monitor?

Return to “Python”