Notifications
Clear all

Raspberry Pi pin usage???

85 Posts
4 Users
8 Likes
1,511 Views
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

I'm not a power user of Linux or Raspberry Pi's.  I've built some up for specific purposes, using web servers, media server, ftp, databases, samba, etc.  I've never even tried using the pins with a project as we do with Arduino, and other MPU's... until now.

I've read through this https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio-and-the-40-pin-header and run the blink Python example successfully.  Unfortunately, I want to use C++.  I feel like I'm missing something very fundamental.  For something that is the entire grass-roots reason for the Raspberry Pi to exist, is to work with pins.  Yet, even the example on this page uses a 3rd-party libraries (non RaspberryPi.org).  I would assume the pins are controlled by either Assembly and/or C functions within the operating system and I would have expected there to be library built-in that I could use. 

Yet, even here https://elinux.org/RPi_GPIO_Code_Samples#pigpio , these libraries under the C section are 3rd party.  I've even looked into higher level libraries (for SPI, I2C) that seem to primarily rely on WiringPi to handle the pin controls.  It used to be packaged as part of the OS, but now has been deprecated.  According to Internet, the original writer/owner won't have anything to do with it (typical Open-Source users drove him out).  Another group took up the maintenance and even they've thrown up their hands in frustration.  Now, many libraries won't work because of this turmoil.  

... so why would the Raspberry Pi organization leave such a fundamental aspect in outsider hands?  Am I just looking in the wrong place?  

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@inq It may have something to do with the Pi family being 'computers' as in MPU vs esp8266 or esp32 or PICO(W) and RP2040 being 'microcontrollers' as in MCU. The 40-pin header allows the addition of what are called HATS. I have some for UPS capability. Some others are POE (power over ethernet), air quality,  Canbus, RS485, 4G, and GPS. Some of the hats cost more than the Pi, even as much as 2x. The only library I have looked at even briefly is the gpiozero library https://gpiozero.readthedocs.io/en/latest/  but I think it is python only. If you google gpiozero you will get a lot of info and some of it is what I think you may be looking for, but keep in mind the Pi is a micro-computer not a micro-controller so may not be suited for whatever you have in mind. It can however work in harmony with an MCU. It may be that linux itself has what you are looking for.

As always, you are far ahead of most of us.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@inq Does this help https://projects.raspberrypi.org/en/projects/physical-computing/1

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@inq This may also be of interest https://blog.guruface.com/gpio-zero-library-and-rpi-gpio-library/

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@inq Maybe this helps. https://moonpreneur.com/tech-corner/microprocessor-vs-microcontroller/#:~:text=As%20Arduino%20is%20a%20microcontroller,output%20devices%20with%20the%20board.

You said

Arduino, and other MPU's

but an Arduino is an MCU, a Raspberry Pi 0, 4, 5 is an MPU.

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

@zander,

I failed to put it in the title, but I'm wanting to do it from C++ not Python.  For mainstream use, the RasPi organization seems to only cater to Python.  I guess that makes sense from the educational mantra.  Even though the library is written in C/Assembler, they don't seem to expose it to C++ apps... or at least I haven't found out how.  Any searches I do invariable end in Python on the Linux Raspberry Pi's or on Picos.  Neither is what I'm needing.

Thanks for looking though. 

VBR,

Inq 

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@inq Maybe if you looked for Linux libraries you may have more luck. IIRC, Raspbian is built on the Ubuntu Linux distro.

EDIT: Maybe Debian?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

Posted by: @zander

but an Arduino is an MCU, a Raspberry Pi 0, 4, 5 is an MPU.

I miss wrote.  I am on a Raspberry Pi 4... an SBC, with an MPU on a full blow Linux OS.  I should have said "Arduino and Micro-controllers" (no OS of substance).  I want to control the pins with C++.  

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@inq How about this https://www.ics.com/blog/gpio-programming-exploring-libgpiod-library

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inq reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

Posted by: @zander

@inq Maybe if you looked for Linux libraries you may have more luck. IIRC, Raspbian is built on the Ubuntu Linux distro.

EDIT: Maybe Debian?

This issue is about controlling the GPIO pins.  These are very specific to a certain piece of hardware (bcm2835) that is specifically on most Raspberry Pi computers.  The general Debian distribution wouldn't have that stuff built in.  Raspberry Pi had to add that in.  It would likely be at the kernel level.  I'm sure somewhere on the computer there are Python wrappers for the libraries and I should be able to copy whatever those wrappers are accessing.

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

Posted by: @zander

@inq How about this https://www.ics.com/blog/gpio-programming-exploring-libgpiod-library

That looks very promising.  Thanks Ron.

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1111
 

I think all the rpi GPIO libraries, python or C, were all written by people external to the rpi organisation. 

The original (for python) GPIO library was released on a general purpose license by the author.  The exception was that a rpi employee created the gpiozero python module, but has since left rpi, but has a hand in maintaining the library along with some others also not associated with rpi. 

rpi does of course include these libraries in its rpi os distribution.  The excellent pigpio library with C and python interfaces is likewise included as was wiringpi, a same its demised, but I think you can still download the source code and using it for your own plaything.

But for your purposes I would think pigpio would be just the ticket.  

This post was modified 3 months ago by byron

   
Inq reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6482
 

@byron @inq

I’d go where the Pi foundation is going libgpiod in the kernel. Better support, etc…

 

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1111
 

@inq @zander

The following may be of interest as it seems to have been updated this very day 

https://raspberrypi.stackexchange.com/questions/117591/controlling-raspberry-pi-gpio-with-c-and-python/117592#117592


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

Posted by: @byron

I think all the rpi GPIO libraries, python or C, were all written by people external to the rpi organisation.

From the aspect of Linux, I can understand the nature of external entities being in on it.  I guess my logic thinks... They (raspberrypi.org) had to adapt Debian to the hardware to make Raspian and that the low level to control the hardware pins would be part of their core value-added.  

I have just a Desktop install.  Didn't opt for all the recommended software.  But out of the box, the only two items in Programming menu are Geany and Thonny.  The Geany editor edits, compiles and runs C++ almost like a full-IDE.  Nothing extra needed to be installed.  Also out of the box, the Thonny loaded the GPIO example and blinked the LED.  I'm assuming the Python has some wrapper (from gpiozero import LED).  I'm also assuming that wrapper calls the c library.  Just wondering why I can't do the same (without a 3rd party library).  I found the gpiozero folder, but I'm struggling on the Python methodology of wrapping C libraries.  I don't see stuff I recognize... yet. 🤨 

I'm pulling on this and Ron's find, but it's external (3rd party).  Considering I've seen my first five libraries either deprecated or broke because of inherited deprecated libraries, it's a little frustrating to be reliant on a moving target.  It looks like even Raspberry Pi has changed the base infrastructure several times in the last couple of revisions... IOW breaking changes to the 3rd party people. 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Page 1 / 6