Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

SI7021 Help
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SI7021 Help

by rwhayes on Thu Apr 29, 2021 7:13 pm

Hi, I'm relatively new to programming in python.

I purchased an SI7021 temperature and humidity stemma breakout for my Raspberry Pi 3 A+.

I also purchased an SGP30 mox gas sensor stemma breakout.

I'm not using the stemma connectors, though, because I don't have the stemma cables. I am using terminal connectors and a pi ez connect.

Anyway, the SI7021 sometimes works and sometimes returns a "Traceback (most recent call last)" error when I declare the sensor in Python 3. Rarely, it works for a while and then gives the same error when I take a reading from the sensor, but usually, it either crashes right away or will run for several minutes until the Python script is complete. None of my other sensors seem to be giving me any such trouble connected the same way.

I originally wanted to run a Python Script to access both the SI7021 and SGP30 at the same time, but, when I try to declare the sensor for the SI7021 after importing the SGP30 library, it always crashes from withon the adafruit_si7021.py unit.

Any ideas how I could troubleshoot?

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by rwhayes on Fri Apr 30, 2021 12:34 pm

The code that crashes is the example code:

Code: Select all | TOGGLE FULL SIZE
import time
import board
import adafruit_si7021
 
sensor = adafruit_si7021.SI7021(board.I2C())
 
while True:
    print("\nTemperature: %0.1f C" % sensor.temperature)
    print("Humidity: %0.1f %%" % sensor.relative_humidity)
    time.sleep(2)


The error I get most often (about 40% of the time I run the code) occurs in line 5:

Code: Select all | TOGGLE FULL SIZE
sensor = adafruit_si7021.SI7021(board.I2C())


As I mentioned, the other 60% of the time, it makes it through that line of code okay, though. Maybe about 50% of the time, the code runs fine and everything with the sensor seems to interface correctly, because I get the correct temperature and a realistic humidity reading. The remaining 10% of the time, the code crashes in the loop, usually when calling the humidity.

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by rwhayes on Fri Apr 30, 2021 12:42 pm

The other issue, probably related, is when I try to run the code:

Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
import adafruit_si7021
import adafruit_sgp30

i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
sensor = adafruit_si7021.SI7021(board.I2C())
sgp30 = adafruit_sgp30.AdafruitSGP30(i2c)

print("SGP30 serial #", [hex(i) for i in sgp30.serial])

sgp30.iaq_init()
sgp30.set_iaq_baseline(0x8973, 0x8AAE)

elapsed_sec = 0

while True:
 print("eCO2 = %d ppm \t TVOC = %d ppb" % (sgp30.eCO2, sgp30.TVOC))
 time.sleep(2)
 slapsed_sec +=1
 if elapsed_sec > 10:
  slapsed_sec = 0
  print(
   "**** Baseline values: eCO2 = 0x%x, TVOC = 0x%x"
   % (sgp30.baselin_eCO2, sgp30.baseline_TVOC)
   )


- it always crashes at line 8 with a traceback error. I though maybe the i2c and I2C variables might be causing problems, but that's not the error I'm seeing.

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by rwhayes on Tue May 04, 2021 11:02 am

Still having trouble. Is this a simple enough problem that I'm just not understanding what I'm doing or is there something wrong with the sensor?

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by adafruit_support_carter on Thu May 06, 2021 7:31 pm

Please post a photo showing how you have the SI7021 connected to the EzConnect and Pi.

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: SI7021 Help

by rwhayes on Thu May 06, 2021 8:44 pm

How do I post a pic? I had tried with the original post, but the upload size was way too small to use a helpful photo.

I'm using a screw terminal block. VIN to 3.3V on the EZ connect, GND to GND on the EZ connect. SCL to a wirenut connecting the sensors to SCL on the EZ connect (P3), and SDA to a wirenut wiring all the sensors to SDA (P5) on the EZ connect.

All of my other sensors are working consistently.

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by franklin97355 on Thu May 06, 2021 9:15 pm

If you're having trouble you could upload the picture to a file-sharing site and then post the link to the site.

franklin97355
 
Posts: 21882
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: SI7021 Help

by rwhayes on Thu May 06, 2021 9:59 pm


rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by adafruit_support_carter on Thu May 06, 2021 10:26 pm

Sort of. It's requiring logging in to view for some reason?

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: SI7021 Help

by rwhayes on Fri May 07, 2021 6:15 am

Image

https://drive.google.com/file/d/1a5q2rR ... p=drivesdk

Are there any free image hosting sites anymore?

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by adafruit_support_carter on Fri May 07, 2021 1:32 pm

Inlining for reference:
wiring.jpg
wiring.jpg (568.46 KiB) Viewed 56 times

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: SI7021 Help

by adafruit_support_carter on Fri May 07, 2021 1:41 pm

Try backing up a bit and testing each breakout individually. Remove the wire junctions and have just each breakout with its associated wires. Then, one at a time, wire each one directly to the I2C and powers pins.

You can do a simple "is it there" test with:
Code: Select all | TOGGLE FULL SIZE
i2cdetect -y 1

and verify the address shows up. Then try the simple example program from each sensors library.
https://github.com/adafruit/Adafruit_Ci ... pletest.py
https://github.com/adafruit/Adafruit_Ci ... pletest.py
https://github.com/adafruit/Adafruit_Ci ... pletest.py

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: SI7021 Help

by rwhayes on Fri May 07, 2021 2:01 pm

Thanks!

That's exactly what I tried before I moved on to the wiring shown in the photo, but I'll take a step back and try it again. I can report back in a few minutes.

Is there any widely-known, specific reason why I necessarily would not be able to communicate to both the Si7021 and SGP30 at the same time? I know they are different I2C addresses, but I suspect there's some newbie-level thing I'm probably missing.

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Re: SI7021 Help

by adafruit_support_carter on Fri May 07, 2021 2:50 pm

Should be OK. There doesn't appear to be an I2C address conflict:
https://learn.adafruit.com/i2c-addresses/the-list
0x39 = AS7341
0x40 = Si7021
0x58 = SGP30

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: SI7021 Help

by rwhayes on Fri May 07, 2021 3:57 pm

Addresses all checked out okay. I thought maybe, since it's intermittently working with the code I'm using, that, if I tried to ping the I2C address a few times over the course of an hour or so, it would give me a bad result maybe some of the time, but I was unable to observe any errors. I wired it back up and it worked fine for about 10 minutes, then gave the same error again, when only initializing the Si7021. When I tried again with the SGP30 and the Si7021, the program wouldn't even initialize the Si7021, just as before.

rwhayes
 
Posts: 10
Joined: Thu Mar 01, 2018 2:57 pm

Please be positive and constructive with your questions and comments.