Qwiic Kit for Raspberry Pi Hookup Guide

Pages
Contributors: M-Short, bboyho
Favorited Favorite 1

Troubleshooting

Below are a few additional troubleshooting tips and tricks when using the Qwiic devices with a single board computer.

The Demo Code is Not Running

If you are having trouble running the demo code, there are a few reasons why the Python script may not be executing. Below are two common reasons why the demo code may not be running.

Library Not Installed

If the libraries are not installed properly, you may receive an error similar to the output below when trying to execute the Python script:

language:bash
 Traceback (most recent call last):
  File "./qwiic_kit_for_pi_demo.py", line 24, in <module>
    import qwiic 
ImportError: No module named 'qwiic'

The ImportError indicates that the module(s) was not installed properly. Make sure that the Python modules are installed on the Pi in order to run the demo.

I2C Bus Not Turned On

If you receive an error similar to the one below, there may be something with the interface settings for the I2C bus.

language:bash
Error:  Failed to connect to I2C bus 1. Error: [Errno 2] No such file or directory
Error connecting to Device: 60, 'NoneType' object has no attribute 'write_byte'
Error:  Failed to connect to I2C bus 1. Error: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/home/pi/Qwiic-Kit-for-Pi/qwiic_kit_for_pi_demo.py", line 50, in <module>
    bme.begin()
  File "/home/pi/.local/lib/python3.7/site-packages/qwiic_bme280.py", line 160, in begin
    chipID = self._i2c.readByte(self.address, self.BME280_CHIP_ID_REG)
  File "/home/pi/.local/lib/python3.7/site-packages/qwiic_i2c/linux_i2c.py", line 142, in readByte
    return self.i2cbus.read_byte_data(address, commandCode)
AttributeError: 'NoneType' object has no attribute 'read_byte_data'

The Error: Failed to connect to I2C bus 1. Error: [Errno 2] No such file or directory at the beginning of the error indicates that the I2 bus is not turned on. Make sure to use the raspi-config to ensure that I2C bus is turned on as opposed to using the graphical user interface.

I2C Device Not Connected

If you receive an error similar to the one below, it means that the bus is having issues reading a sensor.

language:bash
Traceback (most recent call last):
  File "/home/pi/qwiicpy/qwiic_kit_for_pi_demo.py",     line 117, in <module>
    ccs.readAlgorithmResults() #updates the TVOC and CO2 values
  File "/home/pi/qwiicpy/qwiic/qwiic_ccs811.py", line 159, in readAlgorithmResults
    data = self.readBlock(CSS811_ALG_RESULT_DATA, 4)
  File "/home/pi/qwiicpy/qwiic/qwiicdevice.py", line 119, in readBlock
    return self._i2cDriver.readBlock(self.address, commandCode, nBytes)
  File "/home/pi/qwiicpy/qwiic/qwiic_i2c/linux_i2c.py", line 144, in readBlock
    return self.i2cbus.read_i2c_block_data(address, commandCode, nBytes)
OSError: [Errno 121] Remote I/O error

The OSError: [Errno 121] Remote I/O error indicates that an I2C device is not connected to the bus. Make sure that the sensors and micro OLED are securely connected to the I2C bus. The demo code currently checks to see if the CCS811, BME280, VCNL4040, and micro OLED are connected to the Pi's I2C bus before executing.

Don't forget to setup the clock stretching for the Raspberry Pi, this is required for the CCS811 to work correctly on the bus. If 10000 is still too fast, try using a slower baud rate. Make sure to reboot for the changes to take effect. In some cases, adding the clock stretching and then turning on the I2C via the raspi-config will overwrite the settings for the .../boot/config.txt. If you see this configuration:

language:bash
# Enable I2C clock stretching
dtparam=i2c_arm=on

Make sure to adjust the line back to the following. Then save the changes and reboot the Pi for the changes to take effect.

language:bash
# Enable I2C clock stretching
dtparam=i2c_arm_baudrate=10000

I'm Having Problems Reading the CCS811's NTC Thermistor.

If you receive this error, this is because there is no NTC thermistor connected on the environmental combo board! You will not want to call this function if you are using the CCS811/BME280 environmental combo breakout.

language:bash
Traceback (most recent call last):
  File "/home/pi/Qwiic-Kit-for-Pi/qwiic_kit_for_pi_demo.py", line 128, in <module>
    ccs.readNTC() #updates temp value
  File "/home/pi/.local/lib/python3.7/site-packages/qwiic_ccs811.py", line 356, in readNTC
    self.resistance = self.ntcCounts * self.refResistance / float(self.vrefCounts)
ZeroDivisionError: float division by zero

I'm Having Problems Getting the Qwiic_Py Library.

If you are having trouble installing the modules, you may receive this error:

Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://www.piwheels.org/simple/sparkfun-qwiic/

Make sure that you are connected to the Internet to install the modules. Also, make sure that you are using Python3 and pip3 with the correct alias as stated earlier.

If you receive this error when trying to install the modules:

language:bash
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.7/dist-packages/sparkfun_qwiic_i2c-0.8.3.dist-info'
Consider using the `--user` option or check the permissions.

This is due to your user permissions. Make sure to use sudo with your command:

sudo pip install sparkfun_qwiic

Or --user to the command.

language:bash
pip install --user sparkfun_qwiic

I Don't Want to Use Cayenne or Another 3rd Party Service.

That's perfectly alright, you can delete or comment out all the relevant commands as that is not will not affect the rest of the code.

I Can't Connect to Cayenne.

Make sure you have copied your username, password, and clientid correctly from Cayenne into the code before executing the Python script. Also, ensure that you have a reliable connection to the Internet.

How Do I Add _____ Qwiic Sensor?

Right now we only have a few Qwiic sensors in the Qwiic Py library, but we are looking to keep adding more. Please periodically check back to see if the sensor you want is available. You can also check the Internet for existing Python code for that sensor or write your own library.