• sales

    +86-0755-88291180

Raspberry Pi Installing CircuitPython Libraries on Raspberry Pi User Guide

  • CircuitPython libraries and adafruit-blinka will work on any Raspberry Pi board except the compute module! That means the original 1, the Pi 2, Pi 3, Pi 4 or Pi Zero.
  1. Download the latest Raspbian or Raspbian Lite to your computer
  2. Burn the Raspbian image to your MicroSD card using your computer
  3. Re-plug the SD card into your computer (don't use your Pi yet!) and set up your wifi connection by editing supplicant.conf
  4. Activate SSH support
  5. Plug the SD card into the Pi
  6. If you have an HDMI monitor we recommend connecting it so you can see that the Pi is booting OK
  7. Plug in power to the Pi - you will see the green LED flicker a little. The Pi will reboot while it sets up so wait a good 10 minutes
  8. If you are running Windows on your computer, install Bonjour support so you can use .local names, you'll need to reboot Windows after installation
  9. You can then ssh into raspberrypi.local

The Pi Foundation has tons of guides as well

  • We really really recommend the lastest Raspbian only. If you have an older Raspbian install, run "sudo apt-get update" and "sudo apt-get upgrade" to get the latest OS!

Update Your Pi and Python

Run the standard updates:

sudo apt-get update

sudo apt-get upgrade

and

sudo pip3 install --upgrade setuptools

If above doesn't work try

sudo apt-get install python3-pip


  • Python2 support has been dropped, so you will need to either use pip3 and python3 as commands or set Python 3 as the default python install.


Set your Python install to Python 3 Default

There's a few ways to do this, we recommend something like this

  • sudo apt-get install -y python3 git python3-pip
  • sudo update-alternatives --install /usr/bin/python python $(which python2) 1
  • sudo update-alternatives --install /usr/bin/python python $(which python3) 2
  • sudo update-alternatives --config python

Enable I2C and SPI

A vast number of our CircuitPython drivers use I2C and SPI for interfacing so you'll want to get those enabled.

You only have to do this once per Raspberry Pi but by default both interfaces are disabled!

Once you're done with both and have rebooted, verify you have the I2C and SPI devices with the command

ls /dev/i2c* /dev/spi*

You should see the response

/dev/i2c-1 /dev/spidev0.0 /dev/spidev0.1




Enabling Second SPI

If you are using the main SPI port for a display or something and need another hardware SPI port, you can enable it by adding the line

dtoverlay=spi1-3cs

to the bottom of /boot/config.txt and rebooting. You'll then see the addition of some /dev/spidev1.x devices:


Make sure you're using Python 3!

The default python on your computer may not be python 3. Python 2 is officially discontinued and all our libraries are Python 3 only.

We'll be using python3 and pip3 in our commands, use those versions of python and pip to make sure you're using 3 and not 2

Install Python libraries

Now you're ready to install all the python support

Run the following command to install the Raspberry PI GPIO library:

pip3 install RPI.GPIO




Run the following command to install adafruit_blinka

pip3 install adafruit-blinka




The computer will install a few different libraries such as adafruit-pureio (our ioctl-only i2c library), spidev (for SPI interfacing), Adafruit-GPIO (for detecting your board) and of course adafruit-blinka

That's pretty much it! You're now ready to test.

Blinka Test

Create a new file called blinkatest.py with nano or your favorite text editor and put the following in:

 Download: file
  1. import board
  2. import digitalio
  3. import busio
  4.  
  5. print("Hello blinka!")
  6.  
  7. # Try to great a Digital input
  8. pin = digitalio.DigitalInOut(board.D4)
  9. print("Digital IO ok!")
  10.  
  11. # Try to create an I2C device
  12. i2c = busio.I2C(board.SCL, board.SDA)
  13. print("I2C ok!")
  14.  
  15. # Try to create an SPI device
  16. spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
  17. print("SPI ok!")
  18.  
  19. print("done!")

Save it and run at the command line with

python3 blinkatest.py

You should see the following, indicating digital i/o, I2C and SPI all worked



TAG: Raspberry Pi Triple Screen HAT ESP32-S3 AI Electronic Eye Development Doard DualEye TouchEye 1.28 inch TouchScreen LCD Round Display N16R8 Toy Doll Robot Industrial Modbus POE ETH RJ45 To 8-Ch Relay B RTU/Modbus TCP-Ethernet For IOT DeepSeek AI Voice Chat ESP32 C6 Development Board 2.06-inch AMOLED Display 410×502 2.06inch TouchScreen Programmable Watch Raspberry-Pi-ESP32-Pico-Display-image-1.83inch-LCD-NV3030B-ADD-NEW-Picture ESP32-C3FN4 Raspberry pi Pico development board RP2040 Core A Based On Official RP2040 Dual Core Processor Bevelopment Board IPS Raspberry Pi 5 Camera Omni-Directional Lidar ESP32 S3 Development Board 2.8 inch Round LCD Display 480x480 QMI8658 Sensor / MIC / SD /MP3 Audio /Battery Port LVGL/HMI For Arduino TTL UART To CAN Mini Gripper Serial Robotic Arm Gripper Mechanical claw Serial Bus Servo ST3215/CF35-12 Raspberry Pi 10.1 inch DSI MIPI LCD TouchScreen Display 10.1inch 720x1280 For Luckfox Lyra RK3506/ESP32-P4/Luckfox Omni3576 UART Solar Charge Module Raspberry Pi PICO LoRa Milk-V Duo EC200U C4-P01 Development Board QuecPython LTE Cat-1 Bluetooth GNSS Positioning