Read more than 2 registers with i2C



  • #i2c #python #mpu6050
    Hi guys!
    i was trying to read several registers (14) in a MPU6050 device with OmegaI2C python module, but my program crashes randomly. I've seen some examples in documentation but only appears code reading 1 and 2 registers. My code run perfectly when i read a single registry but it takes a lot of time.

    # this method works but is too slow
    reg_list = [0x3B , 0x3C, 0x3D, 0x3E, 0x3F, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x46, 0x47, 0x48 ]
    while get_samples:
        for reg in reg_list:
            lista = self.i2c.readBytes(MPU_ADDR, reg, 1 ) #take a single registry
            calculate_and_send_to_socket()
    
    # this method does'nt work
    while get_samples:
        data = self.i2c.readBytes(MPU_ADDR, 0x3B, 14 ) #take 14 registry
        calculate_and_send_to_socket(data)
    

    Error
    0_1488900044384_Captura de pantalla de 2017-03-07 12-19-57.png
    Someone has an idea?


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.