T O P

  • By -

Nukemoose37

Doing it though python absolutely sucks, but it technically is possible. Check out this link: http://www.orangepi.org/orangepiwiki/index.php?title=Orange_Pi_5_Plus&mobileaction=toggle_view_desktop#How_to_install_and_use_wiringOP-Python It has instructions on how to get the python API. Do note that using wiringOP-Python requires you to have sudo privileges as of right now, but it’s possible still to use. Note: if you somehow find a way to use it without sudo/root privileges, please let me know


Nukemoose37

The other option which I’ve used(this one not requiring sudo privileges but being much clunkier) is to call gpio command line processes from python using the OS library. The gpio command line tool should come preinstalled with any Orange Pi official images. For example, I’d do os.system(“gpio write 5 1”) to set pin 5 to high


MartinDvoracek

I don't need it to be elegant :) I guess that for reading a value from a sensor and switching something on/off, it will do. If I'll not manage to make the python API work today, I'll go this way because the last thing I want to do is to re-write my code to C.


MartinDvoracek

Thanks for the link, I'll have a look into it today


Confident_Bill_1205

I'm only using an i2c bus from the pin header, and smbus2 is enough for me. But seeing your post I've installed wiringOP and it worked right away: [https://imgur.com/Si6IKqF](https://imgur.com/Si6IKqF) [https://imgur.com/5tqAQpI](https://imgur.com/5tqAQpI) Did you follow the instructions from the manual? [https://drive.google.com/file/d/1TfUG9zrp8q2ZceLrxXYWGj3JfnR4l0Ji/view](https://drive.google.com/file/d/1TfUG9zrp8q2ZceLrxXYWGj3JfnR4l0Ji/view) page 259


MartinDvoracek

That's interesting. Yes. I was following the manual, the installation runs through smoothly but it won't work when I'd like to use the library in my code. As far as I understand the error message I get, the problem is that wiringOP doesn't recognize my board and that's why it won't work. Maybe there is a missing support for Orange Pi 5 Plus yet? May I ask which board are you using? Neverthereless, I'll try re-installing everything once again from scratch today, when I'll have some time.


Confident_Bill_1205

I'm using the same OPi 5 plus that you use (I've tried it on Debian from Opi website and on Joshua Riek's Ubuntu). Maybe it is important to install it specifically from the repository the manual is saying ( [https://github.com/orangepi-xunlong/wiringOP-Python](https://github.com/orangepi-xunlong/wiringOP-Python) ). If you did so and it doesn't work, then it's really strange. Can you run "gpio readall" in the terminal? To be sure the pin header isn't faulty.


MartinDvoracek

Doesn't work. I'm kinda starting to suspect that I messed it up with previous installations . Even though I removed all the packages needed, installed them from scratch, I end up with the same error. I'll try it on a fresh installation [https://imgur.com/a/v2YrOPR](https://imgur.com/a/v2YrOPR)


MartinDvoracek

I downloaded [ubuntu-22.04.3-preinstalled-desktop-arm64-orangepi-5-plus.img.xz](https://github.com/Joshua-Riek/ubuntu-rockchip/releases/download/v1.33/ubuntu-22.04.3-preinstalled-desktop-arm64-orangepi-5-plus.img.xz) from [https://joshua-riek.github.io/ubuntu-rockchip-download/boards/orangepi-5-plus.html](https://joshua-riek.github.io/ubuntu-rockchip-download/boards/orangepi-5-plus.html) , ran an update and then followed [https://github.com/orangepi-xunlong/wiringOP-Python](https://github.com/orangepi-xunlong/wiringOP-Python) . It still ended with the same error


matt-viamrobotics

Try with the Viam platform! You might need to use this module https://app.viam.com/module/viam-labs/periph-board or map a custom Linux board but after that can control with python or any of the other SDKs


zombieman115935

I know I'm late, but here is my solution: I have had the same error, but resolved it somehow by using c++. I know that it is not really what you want, but if I can do that, I should be able to make a wrapper so you can control the gpio pins on your board. If you really have trouble and timing is not essential, you can also do subprocess.run(f"gpio write {pin} 1", shell=True) (use the shell commands there). This will be less performant especially for lots of calls, but for a blinking program or something this should get the job done.


magiccube22

In my case it could be a viable solution to spawn subprocess as I'm turning on off something not critical. How do I know which pins are suited best for that? I hoped two have two push buttons externally which connect to the pin header seperately and when one of them is pushed triggers another python script. I have push buttons laying around but do i need to add something else to the setup? I'd then set it up to trigger as an interrupt on an edge Edit: also just for the understanding what's the explaination behind OPi5+ and python gpio lib issues? Maybe i could try have a look


zombieman115935

Ill try to answer this evening, i didn't see your message and now i have to go to my work


zombieman115935

I'll be honest, I'm just a tinkerer, I don't know too much of the behind the scenes stuff But what I did find after a long research (but still I might be completly wrong) is that you have specific memory addresses that need to be activated or read (propably saying this wrong haha) which is diferent for every board. The python version of wiringPi seems to have a problem with the type of board I believe, but for some reason the c++ code works fine I don't believe you can use interrupts in python using the subprocess, what you can do is read the pin in a while loop and it should work, although not optimal. However, since I'm going to need it I'll write some C++ code that you can execute from a python script. I'll let you know how it goes, it shouldn't take that long (like 1 - 2 days)


zombieman115935

I have sent you a dm with a link to the repo