Thursday, June 13, 2019

Physical Port access for NanoPi using Python on Debian


There are two ways to access GPIOs easily on NanoPi.


  1. In C language using WiringNP which is a port of the WiringPi library written for the Raspberry PI's BCM2835. 
  2. In Python using RPi.GPIO_NP which is a port of the RPi.GPIO library for the Raspberry PI. The problem is that this python distribution is only integrated in the FriendlyCore OS images and is not available to be installed directly for python in other images like Debian using pip or pip3. So in order to run RPi.GPIO_NP library for debian distro for NanoPi here are the following steps:


Step 1: Download 

  • git clone https://github.com/chainsx/RPi.GPIO.NP
Step 2: Installation
  • sudo apt-get update
  • sudo apt-get install python-dev
  • cd RPi.GPIO.NP
  • python setup.py install
  • sudo python setup.py install
Step 3: Restart NanoPi

Step 4: Test
  • type python to open the CLI for python
  • >> import RPi.GPIO
  • >>
  • If there is no import error, the library has been successfully installed
Step 5: Test Program

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
PIN_NUM = 7
 
GPIO.setmode(GPIO.BOARD)
GPIO.setup(PIN_NUM,GPIO.OUT)
while True:
        GPIO.output(PIN_NUM,True)
        time.sleep(1)
        GPIO.output(PIN_NUM,False)
        time.sleep(1)

Pictures:





Links:
https://github.com/chainsx/RPi.GPIO.NP
https://github.com/auto3000/RPi.GPIO_NP


No comments:

Post a Comment