import smbus
import time
import datetime
#SMBus(0) - Raspberry Pi Model A
#SMBus(1) - Raspberry Pi Model B
bus = smbus.SMBus(1)
#I2C address of sensor
address = 0x27
def temp():
#rvalue0 = bus.read_word_data(address,0)
rvalue0= bus.read_i2c_block_data(address,1,32)
print rvalue0
print ('\n')
rvalue1 = (rvalue0 & 0x0000ff00) >> 8
print rvalue1
print ('\n')
rvalue2 = rvalue0 & 0x0000ff00
print rvalue2
rvalue = (((rvalue2 *256) + rvalue1) >> 2 ) *.007631
print rvalue
Output:
[79, 202, 104, 29, 63, 41, 160, 116, 252, 166, 129, 211, 242, 154, 7, 79, 202, 104, 29, 63, 41, 160, 116, 252, 166, 129, 211, 242, 154, 7, 79, 202]
Error Message:
Traceback (most recent call last):
File "/home/pi/temp1.py", line 41, in <module>
temp()
File "/home/pi/temp1.py", line 18, in temp
rvalue1 = (rvalue0 & 0x0000ff00) >> 8
TypeError: unsupported operand type(s) for &: 'list' and 'int'
smbus
. Your parameters look wrong.