So.. I'm trying to do multiple writes to the module with the I2C
1 # sensor starts
2 def begin(self):
3 data = [0x11, 0xE5, 0x72, 0x8A] # for multiple writes
4 self._write(data, self.ccs811_addr, CSS811_SW_RESET, timeout=self.timeout)
5 pyb.millis(500)
THIS IS THE METHOD/OPERATION BELOW
def _write(self, data, memaddr, addr):
self._ccs811_i2c.mem_write(data, addr, memaddr, timeout=self.timeout)
is line 3 the right way to prepare the data to be safely written ??
should i pack the data into bytearray ??
because i would prefer a more concise way to doing it instead
of doing individual writes for each data.
Thanks
I2C multiple writes instead of individual writes
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: I2C multiple writes instead of individual writes
For reading data you need a bytearray. For data which is only for writing you can use an (immutable) bytes object:
Code: Select all
data = b'\x11\xE5\x72\x8A'
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.