Home > Nano Pi > NanoPi S2 GPIO Mapping to access using SysFS

NanoPi S2 GPIO Mapping to access using SysFS

In this post, I have mapped all the pins of Nano Pi S2 so that the GPIO can be easily accessed using SysFS.

This post is all about GPIO pin numbering to use with SysFS. In this post, I have mapped all the pins of Nano Pi S2 so that the GPIO can be easily accessed using SysFS. The pins are mapped according to the following formula,

sysfs pin number- X(GPIOX)+Y(GPIOXY)
Where,
X value depends on the GPIO group and is like below
GPIOA: 0
GPIOE: 128
GPIOALV: 160
GPIOB: 32
GPIOC: 64
GPIOD: 96
and Y is the pin number next to GPIO group name


Pin#	Name				Pin#	Name
1	SYS_3.3V		--	2	VDD_5V			--
3	I2C0_SDA/GPIOD2		98	4	VDD_5V			--
5	I2C0_SCL/GPIOD3		99	6	DGND			--
7	GPIOD8/PPM		104	8	UART3_TXD/GPIOD21   	117
9	DGND			--	10	UART3_RXD/GPIOD17   	113
11	UART4_TX/GPIOB29	61	12	GPIOD1/PWM0          	97
13	GPIOB30			62	14	DGND			--
15	GPIOB31			63	16	GPIOC14/PWM2		78       
17	SYS_3.3V		--	18	GPIOB27                 69
19	SPI0_MOSI/GPIOC31	95	20	DGND			--
21	SPI0_MISO/GPIOD0	96	22	UART4_RX/GPIOB28        60
23	SPI0_CLK/GPIOC29	93	24	SPI0_CS/GPIOC30         94
25	DGND			--	26	GPIOB26                 58
27	I2C1_SDA/GPIOD5		101	28	I2C1_SCL/GPIOD4		100
29	GPIOC8			72	30	DGND			--
31	GPIOC7			71	32	GPIOC28                 92 
33	GPIOC13/PWM1		77	34	DGND			--
35	SPI2_MISO/GPIOC11	75	36	SPI2_CS/GPIOC10         74
37	AliveGPIO3		163	38	SPI2_MOSI/GPIOC12       76
39	DGND			--	40	SPI2_CLK/GPIOC9         73
  

Schematic of NanoPi S2 SBC: http://bit.ly/2qbp7UT

Checkout NanoPi S2: http://bit.ly/2ptw7xM

NanoPi S2 WiKi: http://bit.ly/2lvM1lC

Some sysfs examples:

A simple script to access GPIOD8 / 104 and blink LED connected to it for 10 times. For other GPIO change accordingly.

#! /bin/bash

cd /sys/class/gpio
echo 104 > export
cd gpio104
echo “out” > direction

for i in {1..10}
do
echo 0 > value
sleep 1
echo 1 > value
sleep 1
done

cd ..
echo 104 > unexport

 

 

Check out my YouTube channel for other video tutorials.

 

Bikash Panda
Catch Me On

Bikash Panda

Blogger / Embedded System Developer at WeArGenius
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Bikash Panda
Catch Me On
  1. No comments yet.
  1. No trackbacks yet.