View: 33986|Reply: 36

WiringPi on OrangePi 2G-IOT[Beta]

[Copy link]

10

threads

35

posts

305

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
305
Published in 2017-6-19 19:04:39 | Show all floors |Read mode
The open source project WiringPi is working on OrangePi 2G-IOT. User can use WiringPi follow this section.
Thanks @Reinhard sharing more userful information about GPIO. It help me porting WiringPi into OrangePi 2G-IOT.
Now, This section will introduce how to utilize WiringPi on OrangePi 2G-IOT

               

Usage
1. Download WiringPi on OrangePi 2G-IOT
  1. env GIT_SSL_NO_VERIFY=true git clone https://github.com/OrangePiLibra/WiringPi.git
Copy code
2. Compile and install WiringPi
  1.       cd WiringPi
  2.       sudo ./build OrangePi_2G-IOT
  3.       sudo ./build install
Copy code
3. Utilze WiringPi   
  1.       cd WiringPi/example/OrangePi
  2.       make OrangePi
  3.       ./OrangePi
Copy code
4. Details GPIO infromation
  1.       cd  WiringPi/example/OrangePi
  2.       cat README.md
Copy code

Reality Test
  OrangePi 2G-IOT contains GPIOA, GPIOB, GPIOC and GPIOD. Each of group has 32 gpio,
  The type of GPIO is "Input", "Output" and "specify function" such as "I2C", "I2S" and so on.

  On board, OrangePi 2G-IOT exports 40 pins as different function. User can uitlize these
  GPIO on different application scenarios. For example, User can configure the type of GPIO
  as "Input", and get current voltage from program. Another hand, User can configure GPIO
  as specify function, such as "Uart", "I2C" and "SPI".


  Note! On OrangePi 2G-IOT, GPIOA, GPIOB and GPIOD tract as general GPIO, but GPIOC as non-general
  GPIO. Because of some hardware design, The host of GPIOC is modem not CPU. So, If CPU wanna control
  GPIOC, it must send message to Modem, and Moden get message and control GPIOC, it's not good news.
  So. on version 0.1, GPIOC only support "OUTPUT" mode. but we will do more try to let GPIOC work well.
  The size of GPIOx group is 32, so we can get gpio map:
  1.      GPIOA: 0   -  31
  2.      GPIOB: 32  -  63
  3.      GPIOC: 64  -  95
  4.      GPIOD: 96  -  127
Copy code
Each gpio have a unique ID, and the way of caculate as follow:
  1.      GPIO_A_x:   ID = 0   + x
  2.      GPIO_B_x:   ID = 32  + x
  3.      GPIO_C_x:   ID = 64  + x
  4.      GPIO_D_x:   ID = 96  + x
Copy code
Final, this section will introduce how to configure GPIO on OrangePi 2G-IOt.
  1. Set gpio as Input mode
      As General GPIO, we only offer the number of GPIOx. then, use library of wiringPi, User can
      easily to control GPIO. Note! GPIOC not support "Input" mode.
      
  1.        #include <wiringPi.h>

  2.        /* Defind unique ID */
  3.        #define PA1         1
  4.        #define PB5         37
  5.        #define PD2         98

  6.        int main(void)
  7.        {
  8.            unsigned int vol;

  9.            /* Setup wiringPi */
  10.            wiringPiSetup();

  11.            /* Set Input Mode */
  12.            pinMode(PA1, INPUT);
  13.            pinMode(PB5, INPUT);
  14.            pinMode(PD2, INPUT);

  15.            /* Get value from GPIO */
  16.            vol = digitalRead(PA1);
  17.            vol = digitalRead(PB5);
  18.            vol = digitalRead(PD2);

  19.            return 0;
  20.        }
Copy code

  2. Set gpio as "OUTPUT" mode
      All GPIO support "OUTPUT" mode. The demo code as follow:
      
  1.        #include <wiringPi.h>

  2.        /* Defind unique ID */
  3.        #define PA1        1
  4.        #define PB5        37
  5.        #define PC27       91
  6.        #defien PD2        98

  7.        int main(void)
  8.        {
  9.            /* Setup wiringPi */
  10.            wiringPiSetup();

  11.            /* Set GPIO Mode */
  12.            pinMode(PA1,  OUTPUT);
  13.            pinMode(PB5,  OUTPUT);
  14.            pinMode(PC27, OUTPUT);
  15.            pinMode(PD2,  OUTPUT);

  16.            digitalWrite(PA1,  HIGH);
  17.            digitalWrite(PB5,  LOW);
  18.            digitalWrite(PC27, HIGH);
  19.            digitalWrite(PD2,  LOW);

  20.            return 0;
  21.        }
Copy code














This thread contains more resources

You need to Log in to download or view,No account?    Register

x

10

threads

35

posts

305

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
305
 Author| Published in 2017-6-22 20:44:32 | Show all floors
Edited by Buddy at 2017-6-22 20:46
yoelmend replied at 2017-6-22 11:37
Hi, I'm doing the blink.c test, compile but the LED does not blink, any ideas?

#include

Hi friends:
   I have fix this problem, please update your source code of WiringPi.

   Pin 1 maping phys pin 12
   
   You can use command:
  1. gpio mode 1 out
  2. gpio write 1 1
  3. gpio write 1 0
Copy code

This thread contains more resources

You need to Log in to download or view,No account?    Register

x

10

threads

35

posts

305

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
305
 Author| Published in 2017-6-19 19:06:27 | Show all floors
@crossmax  

6

threads

70

posts

370

credits

Intermediate member

Rank: 3Rank: 3

credits
370
Published in 2017-6-19 20:09:43 from mobile | Show all floors
Thanks! I go to probe sensors.

This thread contains more resources

You need to Log in to download or view,No account?    Register

x

6

threads

70

posts

370

credits

Intermediate member

Rank: 3Rank: 3

credits
370
Published in 2017-6-19 21:51:07 | Show all floors
I wat to read a DHT22 tem/huminity sensor, i use this https://github.com/technion/lol_dht22

Compile: gcc -o dht22 dht22.c locking.c -lwiringPi -pthread

But when i use it only see this:

./dht22 56
Raspberry Pi wiringPi DHT22 reader
www.lolware.net
wiringPi: wiringPiSetup called
piboardRev: Hardware string: Hardware   : rda8810
Hardware:Hardware       : rda8810
piboardRev:  8888
piboardRev: Hardware string: Hardware   : rda8810
Hardware:Hardware       : rda8810
piboardRev:  8888
piboardId: Revision string: Revision    : 0000
PinMode: pin:56,mode:1
Register[0x20931004]: 0 index:24
PinMode: pin:56,mode:0
Register[0x20931008]: 0 index:24
Data not good, skip
PinMode: pin:56,mode:1
Register[0x20931004]: 0 index:24
PinMode: pin:56,mode:0
Register[0x20931008]: 0 index:24
Data not good, skip
...

0

threads

1

posts

8

credits

Novice

Rank: 1

credits
8
Published in 2017-6-21 18:32:31 | Show all floors
Hi
i new with this board and i trying to work with the gpio pin i copy the directory from git and when i run the build commad
"sudo ./build OrangePi_2G-IOT" i got the following error below

please advise...

thanks

root@OrangePI:/usr/WiringPi-master# sudo ./build OrangePi_2G-IOT
Build WiringPi on OrangePi
./build: 11: [: OrangePi_2G-IOT: unexpected operator
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
[Compile] wiringPi.c
In file included from wiringPi.c:80:0:
OrangePi.h:1:0: error: unterminated #ifndef
#ifndef _ORANGEPI_H
^
Makefile:131: recipe for target 'wiringPi.o' failed
make: *** [wiringPi.o] Error 1

Make Failed...
Please check the messages and fix any problems. If you're still stuck,
then please email all the output and as many details as you can to
  projects@drogon.net

root@OrangePI:/usr/WiringPi-master#

10

threads

35

posts

305

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
305
 Author| Published in 2017-6-21 20:33:39 | Show all floors
tderi replied at 2017-6-21 18:32
Hi
i new with this board and i trying to work with the gpio pin i copy the directory from git and wh ...

Hi friends:
   I have fix this problem, please update newest source code from github.

0

threads

7

posts

65

credits

Registered member

Rank: 2

credits
65
Published in 2017-6-22 11:37:31 | Show all floors
Edited by yoelmend at 2017-6-22 12:06

Hi, I'm doing the blink.c test, compile but the LED does not blink, any ideas?

#include <stdio.h>
#include <wiringPi.h>

#define PA1        1
int main (void)
{
wiringPiSetup();
pinMode(PA1,OUTPUT);
for(;;)
       {
          digitalWrite(PA1,HIGH);
          printf("High  \n");
          delay(500);
          digitalWrite(PA1,LOW) ;
          printf("Low \n");
          delay(500);
        }
     
     return 0;
}

1

threads

4

posts

33

credits

Novice

Rank: 1

credits
33
Published in 2017-6-24 21:41:26 | Show all floors
Edited by albydnc at 2017-6-24 21:43

Sorry for the dumb question, but where can I get the pinout of the 40 pin header?

0

threads

7

posts

65

credits

Registered member

Rank: 2

credits
65
Published in 2017-6-25 11:06:10 | Show all floors
root@OrangePI:~# gpio readall                       <-----enter the command

You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list