4 Replies Latest reply on May 6, 2015 5:37 PM by CMata_Intel

    How to read a 16 bit integer from i2c using mraa read function?

    sallott831

      I am unable to identify the method to read integers from the I2C interface using python and the mraa library. Any help would be appreciated. I'm pretty new to this so I've included my code below as I'm sure it is something I'm doing wrong...

       

      i2c = mraa.I2c(1)

      i2c.address(0x15)

      counter=0

      while True:

          try:

              data=bytearray(i2c.read(2))

       

              for value in data:

                  print (value)

       

              time.sleep(1)

       

              counter +=1

              if counter >10:

              break

          except (KeyboardInterrupt,SystemExit):

              raise

       

      print "done"