Skip to content

TypeError: memoryview: a bytes-like object is required, not 'list'  #5

Closed
@LittleMatchaGirl

Description

@LittleMatchaGirl

I am using a SGP40 MOX air quality sensor from Adafruit ( link provided: https://learn.adafruit.com/adafruit-sgp40/overview). I have checked my wiring and it is exactly like the one provided, using i2c wiring for the SCL and SDA. I have run into the following error that is listed in the title. Any help is greatly appreciated, and I can try my best to answer any further questions. I am fairly new to coding so I have done my best to research but to no avail. Please and thank you! I have also copied the trace back at the bottom. also provided the version.

TypeError                                 Traceback (most recent call last)
<ipython-input-13-d6b4af4d3b4a> in <module>
----> 1 help(sgp.raw)

/usr/local/lib/python3.7/dist-packages/adafruit_sgp40.py in raw(self)
    206         # recycle a single buffer
    207         self._command_buffer = self._measure_command
--> 208         read_value = self._read_word_from_command(delay_ms=250)
    209         self._command_buffer = bytearray(2)
    210         return read_value[0]

/usr/local/lib/python3.7/dist-packages/adafruit_sgp40.py in _read_word_from_command(self, delay_ms, readlen)
    248 
    249         with self.i2c_device as i2c:
--> 250             i2c.write(self._command_buffer)
    251 
    252         sleep(round(delay_ms * 0.001, 3))

/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py in write(self, buf, start, end)
     82         if end is None:
     83             end = len(buf)
---> 84         self.i2c.writeto(self.device_address, buf, start=start, end=end)
     85 
     86     # pylint: disable-msg=too-many-arguments

/usr/local/lib/python3.7/dist-packages/busio.py in writeto(self, address, buffer, start, end, stop)
    156             if end is None:
    157                 return self._i2c.writeto(address, memoryview(buffer)[start:], stop=stop)
--> 158             return self._i2c.writeto(address, memoryview(buffer)[start:end], stop=stop)
    159         return self._i2c.writeto(address, buffer, stop=stop)
    160 

TypeError: memoryview: a bytes-like object is required, not 'list'
pip3 show adafruit-circuitpython-sgp40
Name: adafruit-circuitpython-sgp40
Version: 1.1.0
Summary: CircuitPython library for the Adafruit SGP40 Air Quality Sensor / VOC Index Sensor Breakouts
Home-page: https://github.com/adafruit/Adafruit_CircuitPython_SGP40
Author: Adafruit Industries
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.7/dist-packages
Requires: Adafruit-Blinka, adafruit-circuitpython-busdevice
Required-by: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions