Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to configure SPI on NanoPi Duo

Featured Replies

I'm working on a Duo project that needs SPI and this is how I configured and tested it without the mini shield.

 

Requirements:

  • NanoPi Duo with test Armbian image
  • 1 female to female jumper wire

Enable SPI on boot:

  • sudo nano /boot/armbianEnv.txt
  • Add spi-spidev to overlays=
  • Add line param_spidev_spi_bus=1
  • sudo reboot

If everything worked you should have /dev/spidev1.0. Check with ls /dev/spi*. Now we can test with a C program:

cd
wget http://www.raspibo.org/renzo/spidev_test.c 
gcc -o spidev_test spidev_test.c
sudo ./spidev_test -D /dev/spidev1.0

spi device: /dev/spidev1.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00

shutdown now -h then wire up MO and MI pins with jumper to create loop back and power up

sudo ./spidev_test -D /dev/spidev1.0

spi device: /dev/spidev32766.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF 
40 00 00 00 00 95 
FF FF FF FF FF FF 
FF FF FF FF FF FF 
FF FF FF FF FF FF 
DE AD BE EF BA AD 
F0 0D

OK, let's try some Python now:

sudo apt-get update
sudo apt-get install python-dev
sudo apt-get install python-pip
sudo -H pip install --upgrade pip setuptools
sudo -H pip install --upgrade spidev
nano spitest.py

import spidev

input = [1 ,2 ,3, 4, 5]
print "input: %s" % input
spi = spidev.SpiDev()
spi.open(1,0)
output = spi.xfer2(input)
print "output: %s" % output

Save code and run program:

sudo python spitest.py

input: [1, 2, 3, 4, 5]
output: [1, 2, 3, 4, 5]

 

 

IMG_20171220_185220.jpg

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.