peter-l5 / MicroPython_SCD4X

MicroPython driver for Sensirion SCD40 and SCD41. Derived from the Adafruit CircuitPython version
MIT License
6 stars 1 forks source link

error in _set_command_value method #4

Closed peter-l5 closed 1 year ago

peter-l5 commented 1 year ago

I am having a problem with this section of code:

def _set_command_value(self, cmd, value, cmd_delay=0):
    self._buffer[0] = (cmd >> 8) & 0xFF
    self._buffer[1] = cmd & 0xFF
    self._crc_buffer[0] = self._buffer[2] = (value >> 8) & 0xFF
    self._crc_buffer[1] = self._buffer[3] = value & 0xFF
    self._buffer[4] = self._crc8(self._crc_buffer)
    self.i2c_device.i2c.write(self.address, self._buffer) # error in this line 'AttributeError: 'I2C' object has no attribute 'i2c'

when I remove the second i2c tag in this line I get - "TypeError: function takes 2 positional arguments but 3 were given" - When commenting out this line, rest of code runs fine. time.sleep(cmd_delay) Any Ideas of what has gone wrong?

_Originally posted by @bocephasj in https://github.com/peter-l5/MicroPython_SCD4X/issues/3#issuecomment-1646874714_

peter-l5 commented 1 year ago

fixed with pull request #5