# Adding a Single Board Computer to Blinka

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/089/982/medium800/raspberry_pi_main_image.jpg?1585357290)

So you have a new board, that you want to get working with Blinka, Adafruit's CircuitPython library compatibility layer for Single Board Computers, or SBCs. Adding a board to Blinka is a 2-part process with the first step being to add it to `PlatformDetect` so that Blinka knows what board it is working with.

In the [PlatformDetect guide](https://learn.adafruit.com/adding-a-single-board-computer-to-platformdetect-for-blinka), the steps needed to get your chip and board correctly detected was addressed so that Blinka knew what it was working with. This guide goes over the second part to get your board functioning on Blinka.

This guide goes over everything that's left to get your board working with Blinka including:

- Adding the Chip and Board files
- Getting GPIO working
- Getting I2C, SPI, and UART working

Along with some additional resources.

The way that Blinka works is it combines multiple techniques to access the parts of the board that it needs. It also depends on the type of board. With MicroPython, the native libraries are translated. For Linux GPIO, libraries such as&nbsp;`RPi.GPIO`&nbsp;or&nbsp;`libgpiod`&nbsp;are used. For I2C, the&nbsp;[PureIO Python library](https://pypi.org/project/Adafruit-PureIO/) is used, and for SPI, the [spidev Python library](https://pypi.org/project/spidev/) is used.

When it comes to Blinka itself, there are two main components that need to be defined.

- First there is the&nbsp; **chip** , the microprocessor definition.
- Second, there is the&nbsp; **board** &nbsp;definition.

**The chip defines which pins of the microprocessor are used by the GPIO library** &nbsp;and&nbsp; **the board definition defines which physical pin on the board maps to the pins defined by the chip file**.&nbsp;There can be multiple boards that all use the same chip, but the specific implementation may be slightly different.

The overall layout of the way these files are accessed looks like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/096/158/medium800/raspberry_pi_Blinka_Layout.png?1603222558)

This guide picks up where the&nbsp;[PlatformDetect guide](https://learn.adafruit.com/adding-a-single-board-computer-to-platformdetect-for-blinka) left off and goes over what steps are needed to add a board, such as the Pine A64 as an example, to Blinka.

## Parts
### USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi

[USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi](https://www.adafruit.com/product/954)
The cable is easiest way ever to connect to your microcontroller/Raspberry Pi/WiFi router serial console port. Inside the big USB plug is a USB\<-\>Serial conversion chip and at the end of the 36" cable are four wire - red power, black ground, white RX into USB port, and green TX out...

In Stock
[Buy Now](https://www.adafruit.com/product/954)
[Related Guides to the Product](https://learn.adafruit.com/products/954/guides)
![USB to TTL Serial Cable With Type A plug and 4 wire sockets](https://cdn-shop.adafruit.com/640x480/954-02.jpg)

### FTDI Serial TTL-232 USB Type C Cable

[FTDI Serial TTL-232 USB Type C Cable](https://www.adafruit.com/product/4364)
Just about all electronics use a UART serial port with RX and TX pins for debugging, bootloading, programming, serial output, etc. But it's rare for a computer to have a serial port anymore. Thus, a serial cable is an essential part of any electrical engineer's toolkit.

This is a...

In Stock
[Buy Now](https://www.adafruit.com/product/4364)
[Related Guides to the Product](https://learn.adafruit.com/products/4364/guides)
![A coiled, black, FTDI cable with a USB-C connector.](https://cdn-shop.adafruit.com/640x480/4364-01.jpg)

### Diffused Blue 10mm LED (25 pack)

[Diffused Blue 10mm LED (25 pack)](https://www.adafruit.com/product/847)
Need some big indicators? We are big fans of these huge diffused blue LEDs. They are really bright so they can be seen in daytime, and from any angle. They go easily into a breadboard and will add that extra zing to your project.

- Pack of 25 diffused blue LEDs
- 10mm...

In Stock
[Buy Now](https://www.adafruit.com/product/847)
[Related Guides to the Product](https://learn.adafruit.com/products/847/guides)
![Single large LED lit up blue](https://cdn-shop.adafruit.com/640x480/847-00.jpg)

### Tactile Switch Buttons (12mm square, 6mm tall) x 10 pack

[Tactile Switch Buttons (12mm square, 6mm tall) x 10 pack](https://www.adafruit.com/product/1119)
Medium-sized clicky momentary switches are standard input "buttons" on electronic projects. These work best in a PCB but [can be used on a solderless breadboard as shown in this tutorial](https://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs?view=all). The...

In Stock
[Buy Now](https://www.adafruit.com/product/1119)
[Related Guides to the Product](https://learn.adafruit.com/products/1119/guides)
![Angled shot of 10 12mm square tactile switch buttons.](https://cdn-shop.adafruit.com/640x480/1119-03.jpg)

### Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor

[Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor](https://www.adafruit.com/product/2652)
Bosch has stepped up their game with their new BME280 sensor, an environmental sensor with temperature, barometric pressure&nbsp;and&nbsp;humidity! This sensor is great for all sorts of indoor environmental sensing and can even be used in both I2C and SPI!

This precision sensor from...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2652)
[Related Guides to the Product](https://learn.adafruit.com/products/2652/guides)
![small, rectangle-shaped, BME280 temperature humidity pressure sensor breakout board.](https://cdn-shop.adafruit.com/640x480/2652-04.jpg)

### Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)

[Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)](https://www.adafruit.com/product/269)
Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference. The MAX31855K does everything for you, and can be easily interfaced with any microcontroller, even one without an analog input. This breakout board has the chip itself, a 3.3V regulator with 10uF...

In Stock
[Buy Now](https://www.adafruit.com/product/269)
[Related Guides to the Product](https://learn.adafruit.com/products/269/guides)
![Angled shot of black, square-shaped thermocouple breakout board with a green 2-pin terminal block.](https://cdn-shop.adafruit.com/640x480/269-06.jpg)

### Thermocouple Type-K Glass Braid Insulated

[Thermocouple Type-K Glass Braid Insulated](https://www.adafruit.com/product/270)
Thermocouples are best used for measuring temperatures that can go above 100 °C. This is a bare wires bead-probe which can measure air or surface temperatures. Most inexpensive thermocouples have a vinyl covering which can melt at around 200 °C, this one uses a fiberglass braid so it...

In Stock
[Buy Now](https://www.adafruit.com/product/270)
[Related Guides to the Product](https://learn.adafruit.com/products/270/guides)
![Angled shot of a Thermocouple Type-K Glass Braid Insulated wire. ](https://cdn-shop.adafruit.com/640x480/270-02.jpg)

### Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates

[Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates](https://www.adafruit.com/product/746)
We carry a few different GPS modules here in the Adafruit shop, but none that satisfied our every desire - that's why we designed this little GPS breakout board. We believe this is the **Ultimate** GPS module, so we named it that. It's got everything you want and...

In Stock
[Buy Now](https://www.adafruit.com/product/746)
[Related Guides to the Product](https://learn.adafruit.com/products/746/guides)
![Angled shot of GPS module breakout.](https://cdn-shop.adafruit.com/640x480/746-11.jpg)

# Adding a Single Board Computer to Blinka

## Software Setup

Warning: This guide picks up where the [PlatformDetect guide](https://learn.adafruit.com/adding-a-single-board-computer-to-platformdetect-for-blinka) left off, so make sure to follow that first if you haven't.

The first thing you will need to do is decide on the GPIO library you will be using. If there is a manufacturer specific library available such as `RPi.GPIO` or `Jetson.GPIO`, then that is preferred, since the access times are much better. However, if that option isn't available, then you will want to turn to `libgpiod` which is available for a huge number of boards as it is built into the Linux Kernel.

For the Pine64, although **RPi.GPIO** was ported over, I ran into an unresolved issue, so I decided to go with **libgpiod**. Generally libgpiod is available as an installable package, but it's possible that you may need to compile it from source. For the Pine64, it was available as a package.

# Installing libgpiod as a package

First you want to check if it's available. To do this, you run the following command:

`sudo apt-cache search gpiod`

It should output something similar to the following:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/411/medium800/python_gpiod_apt-cache.png?1584406496)

The items of interest in this list are:

- **libgpiod3** which is the actual libgpiod
- **python3-libgpiod** which is the Python binding that allows us to make use of the library through Python
- **gpiod** which contains the tools that you'll need to figure out which microprocessor pins are the correct ones.

Let's go ahead and install all three with the following command:

`sudo apt-get install libgpiod3 python3-libgpiod gpiod`

![](https://cdn-learn.adafruit.com/assets/assets/000/089/412/medium800/python_package_install_libgpiod.png?1584406818)

## Installing libgpiod from source
If libgpiod isn't available on the OS for the board you are configuring, you can also compile from source. Normally compiling libgpiod from source can be complicated. There is a script available that will do just about everything for you. To run it, you need to use the following commands:

```terminal
cd ~
sudo pip3 install --upgrade adafruit-python-shell click
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/main/libgpiod.py
sudo python3 libgpiod.py
```

This will take a few minutes to run. If you get an error, try adding the `-l` or `--legacy` flag to the last command.

## Testing the libgpiod installation

After installation you should be able to&nbsp;`import gpiod`&nbsp;from within Python3

![](https://cdn-learn.adafruit.com/assets/assets/000/089/414/medium800/python_libgpiod_test.png?1584407954)

# Install I2C Tools

To test I2C, you will want to install the I2C Tools with the following commands. If your username is different than **pi** , change it as appropriate:

```terminal
sudo apt-get install -y python3-smbus python3-dev i2c-tools
sudo adduser pi i2c
```

# Getting a copy of the code

#### Step 1 - Fork Blinka to your GitHub account

If you don't already have the code from [Adafruit\_Blinka](https://github.com/adafruit/Adafruit_Blinka) forked to your local GitHub repository, you'll want to start off by doing that. If you are not sure how to use GitHub, we have [an excellent guide available on using Git and GitHub](https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/grab-your-fork).

#### Step 2 - git clone the Blinka fork to your single board computer

Once you have forked it, you can clone the repository both onto your local computer and onto your SBC. By using your local repository as a copy point, this makes things really easy. If you'd prefer to just edit right on your SBC and commit from there, you can do that too. **In this guide, it assumes you cloned it to your home directory on your SBC.**

Some other options for copying over the files include using SFTP and an FTP client such as FileZilla or SCP. However, you decide to do it, the guide will assume that you have a copy of the repository in your home directory and that it is located inside the folder **~/Adafruit\_Blinka**.

# Adding a Single Board Computer to Blinka

## Adding the Chip File

This next step is probably the most difficult part of the entire process because there is no one-size-fits-all method for getting the information and every board is different. So rather than concentrating on a specific set of steps, this guide will be discussing various strategies for acquiring the information. It also depends on which GPIO library you went with.

Strategies can range from looking at the microprocessor data sheet to finding similar code that already has the pins figured out, to having the GPIO library just tell you. Another strategy is simple trial and error by just setting a line and seeing if it changes the value. Often times though, it is a combination of different strategies combined together.

It's entirely possible that you may not need to create a chip file. If a chip file for your board already exists or one that is close enough exists, you should definitely use that one. If you do find that you need to create one, it's probably best to see what already exists and make a copy of that file to use as a starting point. When you make a copy, you will want to copy the entire folder.

If you followed the instruction in the software setup, you should have the **Adafruit\_Blinka** folder in your home directory. Inside of there you'll want to navigate to **src/adafruit\_blinka/microcontroller** which is where all of the chip files are located, sorted by manufacturer.

In the case of the Pine64, the AllWinner H3 chip is already set up, so I'll make a copy of the **h3** folder and leave it under the **allwinner** folder. The new folder is called **a64**.

Warning: 

At a minimum, the folder should contain an **\_\_init\_\_.py** and **pin.py** file. The init file will most likely be empty or only contain a comment. The **pin.py** file will contain all of the Chip pin information. Here's what the h3 **pin.py** file looks like:

https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/microcontroller/allwinner/h3/pin.py

## Checking with the GPIO library

You'll start with the easiest strategy, which is to check with the GPIO library. The first thing you want to do is map out the chip. You will start off by seeing how many GPIO chips are detected. There should be at least one, but there may be a few. To do this you type:

- `sudo gpiodetect`

![](https://cdn-learn.adafruit.com/assets/assets/000/089/486/medium800/python_gpiodetect.png?1584459812)

This tells us that there are 3 GPIO chips on the Pine64 and the number of lines that each controls. It's likely the bulk of them are on gpiochip1.

Next you will look for some more detailed information by typing:

- `sudo gpioinfo`

![](https://cdn-learn.adafruit.com/assets/assets/000/089/487/medium800/python_gpioinfo.png?1584459971)

In this case, most of the lines are unnamed. In some chips, they may actually have the pin numbers which makes things much easier.

For the Pine64, since there are multiple GPIO chips and there are only 32 lines associated with the first chip. This means the bulk of the lines will most likely be associated with the GPIO chip 1.

For the H3 chip, only an integer is passed, which means that it associates all the pin numbers with GPIO chip 0. However, for the A64 chip, it will likely need specified which chip each of the lines is on, so instead of specifying something like:

`PC0 = Pin(64)`

If **line 64** was based off **gpiochip1** , it would need to use a tuple instead of an integer and specify it more like:

`PC0 = Pin((1, 64))`

How do you know which line is associated with which GPIO chip? That involves a little bit of guess work. You can see there are 32 lines in the first GPIO chip and 256 lines in the second. The third has only 2 lines, so it most likely will not be used.

## Looking Up a Pinout Diagram

Sometimes looking up a Pinout diagram can help yield clues. A web search for **Pine64 Pinout** , yielded this pinout diagram available at [http://joey.hazlett.us/pine64/pine64\_pins.html](http://joey.hazlett.us/pine64/pine64_pins.html),&nbsp;which is very helpful:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/554/medium800/python_Pine64-pin-layout.jpg?1584554042)

According to the diagram, it appears **PC0** is using **GPIO 64** , which matches what is in the h3 pin mappings.

## Checking Data Sheets

The next thing you would do is try and find a data sheet with a web search. The Pine A64 uses the AllWinner A64 chip, which you can figure by doing some web searches and doing some reading. For this chip, there is a [data sheet available here](http://files.pine64.org/doc/datasheet/pine64/A64_Datasheet_V1.1.pdf).

The important part of this data sheet is section 4 titled **Pin Characteristics**. It shows us the **Pin Names** grouped by GPIO blocks starting with **GPIO B**. You may notice that these Pin names match those in the Pinout Diagram.

## Testing a physical GPIO Pin

Just to help out with figuring out the layout, you can test to see if setting a libgpiod line on a chip corresponds to the pin you think it should correspond to. For this example,&nbsp; look at pin PC0, which appears to be physically connected to Pin 19 of the 40-pin Pi header according to the Pinout diagram. The next thing to do is to connect an LED up to it to test turning it off and on:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/557/medium800/python_LED_Test_bb.jpg?1584556459)

[Download Fritzing Object](https://cdn-learn.adafruit.com/assets/assets/000/089/558/original/LED_Test.fzz?1584556469)
As mentioned earlier, this pin uses line 64 and is most likely connected to gpiochip1 since that's the only GPIO chip with enough lines. To test, you can type in the `gpioset` command like:

- `sudo gpioset gpiochip1 64=1`

If everything is correct, the LED should turn on, which confirms the hypothesis. To try out the same thing with pins such as PB1, which says GPIO 33 in the pin diagram, it would also most likely be on **gpiochip1** , and after testing, this is in fact the case.

## Interpolating the Numbering

Now you may notice that according to the Pinout Diagram, it says pins such as PL10 are using GPIO 362 and you can see that none of the GPIO chips have that many lines, so it looks like taking a different approach is in order. There was no GPIO block A, so what if gpiochip0 controls GPIO block L onwards? The next thing to try is connecting PL10, which appears to be connected to Physical Pin 7 up to the LED.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/559/medium800/python_LED_Test2_bb.jpg?1584559257)

[Download Fritzing Object](https://cdn-learn.adafruit.com/assets/assets/000/089/560/original/LED_Test2.fzz?1584559268)
So based on the hypothesis that PL10 is using gpiochip0 and line 10, I'll try typing the command:

- `sudo gpioset gpiochip0 10=1`

Unfortunately, it didn't turn on the LED. However, after&nbsp;digging through some documentation a bit further, I found that PL10 does in fact correspond to GPIO 10 on gpiochip1. According to the Pinout, 362 refers to the GPIO pin number when accessing the pin via SysFs, which is an old way of accessing the pins and is not terribly efficient. When I set the pin via SysFs, it also did not light up the LED, but when running the gpioset command again, this time I got the error message:

**gpioset: error setting the GPIO line values: Device or resource busy**

The LED isn't turning on either way, which means 3 of the pins on the Pi 2 header may not be able to run, but this is acceptable and perhaps this can be revisited in the future. The important thing is the pin mapping has been verified.

For the rest of the GPIO pins, it appears that all of the pins from GPIO B through GPIO H are fine and definitely running off gpiochip1. The next thing is to take a look at a few known values and see if a pattern emerges.

According to the pinout diagram, PC0, PC1, and PC2 correspond to 64, 65, and 66 respectively, so it appears they are in order. PC5 is 69 and PC9 is 73. Thus it can be inferred PC6 through PC8 are likely 70 through 72.

Ok, next look at the pins starting with PB0, which appears to correspond to 32. According to the data sheet, there are only 10 pins in GPIO block B, so while 42 through 63 would normally be in this block, they are not used and can be ignored. In fact, based on the note at the bottom of the Pinout, you can see that every GPIO block has 32 numbers allocated to it which makes figuring out the exact numbers much easier.

## Finishing up the GPIO Pins

If there are any GPIO pins that don't belong _that you added_, go ahead and remove those from the&nbsp; **chip.py** file. Add only the pins that are going to be used. If the **chip.py** file already existed from another board, add any new pins that your board uses that the other board may not have used.

### Pin Aliases

If you need any aliases, after defining a pin, just refer to the already defined pin rather than making a new pin. For instance, if you wanted to create Pin PC0 and also have the name SPI0\_MOSI, you would do something like the following:

```python
PC0 = Pin((1, 64))
SPI0_MOSI = PC0
```

### I2C, SPI and UART Ports

You will add any I2C, SPI, and UART pins in a later section and address both the chip and board files at the same time.

## Adding the MicroController to the JSON File

As of Blinka version 9.0.0, the MicroController imports are now stored in **microcontroller\_imports.json**. The code checks for chips in the order they are listed, so if one chip needs to be checked before another, it should be listed before that chip.

The chip import should be added like:

```javascript
"CHIP_ID": "import.path",
```

In very special cases, the import needs to be further refined by the board. However, this should be avoided if at all possible. In these special cases, it is added like:

```javascript
"CHIP_ID": {
    "BOARD_ID": "import.path"
    "default": "default.import.path"
},
```

The `CHIP_ID` corresponds to the ID that PlatformDetect returns. This will automatically add the chip to the&nbsp; **microcontroller** , **microcontroller.pin** , and **digitalio** imports.

If there is an existing chip with the same import path, you can point your chip ID to that path.

## Additional Resources

- A very useful page about using libgpiod to get GPIO working [https://www.beyondlogic.org/an-introduction-to-chardev-gpio-and-libgpiod-on-the-raspberry-pi/](https://www.beyondlogic.org/an-introduction-to-chardev-gpio-and-libgpiod-on-the-raspberry-pi/).
- A useful page on the general usage of libgpiod: [https://www.acmesystems.it/libgpiod](https://www.acmesystems.it/libgpiod)

# Adding a Single Board Computer to Blinka

## Adding the Board File

The board file is much easier than the chip file. It basically involves loading the chip file and just mapping the chip pins to the physical pins on the board. At this time there hasn't a consistent naming of the pins due to the documentation provided by different manufacturers referencing the pins by different names.

For instance, naming pins like D4, to imply it is a digital pin number 4, or GPIO22 are pretty common. Some boards also use the same name as the microcontroller pin name like PC0. However, if the board you are using has a Raspberry Pi style connector, we recommended that you go with the D naming scheme since using a name like D4 will make it so it is more consistent with existing CircuitPython examples without needing changes.

If you followed the instruction in the software setup, you should have the **Adafruit\_Blinka** folder in your home directory. Inside of there you'll want to navigate to **src/adafruit\_blinka/board** which is where all of the board files are located, some of them sorted by manufacturer.

Warning: 

For the Pine64, I'm just going to create a file called pine64.py. The first step is to start with creating each of the D pins and assigning it to the pins defined in the chip file. Once that's done, the next step is to create any aliases that are needed such as pins for I2C. We'll go over those a bit more in depth later in this guide. Here are the contents of the board file for the Pine64:

https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/board/pine64/pine64.py

## Adding the Board to the JSON File

As of Blinka version 9.0.0, the Board imports are now stored in **board\_imports.json**. The code checks for boards in the order they are listed, so if one board needs to be checked before another, it should be listed before that board.

The board import should be added like:

```javascript
"BOARD_ID": "import.path",
```

The `BOARD_ID` corresponds to the ID that PlatformDetect returns. This will automatically add the chip to the **board** imports. If there are multiple boards that use the same import, one of the "any\_" board properties defined in PlatformDetect can be used, such as&nbsp;`any_raspberry_pi_40_pin`.

If there is an existing board with the same import path, you can point your board ID to that path.

# Adding a Single Board Computer to Blinka

## Getting GPIO working

There's one very important thing we have left to get GPIO working.If you haven't already added your board and microcontroller imports, you will need to add them to the JSON files. More details can be found on the "Adding the Chip/Board File" pages.

For the remaining files, if you are using an existing microcontroller file, you will most likely not need to make any changes, but it's always good to check.

Warning: Be sure you've added your board definition file to board_imports.json which is where Blinka loads it from.

## Testing

Now that we've gone ahead and added the GPIO to the Chip and Board files, the next step is to go and test out GPIO.

Prior to running tests, you may need to copy the changes you made from contents of the **src** folder to the Python packages folder of your board. An easy way to do this is to perform a pip install by running the following command from the Blinka folder (the same one with **setup.py** ):

```terminal
cd ~/Adafruit_Blinka
sudo pip3 install .
```

First we'll start with checking the output. We can test that with a simple test script in Python to blink an LED. Let's go ahead and wire up a simple circuit with a button and LED. Go ahead and choose one GPIO for output and one for input. For this diagram, we'll use D17 and D18. We're using a pull-up resistor because libgpiod doesn't support built-in pull-ups, but if you are using a different library that does support that, feel free to remove them.

## Parts Used
### Diffused Blue 10mm LED (25 pack)

[Diffused Blue 10mm LED (25 pack)](https://www.adafruit.com/product/847)
Need some big indicators? We are big fans of these huge diffused blue LEDs. They are really bright so they can be seen in daytime, and from any angle. They go easily into a breadboard and will add that extra zing to your project.

- Pack of 25 diffused blue LEDs
- 10mm...

In Stock
[Buy Now](https://www.adafruit.com/product/847)
[Related Guides to the Product](https://learn.adafruit.com/products/847/guides)
![Single large LED lit up blue](https://cdn-shop.adafruit.com/640x480/847-00.jpg)

### Through-Hole Resistors - 220 ohm 5% 1/4W - Pack of 25

[Through-Hole Resistors - 220 ohm 5% 1/4W - Pack of 25](https://www.adafruit.com/product/2780)
ΩMG! You're not going to be able to resist these handy resistor packs!&nbsp;Well, axially, they&nbsp;do all of the resisting for you!

This is a **25 Pack of 220Ω Resistors.** More specifically, they are **carbon film** , through-hole...

In Stock
[Buy Now](https://www.adafruit.com/product/2780)
[Related Guides to the Product](https://learn.adafruit.com/products/2780/guides)
![Angled shot of 25 Through-Hole Resistors - 220 ohm 5% 1/4W.](https://cdn-shop.adafruit.com/640x480/2780-00.jpg)

### Tactile Switch Buttons (12mm square, 6mm tall) x 10 pack

[Tactile Switch Buttons (12mm square, 6mm tall) x 10 pack](https://www.adafruit.com/product/1119)
Medium-sized clicky momentary switches are standard input "buttons" on electronic projects. These work best in a PCB but [can be used on a solderless breadboard as shown in this tutorial](https://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs?view=all). The...

In Stock
[Buy Now](https://www.adafruit.com/product/1119)
[Related Guides to the Product](https://learn.adafruit.com/products/1119/guides)
![Angled shot of 10 12mm square tactile switch buttons.](https://cdn-shop.adafruit.com/640x480/1119-03.jpg)

### Through-Hole Resistors - 1.0K ohm 5% 1/4W - Pack of 25

[Through-Hole Resistors - 1.0K ohm 5% 1/4W - Pack of 25](https://www.adafruit.com/product/4294)
ΩMG! You're not going to be able to resist these handy resistor packs!&nbsp;Well, axially, they&nbsp;do all of the resisting for you!

This is a **25 Pack of 1.0KΩ Resistors.** More specifically, they are **carbon film** , through-hole...

In Stock
[Buy Now](https://www.adafruit.com/product/4294)
[Related Guides to the Product](https://learn.adafruit.com/products/4294/guides)
![Angled shot of 25 Through-Hole Resistors - 1.0K ohm 5% 1/4W.](https://cdn-shop.adafruit.com/640x480/4294-00.jpg)

### Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)

[Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/826)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on one end and 0.1" female header contacts...

In Stock
[Buy Now](https://www.adafruit.com/product/826)
[Related Guides to the Product](https://learn.adafruit.com/products/826/guides)
![Angled shot of Premium Female/Male 'Extension' Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/826-04.jpg)

### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

Out of Stock
[Buy Now](https://www.adafruit.com/product/758)
[Related Guides to the Product](https://learn.adafruit.com/products/758/guides)
![Angled shot of Premium Male/Male Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/758-04.jpg)

### Half-Size Breadboard with Mounting Holes

[Half-Size Breadboard with Mounting Holes](https://www.adafruit.com/product/4539)
This cute 3.2″ × 2.1″ (82 × 53mm) solderless half-size breadboard has four bus lines&nbsp;and 30 rows of pins, our favorite size of solderless breadboard for projects. You get a whoppin' **400 tie points**! [Plug in...](http://adafruit.com/feather)

In Stock
[Buy Now](https://www.adafruit.com/product/4539)
[Related Guides to the Product](https://learn.adafruit.com/products/4539/guides)
![Angled shot of Half-Size Breadboard with Mounting Holes.](https://cdn-shop.adafruit.com/640x480/4539-03.jpg)

## Wiring
- Connect the SBC Ground pin to the blue ground rail on the breadboard.
- Connect one side of the tactile switch to SBC&nbsp; **D17** &nbsp;(Pin #11)
- Connect a ~1K-10K pull up resistor from&nbsp; **D17** &nbsp;to&nbsp; **3.3V**
- Connect the other side of the tactile switch to the&nbsp; **ground** &nbsp;rail
- Connect the longer/positive pin of the LED to SBC&nbsp; **D18** &nbsp;(Pin #12)
- Connect the shorter/negative pin of the LED to a 220 ohm-2.2K resistor, the other side of the resistor goes to the **ground** &nbsp;rail

![python_digitalio_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/836/medium640/python_digitalio_bb.jpg?1585152597)

[Download Fritzing Object](https://cdn-learn.adafruit.com/assets/assets/000/089/819/original/digitalio.fzz?1585089099)
## Testing Output

D18 will be used to test the output of GPIO by flashing the LED with this simple script. Go ahead and copy the code and save it on your Single Board Computer as **blink.py**. Be sure to change the GPIO to whichever one you are testing.

```python
import time
import board
import digitalio
 
led = digitalio.DigitalInOut(board.D18)
led.direction = digitalio.Direction.OUTPUT
 
while True:
    led.value = True
    time.sleep(0.5)
    led.value = False
    time.sleep(0.5)
```

No go ahead and run it by typing:

```terminal
sudo python3 blink.py
```

If everything is working properly, you should see the LED blinking on and off.

## Testing Input

We'll go ahead and use the same circuit that we used to test output. This time we'll use a slightly different script. Go ahead and save this script as **button.py**. Be sure to change the GPIO to whichever one you are testing.

```python
import time
import board
import digitalio

led = digitalio.DigitalInOut(board.D18)
led.direction = digitalio.Direction.OUTPUT

button = digitalio.DigitalInOut(board.D17)
button.direction = digitalio.Direction.INPUT

while True:
    led.value = not button.value # light when button is pressed!
```

No go ahead and run it by typing:

```terminal
sudo python3 button.py
```

If everything is working properly, you should see the LED turn on if the button is pressed.

## Troubleshooting Tips

If neither of the above scripts work, here are some troubleshooting tips:

- The problem is more likely to be in the Chip file.
- Try a different GPIO and see if that works
- Check the Data Sheet
- Sometimes Pins are Multiplexed meaning they are used in different ways and something may need to be disabled for them to work.
- If there's a Python Error check to see if you can trace it back
- Sometimes they just don't work
- Try asking in Discord if nothing else works

# Adding a Single Board Computer to Blinka

## Getting I2C Working

Next we'll work on getting I2C working. To get I2C working, you will first need to make sure your I2C is enabled. The exact method to enable it can vary from manufacturer to manufacturer. You can check if it's already enabled by typing the following command:

```terminal
ls /dev/i2c*
```

If it is enabled, there should be at least one i2C port listed.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/823/medium800/python_ls_i2c.png?1585092302)

## Add your board to busio.py

When you added your board to PlatformDetect, if your board is being detected by the any\_embedded\_linux() function, you should be good to go. If not, you will want to go back and add it in [Adafruit\_Python\_PlatformDetect](https://github.com/adafruit/Adafruit_Python_PlatformDetect). See the [Adding Detection Code](https://learn.adafruit.com/adding-a-single-board-computer-to-platformdetect-for-blinka/adding-detection-code) page in our [Adding a Single Board Computer to PlatformDetect for Blinka](https://learn.adafruit.com/adding-a-single-board-computer-to-platformdetect-for-blinka) guide for more details on how to add this.

## Adding to the Chip File

Near the bottom of the Chip File, you will want an `i2cPorts` tuple variable that contains all of the I2C ports. It should end up looking something like the following:

```python
# ordered as i2cId, sclId, sdaId
i2cPorts = (
    (0, I2C0_SCL, I2C0_SDA),
    (1, I2C1_SCL, I2C1_SDA)
)
```

The values in each of the tuple items are as follows:

- The I2C bus number. For instance, a value of **1** corresponds to **/dev/i2c-1**.
- The SCL or Serial Clock pin. This should be an alias for readability.
- The SDA or Serial Data pin. This should also be an alias for readability.

## Adding to the Board File

The only thing you will need to add to the board file are any aliases for the Pins.

## Clock Stretching

Occasionally certain Single Board Computers such as the Raspberry Pi need some settings changed to enable Clock Stretching. You will need to check with the board manufacturer to be certain, but you can read more about it in our [Raspberry Pi Clock Stretching guide](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/i2c-clock-stretching).

## Parts Used

To test, we'll need an I2C controlled board such as the BME280, which is a temperature sensor along with a couple other parts to connect it to the board.

Info: 

### Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor

[Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor](https://www.adafruit.com/product/2652)
Bosch has stepped up their game with their new BME280 sensor, an environmental sensor with temperature, barometric pressure&nbsp;and&nbsp;humidity! This sensor is great for all sorts of indoor environmental sensing and can even be used in both I2C and SPI!

This precision sensor from...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2652)
[Related Guides to the Product](https://learn.adafruit.com/products/2652/guides)
![small, rectangle-shaped, BME280 temperature humidity pressure sensor breakout board.](https://cdn-shop.adafruit.com/640x480/2652-04.jpg)

### Half-Size Breadboard with Mounting Holes

[Half-Size Breadboard with Mounting Holes](https://www.adafruit.com/product/4539)
This cute 3.2″ × 2.1″ (82 × 53mm) solderless half-size breadboard has four bus lines&nbsp;and 30 rows of pins, our favorite size of solderless breadboard for projects. You get a whoppin' **400 tie points**! [Plug in...](http://adafruit.com/feather)

In Stock
[Buy Now](https://www.adafruit.com/product/4539)
[Related Guides to the Product](https://learn.adafruit.com/products/4539/guides)
![Angled shot of Half-Size Breadboard with Mounting Holes.](https://cdn-shop.adafruit.com/640x480/4539-03.jpg)

### Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)

[Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/826)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on one end and 0.1" female header contacts...

In Stock
[Buy Now](https://www.adafruit.com/product/826)
[Related Guides to the Product](https://learn.adafruit.com/products/826/guides)
![Angled shot of Premium Female/Male 'Extension' Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/826-04.jpg)

## Wiring
- Connect the SBC **3.3V** &nbsp;power pin to&nbsp; **Vin**
- Connect the SBC&nbsp; **GND** &nbsp;pin to&nbsp; **GND**
- Connect the SBC **SDA** &nbsp;(Pin #3) pin to the BME280&nbsp; **SDI**
- Connect the SBC **SCL** &nbsp;(Pin #5) pin to to the BME280&nbsp; **SCK**

![python_i2c_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/838/medium640/python_i2c_bb.jpg?1585153566)

[Download Fritzing Object](https://cdn-learn.adafruit.com/assets/assets/000/089/839/original/i2c.fzz?1585153576)
## Check the Connection

After wiring it up, double-check your connections and run the following command to check bus 1:

```terminal
sudo i2cdetect -y 1
```

If it gives you an error, you may need to add an **-r** parameter such as:

```terminal
sudo i2cdetect -r -y 1
```

You should see a device. If not, you may want to try changing the I2C bus number until you get something. The BME280 has an I2C address of **0x77**. It should look like the following:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/841/medium800/python_i2cdetect.png?1585154495)

## Run the Test Script

Testing is really the most involved part about enabling I2C. First make sure the BME280 library is installed. If you chose a different sensor, make sure that library is installed:

```terminal
sudo pip3 install adafruit-circuitpython-bme280
```

Next save the simpletest code to your board as **bme280\_simpletest.py** :

https://github.com/adafruit/Adafruit_CircuitPython_BME280/blob/main/examples/bme280_simpletest.py

Now go ahead and run that code using the following command:

```terminal
sudo python3 bme280_simpletest.py
```

You should see it outputting a temperature and some other data every 2 seconds or so:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/843/medium800/python_bme280_simpletest.png?1585155504)

Info: 

## Troubleshooting Tips

- Make Sure I2C is enabled on your board
- Make sure i2cdetect is seeing the sensor
- Check your Wiring
- Check Permissions
- The board may just not support I2C.

# Adding a Single Board Computer to Blinka

## Getting SPI Working

Info: 

Next you'll want to work on getting SPI working. To get SPI working, you will first need to make sure your SPI is enabled. The exact method to enable it can vary from manufacturer to manufacturer. For the Pine64, we used **armbian-config** and enabled **spi-spidev**. You can check if it's enabled by typing the following command:

```terminal
ls /dev/spi*
```

If it is enabled, there should be at least one SPI port listed.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/852/medium800/python_ls_spi.png?1585157489)

## Adding to the Chip File

Near the bottom of the Chip File, you'll want an `spiPorts` tuple variable that contains all of the SPI ports. It should end up looking something like the following:

```python
# ordered as spiId, sckId, mosiId, misoId
spiPorts = (
    (0, SPI0_SCLK, SPI0_MOSI, SPI0_MISO),
    (1, SPI1_SCLK, SPI1_MOSI, SPI1_MISO),
)
```

The values in each of the tuple items are as follows:

- The SPI bus number. For instance, a value of **1** corresponds to **/dev/spidev0.1**. At this time, only Spidev 0 is supported.
- The SCLK or Serial Clock pin. This should be an alias for readability.
- The MOSI or Microcontroller Out Serial In pin. This should also be an alias for readability.
- The MISO or Microcontroller In Serial Out pin. This should also be an alias for readability.

## Adding to the Board File

The only thing you will need to add to the board file are any aliases for the Pins.

## Parts Used

To test, you'll need an SPI controlled board such as the MAX31855, which is a Thermocouple Amplifier sensor (for temperature measurement) along with a couple other parts to connect it to the board.

Danger: 

### Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)

[Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)](https://www.adafruit.com/product/269)
Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference. The MAX31855K does everything for you, and can be easily interfaced with any microcontroller, even one without an analog input. This breakout board has the chip itself, a 3.3V regulator with 10uF...

In Stock
[Buy Now](https://www.adafruit.com/product/269)
[Related Guides to the Product](https://learn.adafruit.com/products/269/guides)
![Angled shot of black, square-shaped thermocouple breakout board with a green 2-pin terminal block.](https://cdn-shop.adafruit.com/640x480/269-06.jpg)

### Thermocouple Type-K Glass Braid Insulated

[Thermocouple Type-K Glass Braid Insulated](https://www.adafruit.com/product/270)
Thermocouples are best used for measuring temperatures that can go above 100 °C. This is a bare wires bead-probe which can measure air or surface temperatures. Most inexpensive thermocouples have a vinyl covering which can melt at around 200 °C, this one uses a fiberglass braid so it...

In Stock
[Buy Now](https://www.adafruit.com/product/270)
[Related Guides to the Product](https://learn.adafruit.com/products/270/guides)
![Angled shot of a Thermocouple Type-K Glass Braid Insulated wire. ](https://cdn-shop.adafruit.com/640x480/270-02.jpg)

### Half-Size Breadboard with Mounting Holes

[Half-Size Breadboard with Mounting Holes](https://www.adafruit.com/product/4539)
This cute 3.2″ × 2.1″ (82 × 53mm) solderless half-size breadboard has four bus lines&nbsp;and 30 rows of pins, our favorite size of solderless breadboard for projects. You get a whoppin' **400 tie points**! [Plug in...](http://adafruit.com/feather)

In Stock
[Buy Now](https://www.adafruit.com/product/4539)
[Related Guides to the Product](https://learn.adafruit.com/products/4539/guides)
![Angled shot of Half-Size Breadboard with Mounting Holes.](https://cdn-shop.adafruit.com/640x480/4539-03.jpg)

### Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)

[Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/826)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on one end and 0.1" female header contacts...

In Stock
[Buy Now](https://www.adafruit.com/product/826)
[Related Guides to the Product](https://learn.adafruit.com/products/826/guides)
![Angled shot of Premium Female/Male 'Extension' Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/826-04.jpg)

## Wiring
- Connect the SBC&nbsp; **3.3V** &nbsp;power pin to&nbsp; **Vin**
- Connect the SBC&nbsp; **GND** &nbsp;pin to&nbsp; **GND**
- Connect the SBC&nbsp; **SCLK** &nbsp;pin to the MAX31855&nbsp; **CLK**
- Connect the SBC&nbsp; **MISO** &nbsp;pin to to the MAX31855&nbsp; **DO**
- Connect the SBC&nbsp; **D5** &nbsp;pin to to the MAX31855&nbsp; **CS**

![python_linux_sensors_max_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/089/855/medium640/python_linux_sensors_max_bb.png?1585159538)

## Run the Test Script

After wiring it up, double-check your connections. Next, make sure the MAX31855 library is installed. If you chose a different sensor, make sure that library is installed:

```terminal
sudo pip3 install adafruit-circuitpython-max31855
```

Next save the simpletest code to your board as **max31855\_simpletest.py** :

https://github.com/adafruit/Adafruit_CircuitPython_MAX31855/blob/main/examples/max31855_simpletest.py

Now go ahead and run that code using the following command:

```terminal
sudo python3 max31855_simpletest.py
```

You should see it outputting the temperature every 2 seconds or so:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/857/medium800/python_max31855_simpletest.png?1585160172)

Info: 

## Troubleshooting Tips

- Make Sure SPI is enabled on your board
- Try a different GPIO for the Chip Select Pin
- Check your Wiring
- The board may just not support SPI. It often doesn't work for us.

# Adding a Single Board Computer to Blinka

## Getting Serial UART Working

Next we'll work on getting Serial UART working. To get UART working, you will first need to make sure the correct serial ports are&nbsp;enabled. The exact method to enable it can vary from manufacturer to manufacturer. For the Pine64, we used **armbian-config** and enabled **uart2** , **uart3** , and **uart4**. You can check which serial ports are enabled by typing the following command:

```terminal
ls /dev/tty*
```

You'll likely see a lot of ports listed. Finding which port is the proper one is usually found with searching the internet. They often have a letter between the **tty** part and the **number**. Here's what we have on the Pine64:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/859/medium800/python_ls_tty.png?1585160736)

The only ones that have a letter between the tty and number are **/dev/ttyS0** , **/dev/ttyS2** , and **/dev/ttyS3** , which are in fact the correct ones for this board. The reason there is no **/dev/ttyS1** is because that port is being used for the Serial Console, so we didn't enable it. You could try narrowing it down with the following command:

```terminal
ls /dev/tty[a-zA-Z]*
```

This will list only ports with a letter A-Z (lower case or capital) after the tty part.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/864/medium800/python_ls_tty_a-z.png?1585162723)

## Parts Used

To test, we'll need a serial controlled board such as a GPS module, along with a couple other parts to connect it to the board. There's a couple version of the GPS module that are useful. The breakout version is useful for hooking up to GPIO and the USB version makes it easy to test serial via the USB port. For the purposes of this guide though, the breakout version is more useful as it can be connected to a USB to TTL serial cable.

### Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates

[Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates](https://www.adafruit.com/product/746)
We carry a few different GPS modules here in the Adafruit shop, but none that satisfied our every desire - that's why we designed this little GPS breakout board. We believe this is the **Ultimate** GPS module, so we named it that. It's got everything you want and...

In Stock
[Buy Now](https://www.adafruit.com/product/746)
[Related Guides to the Product](https://learn.adafruit.com/products/746/guides)
![Angled shot of GPS module breakout.](https://cdn-shop.adafruit.com/640x480/746-11.jpg)

### USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi

[USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi](https://www.adafruit.com/product/954)
The cable is easiest way ever to connect to your microcontroller/Raspberry Pi/WiFi router serial console port. Inside the big USB plug is a USB\<-\>Serial conversion chip and at the end of the 36" cable are four wire - red power, black ground, white RX into USB port, and green TX out...

In Stock
[Buy Now](https://www.adafruit.com/product/954)
[Related Guides to the Product](https://learn.adafruit.com/products/954/guides)
![USB to TTL Serial Cable With Type A plug and 4 wire sockets](https://cdn-shop.adafruit.com/640x480/954-02.jpg)

### Half-Size Breadboard with Mounting Holes

[Half-Size Breadboard with Mounting Holes](https://www.adafruit.com/product/4539)
This cute 3.2″ × 2.1″ (82 × 53mm) solderless half-size breadboard has four bus lines&nbsp;and 30 rows of pins, our favorite size of solderless breadboard for projects. You get a whoppin' **400 tie points**! [Plug in...](http://adafruit.com/feather)

In Stock
[Buy Now](https://www.adafruit.com/product/4539)
[Related Guides to the Product](https://learn.adafruit.com/products/4539/guides)
![Angled shot of Half-Size Breadboard with Mounting Holes.](https://cdn-shop.adafruit.com/640x480/4539-03.jpg)

### Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)

[Premium Female/Male 'Extension' Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/826)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on one end and 0.1" female header contacts...

In Stock
[Buy Now](https://www.adafruit.com/product/826)
[Related Guides to the Product](https://learn.adafruit.com/products/826/guides)
![Angled shot of Premium Female/Male 'Extension' Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/826-04.jpg)

### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

Out of Stock
[Buy Now](https://www.adafruit.com/product/758)
[Related Guides to the Product](https://learn.adafruit.com/products/758/guides)
![Angled shot of Premium Male/Male Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/758-04.jpg)

## Testing Serial over Built-in UART

For the purposes of adding a new board, we only need to be concerned with whether the Serial over GPIO pins is working as there isn't really anything to configure to get Serial working over USB.

Warning: 

## Wiring
- Connect the SBC **3.3V** &nbsp;power pin to&nbsp; **V+ Rail**
- Connect the SBC&nbsp; **GND** &nbsp;pin to&nbsp; **GND Rail**
- Connect the SBC **TX** pin to the GPS&nbsp; **RX**
- Connect the SBC **RX** pin to to the GPS&nbsp; **TX**
- Connect the GPS **Vin** &nbsp;power pin to&nbsp; **V+ Rail**
- Connect the GPS&nbsp; **GND** &nbsp;pin to&nbsp; **GND Rail**

![python_linux_sensors_uartgps_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/089/865/medium640/python_linux_sensors_uartgps_bb.png?1585162873)

## Run the Test Script

After wiring it up, double-check your connections. Next, make sure PySerial and the GPS library are installed. If you chose a different sensor, make sure that library is installed:

```terminal
sudo pip3 install pyserial adafruit-circuitpython-gps
```

Next save the simpletest code to your board as **gps\_simpletest.py** :

https://github.com/adafruit/Adafruit_CircuitPython_GPS/blob/main/examples/gps_simpletest.py

Next, we need to make a few changes to the test script:

- Comment out the lines that reference&nbsp;`board.TX`,&nbsp;`board.RX`&nbsp;and&nbsp;`busio.uart`
- Uncomment the line to&nbsp;`import serial`
- Uncomment the line to define the&nbsp;`serial`&nbsp;device.
- Change the Serial port to the one you are testing

Now go ahead and run that code using the following command:

```terminal
sudo python3 gps_simpletest.py
```

You should see it outputting some NMEA sentences about every 5 seconds or so:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/867/medium800/python_gps_simpletest.png?1585163557)

Info: 

## Troubleshooting Tips

- Make Sure the Serial UART is enabled on your board
- Make sure the Serial Console isn't sharing the pins
- Check your wiring
- The board may just not work with Serial.

# Adding a Single Board Computer to Blinka

## Adding More Features

This guide covers the basics of adding a board that can support GPIO, I2C, SPI, and UART Serial. However, Blinka supports other features such as PWM Output using the pulseio module, NeoPixel Support, and Analog Support using the analogio module.

Since each of these is implemented differently for each board, we don't have a specific set of steps to follow. However, the separate files for each supported module should be stored in the same folder as your Chip file.

### PWM Output

There are a couple of ways that you can add PWM support to your board. Either you can use built-in PWM support and use the sysfs PWM library, or you can use a custom driver such as one provided by the manufacturer. Custom manufacturer drivers vary widely and is beyond the scope of this guide. Additionally, not all boards support PWM. You could check that it is supported natively by running the command:

```terminal
ls /sys/class/pwm
```

The check if anything shows up. There was nothing for the Pine64, but there was when the Coral was added:

![](https://cdn-learn.adafruit.com/assets/assets/000/090/003/medium800/raspberry_pi_sysfs-class-pwm.png?1585616153)

If you do find something, you can get some more information by typing:

```terminal
sudo cat /sys/kernel/debug/pwm
```

![](https://cdn-learn.adafruit.com/assets/assets/000/090/004/medium800/raspberry_pi_sys-kernel-debug-pwm.png?1585616205)

None of these PWMs in the example photo are in use. You can tell by the **(null)** and that the **period** and **duty cycle** are 0. If they were in use, you couldn't use them. Also, sometimes the pwm chips can control more than 1 pin.

To add natively supported PWM, you'll first need to add pwmOuts to your Chip file such as:

```python
pwmOuts = (
  ((0, 0), PWM1),
  ((1, 0), PWM2),
  ((2, 0), PWM3),
)
```

The first parameter is a tuple and consists of the **PWM chip number** and the **PWM channel** of that chip.

The second parameter is the PWM pin and can be found by either a web search or referring to the manufacturer data.

Don't forget to add the pins to the Board file as well in the same way as the GPIO.

Regardless of whether you are using a manufacturer driver or adding it natively, you will also want to add your board to&nbsp; **Adafruit\_Blinka/src/pwmio.py**.

### NeoPixel Support

To add NeoPixel support, you will need a driver that is capable of running the NeoPixels at a rate of 800Hz since they run at a fixed frequency. If you are able to find or write a driver for the board, you will want to be sure to add your board to **Adafruit\_Blinka/src/neopixel\_write.py.**

### Analog Support

For adding Analog Support, your board will first need to have PINs that have either an ADC or Analog-to-Digital Converter, or a DAC, which is the opposite of an ADC. You will most likely need to create a custom Pin file for your board that adds support for those pins and you will want to add your board to **Adafruit\_Blinka/src/analogio.py.**

# Adding a Single Board Computer to Blinka

## Next Steps

Now that you have your board being correctly detected, the next step is to create a Pull Request to the [Adafruit\_Blinka](https://github.com/adafruit/Adafruit_Blinka) repo. If you are not sure how to create a Pull Request, check out [this page from the GitHub guide](https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/create-your-pull-request) we mentioned earlier. You'll want to be sure to run [Black](https://black.readthedocs.io/en/stable/) to format your code as well as [Pylint](https://www.pylint.org/) so that it passes the automated code check.

Once your Pull Request is approved and merged, your new board will now be a part of Blinka!

![](https://cdn-learn.adafruit.com/assets/assets/000/089/868/medium800/python_guide_main_image.jpg?1585166067)

With all that hard work finished, it's time to show off that new board on [circuitpython.org](https://circuitpython.org/)!

To get your board listed on [circuitpython.org](https://circuitpython.org/), you will want to submit a separate Pull Request for that. Details about adding your board can be found in the [How to add a New Board to the circuitpython.org website guide](https://learn.adafruit.com/how-to-add-a-new-board-to-the-circuitpython-org-website).


## Featured Products

### USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi

[USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi](https://www.adafruit.com/product/954)
The cable is easiest way ever to connect to your microcontroller/Raspberry Pi/WiFi router serial console port. Inside the big USB plug is a USB\<-\>Serial conversion chip and at the end of the 36" cable are four wire - red power, black ground, white RX into USB port, and green TX out...

In Stock
[Buy Now](https://www.adafruit.com/product/954)
[Related Guides to the Product](https://learn.adafruit.com/products/954/guides)
### Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates

[Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates](https://www.adafruit.com/product/746)
We carry a few different GPS modules here in the Adafruit shop, but none that satisfied our every desire - that's why we designed this little GPS breakout board. We believe this is the **Ultimate** GPS module, so we named it that. It's got everything you want and...

In Stock
[Buy Now](https://www.adafruit.com/product/746)
[Related Guides to the Product](https://learn.adafruit.com/products/746/guides)
### FTDI Serial TTL-232 USB Type C Cable

[FTDI Serial TTL-232 USB Type C Cable](https://www.adafruit.com/product/4364)
Just about all electronics use a UART serial port with RX and TX pins for debugging, bootloading, programming, serial output, etc. But it's rare for a computer to have a serial port anymore. Thus, a serial cable is an essential part of any electrical engineer's toolkit.

This is a...

In Stock
[Buy Now](https://www.adafruit.com/product/4364)
[Related Guides to the Product](https://learn.adafruit.com/products/4364/guides)
### Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor

[Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor](https://www.adafruit.com/product/2652)
Bosch has stepped up their game with their new BME280 sensor, an environmental sensor with temperature, barometric pressure&nbsp;and&nbsp;humidity! This sensor is great for all sorts of indoor environmental sensing and can even be used in both I2C and SPI!

This precision sensor from...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2652)
[Related Guides to the Product](https://learn.adafruit.com/products/2652/guides)
### Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)

[Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)](https://www.adafruit.com/product/269)
Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference. The MAX31855K does everything for you, and can be easily interfaced with any microcontroller, even one without an analog input. This breakout board has the chip itself, a 3.3V regulator with 10uF...

In Stock
[Buy Now](https://www.adafruit.com/product/269)
[Related Guides to the Product](https://learn.adafruit.com/products/269/guides)
### Thermocouple Type-K Glass Braid Insulated

[Thermocouple Type-K Glass Braid Insulated](https://www.adafruit.com/product/270)
Thermocouples are best used for measuring temperatures that can go above 100 °C. This is a bare wires bead-probe which can measure air or surface temperatures. Most inexpensive thermocouples have a vinyl covering which can melt at around 200 °C, this one uses a fiberglass braid so it...

In Stock
[Buy Now](https://www.adafruit.com/product/270)
[Related Guides to the Product](https://learn.adafruit.com/products/270/guides)
### Diffused Blue 10mm LED (25 pack)

[Diffused Blue 10mm LED (25 pack)](https://www.adafruit.com/product/847)
Need some big indicators? We are big fans of these huge diffused blue LEDs. They are really bright so they can be seen in daytime, and from any angle. They go easily into a breadboard and will add that extra zing to your project.

- Pack of 25 diffused blue LEDs
- 10mm...

In Stock
[Buy Now](https://www.adafruit.com/product/847)
[Related Guides to the Product](https://learn.adafruit.com/products/847/guides)
### Half-Size Breadboard with Mounting Holes

[Half-Size Breadboard with Mounting Holes](https://www.adafruit.com/product/4539)
This cute 3.2″ × 2.1″ (82 × 53mm) solderless half-size breadboard has four bus lines&nbsp;and 30 rows of pins, our favorite size of solderless breadboard for projects. You get a whoppin' **400 tie points**! [Plug in...](http://adafruit.com/feather)

In Stock
[Buy Now](https://www.adafruit.com/product/4539)
[Related Guides to the Product](https://learn.adafruit.com/products/4539/guides)

## Related Guides

- [Arduino GPS Clock](https://learn.adafruit.com/arduino-clock.md)
- [CircuitPython I2C and SPI Under the Hood](https://learn.adafruit.com/circuitpython-basics-i2c-and-spi.md)
- [CircuitPython Libraries on Linux and the NVIDIA Jetson Nano](https://learn.adafruit.com/circuitpython-libraries-on-linux-and-the-nvidia-jetson-nano.md)
- [Adafruit Ultimate GPS](https://learn.adafruit.com/adafruit-ultimate-gps.md)
- [Esenciales para CircuitPython](https://learn.adafruit.com/esenciales-para-circuitpython.md)
- [PyPortal IoT Weather Station](https://learn.adafruit.com/pyportal-iot-weather-station.md)
- [CircuitPython Libraries on Linux and the 96Boards DragonBoard 410c](https://learn.adafruit.com/circuitpython-libraries-on-linux-and-the-96boards-dragonboard-410c.md)
- [MicroPython Hardware: SPI Devices](https://learn.adafruit.com/micropython-hardware-spi-devices.md)
- [Integrating Home Assistant with Adafruit IO](https://learn.adafruit.com/integrating-adafruit-io-with-home-assistant.md)
- [CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials.md)
- [Adafruit Ultimate GPS with gpsd](https://learn.adafruit.com/adafruit-ultimate-gps-on-the-raspberry-pi.md)
- [Adafruit 1-Wire Thermocouple Amplifier - MAX31850K](https://learn.adafruit.com/adafruit-1-wire-thermocouple-amplifier-max31850k.md)
- [Adafruit FT232H With SPI & I2C Devices](https://learn.adafruit.com/adafruit-ft232h-with-spi-and-i2c-libraries.md)
- [IoT Air Quality Sensor with Adafruit IO](https://learn.adafruit.com/diy-air-quality-monitor.md)
- [Adafruit 2.7" eInk Display Breakouts and Shields](https://learn.adafruit.com/adafruit-2-7-eink-display-breakouts-and-shields.md)
