Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Adafruit CircuitPython with MS8607 Sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit CircuitPython with MS8607 Sensor

by Tom_Henry on Mon Aug 31, 2020 8:13 pm

Today I received your MS8607 from
Order Confirmation No: 2350533-4294160462

I set up my Raspberry Pi and connected your MS8607 sensor to the pi.

I went to this website:

https://learn.adafruit.com/circuitpytho ... spberry-pi

I ran this Python Program:

import board
import digitalio
import busio

print("Hello blinka!")

# Try to great a Digital input
pin = digitalio.DigitalInOut(board.D4)
print("Digital IO ok!")

# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")

# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")

print("done!)

I ran the program and here are the results:

Python 3.7.3 (/usr/bin/python3)
>>> %Run blinkatest.py

Hello blinka!
Digital IO ok!
I2C ok!
SPI ok!
done!
>>>


Then I went to this page:
CircuitPython & Python Usage

To demonstrate the usage of the sensor we'll initialize it and read the pressure, temperature, and humidity measurements from the board's Python REPL. Run the following code to import the necessary modules and initialize the I2C connection with the sensor:

Then I ran this command from terminal:

sudo pip3 install adafruit-circuitpython-ms8607


Then I tried running this python3 program. I saved it as stuck.py.

import board
import busio
from adafruit_ms8607 import MS8607

i2c = busio.I2C(board.SCL, board.SDA)
sensor = MS8607(i2c)


Here’s is where I got stuck:

Python 3.7.3 (/usr/bin/python3)

>>> %Run stuck.py

Traceback (most recent call last):

File "/home/pi/stuck.py", line 3, in <module>
from adafruit_ms8607 import MS8607

File "/home/pi/adafruit_ms8607.py", line 4, in <module>
from adafruit_ms8607 import MS8607

ImportError: cannot import name 'MS8607' from 'adafruit_ms8607' (/home/pi/adafruit_ms8607.py)
>>>


So what am I doing wrong?

Tom_Henry
 
Posts: 15
Joined: Wed Aug 26, 2020 8:19 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by mikeysklar on Mon Aug 31, 2020 8:23 pm

Hi Tom_Henry,

It looks like you are mostly there. The version of python you are invoking is not finding your library as it looking in the ~pi home directory which is not the right location.

since you used sudo pip3 to install the adafruit-circuitpython-ms8607 you might need to run something like:

Code: Select all | TOGGLE FULL SIZE
sudo python3 stuck.py


If that does not work you can try other variations like:

Code: Select all | TOGGLE FULL SIZE
python stuck.py


Code: Select all | TOGGLE FULL SIZE
python3 stuck.py


Some combination of sudo, python or python3 should pickup the library correctly.

Let me know if this resolves it.

mikeysklar
 
Posts: 1695
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by Tom_Henry on Mon Aug 31, 2020 10:48 pm

pi@raspberrypi:~ $ sudo python3 stuck.py
Traceback (most recent call last):
File "stuck.py", line 3, in <module>
from adafruit_ms8607 import MS8607
File "/home/pi/adafruit_ms8607.py", line 4, in <module>
from adafruit_ms8607 import MS8607
ImportError: cannot import name 'MS8607' from 'adafruit_ms8607' (/home/pi/adafruit_ms8607.py)

pi@raspberrypi:~ $ python stuck.py
Traceback (most recent call last):
File "stuck.py", line 1, in <module>
import board
ImportError: No module named board

pi@raspberrypi:~ $ python3 stuck.py
Traceback (most recent call last):
File "stuck.py", line 3, in <module>
from adafruit_ms8607 import MS8607
File "/home/pi/adafruit_ms8607.py", line 4, in <module>
from adafruit_ms8607 import MS8607
ImportError: cannot import name 'MS8607' from 'adafruit_ms8607' (/home/pi/adafruit_ms8607.py)

Mike,

I gave those a try. This is my first time trying to use CircuitPython so I am still a little unsure how it works. You mentioned "pick up the library". Where is the library located?

Any other ideas?

Tom Henry

Tom_Henry
 
Posts: 15
Joined: Wed Aug 26, 2020 8:19 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by Tom_Henry on Mon Aug 31, 2020 11:28 pm

Mike,

Ok, I found the Adafruit library. Here is where I found it: /home/pi/Python/adafruit-circuitpython-bundle-6.x-mpy-20200829/lib

Does that help you?

Tom Henry

Tom_Henry
 
Posts: 15
Joined: Wed Aug 26, 2020 8:19 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by mikeysklar on Tue Sep 01, 2020 10:45 am

Hi Tom,

I believe the problem you are seeing is that your python3 installation does not know where to look for the necessary MS8607 python library. Normally there are environment variables that are set automatically when you install a library through pip3.

https://circuitpython.readthedocs.io/pr ... en/latest/

In your first message you had installed the library (MS8607) using sudo pip3 install. Could you try again using just pip3 install and see if that makes a difference.

Code: Select all | TOGGLE FULL SIZE
pip3 install adafruit-circuitpython-ms8607


then try to execute your script with:

Code: Select all | TOGGLE FULL SIZE
python3 stuck.py


of course everything will just work if you drop the adafruit_ms8607.py library right into the same directory as the stuck.py script, but that is sort of cheating and I want to make sure this is just a subtle installation environmental issue.

https://github.com/adafruit/Adafruit_Ci ... _ms8607.py

mikeysklar
 
Posts: 1695
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by Tom_Henry on Tue Sep 01, 2020 3:31 pm

Mike,

Still not working, here are the results:

pi@raspberrypi:~ $ pip3 install adafruit-circuitpython-ms8607
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: adafruit-circuitpython-ms8607 in ./.local/lib/python3.7/site-packages (1.0.1)
Requirement already satisfied: Adafruit-Blinka in ./.local/lib/python3.7/site-packages (from adafruit-circuitpython-ms8607) (5.3.0)
Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-ms8607) (0.7.0)
Requirement already satisfied: Adafruit-PlatformDetect>=2.11.1 in ./.local/lib/python3.7/site-packages (from Adafruit-Blinka->adafruit-circuitpython-ms8607) (2.15.0)
Requirement already satisfied: pyftdi>=0.40.0 in ./.local/lib/python3.7/site-packages (from Adafruit-Blinka->adafruit-circuitpython-ms8607) (0.51.2)
Requirement already satisfied: sysv-ipc; platform_system != "Windows" and platform_machine != "mips" in ./.local/lib/python3.7/site-packages (from Adafruit-Blinka->adafruit-circuitpython-ms8607) (1.0.1)
Requirement already satisfied: rpi-ws281x>=4.0.0 in ./.local/lib/python3.7/site-packages (from Adafruit-Blinka->adafruit-circuitpython-ms8607) (4.2.4)
Requirement already satisfied: Adafruit-PureIO>=1.1.5 in ./.local/lib/python3.7/site-packages (from Adafruit-Blinka->adafruit-circuitpython-ms8607) (1.1.5)
Requirement already satisfied: pyusb>=1.0.0 in ./.local/lib/python3.7/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-ms8607) (1.0.2)
Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-ms8607) (3.4)


pi@raspberrypi:~ $ python3 stuck.py
Traceback (most recent call last):
File "stuck.py", line 3, in <module>
from adafruit_ms8607 import MS8607
File "/home/pi/adafruit_ms8607.py", line 4, in <module>
from adafruit_ms8607 import MS8607
ImportError: cannot import name 'MS8607' from 'adafruit_ms8607' (/home/pi/adafruit_ms8607.py)

Tom_Henry
 
Posts: 15
Joined: Wed Aug 26, 2020 8:19 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by Tom_Henry on Tue Sep 01, 2020 3:51 pm

Ok Mike,

I am going to do a clean install with a MicroSD card.

What do you recommend as the best set of directions to follow from the Adafruit CircuitPython website?

Thanks,

Tom Henry

Tom_Henry
 
Posts: 15
Joined: Wed Aug 26, 2020 8:19 pm

Re: Adafruit CircuitPython with MS8607 Sensor

by adafruit2 on Wed Sep 02, 2020 11:12 am

you named your script
/home/pi/adafruit_ms8607.py

the same as the library
change the name of that script!

adafruit2
Site Admin
 
Posts: 19357
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.