element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Wiring pi is defunct.
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 14 replies
  • Answers 1 answer
  • Subscribers 657 subscribers
  • Views 3708 views
  • Users 0 members are here
  • c
  • gpio
  • wiringpi
  • raspberry_pi
  • raspberry-pi
  • raspberrypi
Related

Wiring pi is defunct.

SensoredHacker0
SensoredHacker0 over 1 year ago

I used to love using the Wiring Pi library in C for programing the IO of the Raspberry pi.
I haven't used a PI for a project in a while, and I guess in that time developer of WiringPi has
stopped supporting the library.
I tried using version 2.52 on a raspberry pi 4, but it says something like the hardware isn't listed in /proc/cpuinfo.

So I guess I cant use wiringPi. what C libraries would you use for programing GPIO in C on a rasperry Pi 4?
Ive looked around the internet, and I see some various options, but Im not sure what code works with which boards, etc.

  • Sign in to reply
  • Cancel
Parents
  • shabaz
    0 shabaz over 1 year ago

    WiringPi certainly does work with Pi 4, I have used it myself on Pi 4. 

    However, it is not maintained (the author doesn't wish to maintain it anymore), so it won't work with Pi 5 at all (unless someone adapts it, which the original author I think doesn't have an interest in pursuing). There is a list of alternatives (some are for Python, but there are some listed for C) here: https://raspberrypi.stackexchange.com/questions/117591/controlling-raspberry-pi-gpio-with-c-and-python

    However, I've not tried any alternative personally on Pi 4. With C, I've only used WiringPi on Pi 4.

    I suspect some people (those that need it for, say, a job and thus have the time - several days of effort to do it properly) are directly programming registers (i.e. do a mmap, followed by writing/reading the registers that are mapped) for the particular Pi they are using, and effectively creating their own API. I've had to do that myself on some platforms (e.g. BeagleBone Black), but it's a lot of effort to initially do, and to maintain. 

    In summary, if it's only Pi 4 that interests you, and you wish to use C programming, then WiringPi should work. Otherwise, if you may eventually want Pi 5 support too, you'd need to choose a different library (e.g. pigpio, but there are various options at that link), which today may not work for Pi 5 but at least has a chance of being supported eventually, if it is actively being maintained currently, or create your own.

    If you don't need fast GPIO, then there are other options (e.g. using /sys/class/gpio) but those are slower. Not every application will need speed, so that may be a possibility. 

    Yet another possibility is to use SPI or I2C (e.g. SPI or I2C GPIO expander) and avoid the WiringPi and its alternatives altogether since you'd be using the normal Linux i2cdev or spidev API, which will always be supported (unless something better comes along one day).

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • shabaz
    0 shabaz over 1 year ago

    WiringPi certainly does work with Pi 4, I have used it myself on Pi 4. 

    However, it is not maintained (the author doesn't wish to maintain it anymore), so it won't work with Pi 5 at all (unless someone adapts it, which the original author I think doesn't have an interest in pursuing). There is a list of alternatives (some are for Python, but there are some listed for C) here: https://raspberrypi.stackexchange.com/questions/117591/controlling-raspberry-pi-gpio-with-c-and-python

    However, I've not tried any alternative personally on Pi 4. With C, I've only used WiringPi on Pi 4.

    I suspect some people (those that need it for, say, a job and thus have the time - several days of effort to do it properly) are directly programming registers (i.e. do a mmap, followed by writing/reading the registers that are mapped) for the particular Pi they are using, and effectively creating their own API. I've had to do that myself on some platforms (e.g. BeagleBone Black), but it's a lot of effort to initially do, and to maintain. 

    In summary, if it's only Pi 4 that interests you, and you wish to use C programming, then WiringPi should work. Otherwise, if you may eventually want Pi 5 support too, you'd need to choose a different library (e.g. pigpio, but there are various options at that link), which today may not work for Pi 5 but at least has a chance of being supported eventually, if it is actively being maintained currently, or create your own.

    If you don't need fast GPIO, then there are other options (e.g. using /sys/class/gpio) but those are slower. Not every application will need speed, so that may be a possibility. 

    Yet another possibility is to use SPI or I2C (e.g. SPI or I2C GPIO expander) and avoid the WiringPi and its alternatives altogether since you'd be using the normal Linux i2cdev or spidev API, which will always be supported (unless something better comes along one day).

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • SensoredHacker0
    0 SensoredHacker0 over 1 year ago in reply to shabaz

    is that a 32bit or 64 bit version of the OS?
    Im looking a pigpio, they do some weird things, with how it runs as a daemon.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • BigG
    0 BigG over 1 year ago in reply to SensoredHacker0

    I would also have suggested pigpio library as the one to use for most general needs. I did come across this link, which offers some other alternatives, e.g. sysfs, or if really up for it, using direct register access.

    elinux.org/RPi_GPIO_Code_Samples

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 1 year ago in reply to shabaz
    shabaz said:
    there are other options (e.g. using /sys/class/gpio)

    I use those, if I don't need fast IO. 

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 1 year ago in reply to Jan Cumps

    I suspect often people don't need the speed, but simply want DigitalIn/DigitalOut style API functions like a microcontroller's libraries may offer, or Arduino even, and probably they would not mind if the underlying implementation used /sys/class/gpio. 

    Even if slower IO is fine, sometimes an OCD gets the better of me and makes me want to implement it using registers, but it's a lot of work!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 1 year ago in reply to shabaz

    As an exercise, I created a little C++ GPIO lib:  C++ gpio library for Raspberry Pi - Pt 1: Design and How To Use 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • BigG
    0 BigG over 1 year ago in reply to shabaz

    Here's yet another, more generic, C programming option for Linux, which looks to be quite active in development but is not found in that list. Have yet to test performance...

    github.com/.../c-periphery

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 1 year ago in reply to BigG

    Nice find. Regarding your performance comment, I think for general I/O they have a wrapper around /sys/class/gpio, so it won't be super-fast, but most users just want a wrapper anyway, with a simple API, so it should still be fine for a lot of purposes.

    I'm currently writing a direct register access API for a different board that I need to use, it's going to be basic because I don't wish to maintain something complex. but I wish SBC manufacturers had standardized on a way to make it simple for C/C++ developers to use fast access without having to delve into tech ref manuals, e.g. some C/C++ API framework and a config file that was tailored for the processor/SBC.  I wish raspberrypi.com had taken the initiative and come up with something like a framework that any SBC supplier could use to implement GPIO with the same underlying API calls. That way, people could modify apps to suit Pi 5, 6, etc or other manufacturer boards too.

    A few things that would be useful for that would be the ability to write an API on top (such as DigitalIn/DigitalOut for those who want an Arduino-style API), plus the ability to map different identifiers. For instance, if a different SBC used completely different GPIO pins, it would be good if they could be mapped to Pi GPIO numbers (if people were porting code), or even map to physical pin numbers if desired. Lots of SBCs have a 40-way connector, but of course, the registers will be different.

    Also, as well as C++, such a library would also be linkable to C code (since some legacy stuff might not compile as C++ without a load of errors).

    All that, plus maintaining it, is quite some work for an individual, but a nice constrained, not-insurmountable uni project for a sponsored student for raspberrypi org etc.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Jan Cumps
    0 Jan Cumps over 1 year ago in reply to shabaz

    I'm checking out the memmap register access on the RPi. To test if I can plug in another implementation in the little oo lib I made. Got sidetracked by LoRaWAN things Grin

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube