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

Need some help to setup CircuitPython on Pi4
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Need some help to setup CircuitPython on Pi4

by adafruit_user2015 on Sat Oct 17, 2020 9:05 pm

Hi, I have a Raspberry Pi 4. I want to install CircuitPython so that I can use some sensors on the Pi4.

From a product page, I got linked to:
https://learn.adafruit.com/adafruit-ina ... cuitpython

I clicked on "latest version of Adafruit CircuitPython" but it does not list the Pi4. Then, I googled and went to:

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

I followed all the steps and at the end, after executing "python3 blinkatest.py", I got the results shown in the screenshot.

So, what is the next step?

I went back to:

https://learn.adafruit.com/adafruit-ina ... cuitpython

Since I am using Pi4, do I need to go through the steps in the following 4 links?
- Make sure running the latest version of Adafruit CircuitPython for your board.
- Install the necessary libraries to use the hardware --carefully follow the steps to find and install these libraries from Adafruit's CircuitPython library bundle
- a great page on how to install the library bundle
- connect to the board's serial REPL

I just executed: sudo pip install adafruit-circuitpython-ina260 (note that I used pip rather than pip3 as Python3 is my default version)

Is that all I need to do? I cannot find adafruit_ina260.mpy, adafruit_bus_device and adafruit_register. I suppose the sudo pip command installed these three files but I cannot find them. Where are they stored?

adafruit_user2015
 
Posts: 40
Joined: Wed Mar 18, 2015 9:19 pm

Re: Need some help to setup CircuitPython on Pi4

by dastels on Sun Oct 18, 2020 12:21 pm

The Pi doesn't run CircuitPython. Instead you use Blinka that lets you use CircuitPython modules/libraries from Python3. So the first link is the relevant one. Your screenshot wasn't attached to the post. Could you try posting it again?

Dave

dastels
 
Posts: 3864
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need some help to setup CircuitPython on Pi4

by adafruit_user2015 on Sun Oct 18, 2020 1:09 pm

dastels wrote:The Pi doesn't run CircuitPython. Instead you use Blinka that lets you use CircuitPython modules/libraries from Python3. So the first link is the relevant one. Your screenshot wasn't attached to the post. Could you try posting it again?

Dave



Thank you Dave. Do you mean the second link? https://learn.adafruit.com/circuitpytho ... spberry-pi is all I need to follow?
I got the same output as the screenshot shown at the bottom of the link.

So from now on, whenever I add a new sensor breakout board, I just do the corresponding: sudo pip install filename and that is it?

I still cannot find adafruit_ina260.mpy, adafruit_bus_device and adafruit_register. Where are they stored in the Raspberry Pi?

adafruit_user2015
 
Posts: 40
Joined: Wed Mar 18, 2015 9:19 pm

Re: Need some help to setup CircuitPython on Pi4

by dastels on Sun Oct 18, 2020 3:27 pm

You mean the screenshot I attached?

If so, then it worked.

Yes, install sensor (and such) modules as described on https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/i2c-sensors-and-devices.

Personally, I don't know where they end up on the Pi.

Dave
Attachments
sensors_test.png
sensors_test.png (4.4 KiB) Viewed 86 times

dastels
 
Posts: 3864
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need some help to setup CircuitPython on Pi4

by adafruit_user2015 on Sun Oct 18, 2020 3:52 pm

Yes, this screenshot. Thank you.

If I want to use multiple I2C buses on the Pi4, what do I need to do to enable them so that I can use the additional I2C buses under CircuitPython?

adafruit_user2015
 
Posts: 40
Joined: Wed Mar 18, 2015 9:19 pm

Re: Need some help to setup CircuitPython on Pi4

by dastels on Sun Oct 18, 2020 4:56 pm

Why would you need I2C busses? That's generally not required.

But have a llok at https://www.instructables.com/Raspberry-PI-Multiple-I2c-Devices/

dastels
 
Posts: 3864
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need some help to setup CircuitPython on Pi4

by adafruit_user2015 on Sun Oct 18, 2020 9:40 pm

dastels wrote:Why would you need I2C busses? That's generally not required.

But have a llok at https://www.instructables.com/Raspberry-PI-Multiple-I2c-Devices/


Thanks for the link.

At the beginning of the year, there were some posts saying that CircuitPython could use one I2C bus only. Later on, some reported that bug was fixed and now CircuitPython can take advantage of multiple buses running in parallel. In terms of throughput, how is the performance of running all or most devices in the default bus vs. distributing them evenly among different buses?

adafruit_user2015
 
Posts: 40
Joined: Wed Mar 18, 2015 9:19 pm

Re: Need some help to setup CircuitPython on Pi4

by dastels on Mon Oct 19, 2020 11:56 am

I can't see any real advantage to using separate buses in terms of performance. You still only have one core to use them. Maybe if you had them run in parallel with a transaction complete notification. That would likely only be useful for very long running transactions which, in our context, isn't the case.

Dave

dastels
 
Posts: 3864
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need some help to setup CircuitPython on Pi4

by dastels on Mon Oct 19, 2020 11:57 am

Also, remember that CircuitPython doesn't run on the Pi. You're dealing with cpython3.

Dave

dastels
 
Posts: 3864
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need some help to setup CircuitPython on Pi4

by adafruit_user2015 on Mon Oct 19, 2020 12:51 pm

I see the default I2C bus speed on the Pi4 is 100KHz but we can set it to 400KHz. Do all Adafruit breakout boards support 400KHz? How do I know which do and which don't?

Some sensors I2C address cannot be changed and others have limited number of available address. In addition, my breadboard has 5 pins on one side so there is a limit on the number of I2C devices I can daisy change.

For example, in the guide it says that we cannot change the I2C address of the VL6180X but somebody said we can do it. I am puzzled.
https://learn.adafruit.com/adafruit-vl6 ... ut/pinouts

adafruit_user2015
 
Posts: 40
Joined: Wed Mar 18, 2015 9:19 pm

Re: Need some help to setup CircuitPython on Pi4

by dastels on Mon Oct 19, 2020 2:48 pm

I don't know about bus speeds.

Chaining limitations are a reason to go with the STEMMA-AT based breakouts.

This sensor appears to be able to have it's address set as part of the power-up sequence by setting register 0x212. See page 76 of the datasheet at https://www.st.com/resource/en/datasheet/vl6180x.pdf

Dave

dastels
 
Posts: 3864
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.