Is this problem already solved? It seems to be a mistake in the sample program. Although, the variable 'count' in the function i2c_transmit() should be global, it is interpreted as local. I modified the function i2c_on_transmit() as follows: def i2c_on_transmit (): global count count = count + 1 print ("on_transmit, send:", count) return count Then, it worked well.