Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
123Next
Return to list New
View: 15732|Reply: 26

WiringPi on OrangePi 2G-IOT[Beta]

[Copy link]

10

Threads

35

Posts

305

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
305
Post time 2017-6-19 19:04:39 | Show all posts |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 the Code
2. Compile and install WiringPi
  1.       cd WiringPi
  2.       sudo ./build OrangePi_2G-IOT
  3.       sudo ./build install
Copy the Code
3. Utilze WiringPi   
  1.       cd WiringPi/example/OrangePi
  2.       make OrangePi
  3.       ./OrangePi
Copy the Code
4. Details GPIO infromation
  1.       cd  WiringPi/example/OrangePi
  2.       cat README.md
Copy the 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 the 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 the 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 the 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 the Code














This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

10

Threads

35

Posts

305

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
305
 Author| Post time 2017-6-22 20:44:32 | Show all posts
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 the Code

This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

10

Threads

35

Posts

305

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
305
 Author| Post time 2017-6-19 19:06:27 | Show all posts
@crossmax  

6

Threads

70

Posts

370

Credits

Intermediate member

Rank: 3Rank: 3

Credits
370
Post time 2017-6-19 20:09:43 From the mobile phone | Show all posts
Thanks! I go to probe sensors.

This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

6

Threads

70

Posts

370

Credits

Intermediate member

Rank: 3Rank: 3

Credits
370
Post time 2017-6-19 21:51:07 | Show all posts
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
Post time 2017-6-21 18:32:31 | Show all posts
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| Post time 2017-6-21 20:33:39 | Show all posts
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
Post time 2017-6-22 11:37:31 | Show all posts
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
Post time 2017-6-24 21:41:26 | Show all posts
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
Post time 2017-6-25 11:06:10 | Show all posts
root@OrangePI:~# gpio readall                       <-----enter the command

You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2020-5-26 07:50 GMT+8 , Processed in 0.038327 second(s), 24 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list