How can I use mraa?

please try this :

gpio16 = mraa.Gpio(16, owner=True, raw=True)

Thanks for the reply! !

That was the first thing I tried!

It’s no good.

How do you test the input?

I checked by directly contacting the GPIO No. 16 terminal with 3.3V using tweezers.

import mraa
import time

pin = 3 # set pin num

gpio = mraa.Gpio(pin)
gpio.dir(mraa.DIR_IN) # set mode as input

while True:
    value =  # read from pin 3
    print("value: {}".format(value))

except KeyboardInterrupt:

please try this example which I have tested

Thanks for testing! !
But when I try it, this error occurs.
Maybe the mraa installed on my Rock4SE is not good?


Traceback (most recent call last):
File “/home/radxa/Documents/”, line 7, in
gpio = mraa.Gpio(pin)
File “/usr/local/lib/python3.9/dist-packages/”, line 479, in init
_mraa.Gpio_swiginit(self, _mraa.new_Gpio(pin, owner, raw))
ValueError: Invalid GPIO pin specified

I’ve uploaded it just in case.
I think mraa is working as shown in this image.

really sorry! ! !


The program you tested worked when I ran it as super user.

sudo pyhton
*XXXX is the Python program name

It is like this.

When value: 1, the corresponding pin is set to high level of 3.3V.

This program also worked when I started it as super user! !

Nasca, thank you so much for your response! !

Just one thing.

Perhaps this pull-up setting is not working, right?
Looking at the mraa source code, it doesn’t seem to be working.
(Intel’s edison seems to support programmatic pull-ups, but no other boards seem to support it.)
Does this mean that the only solution to this problem is to wire a pull-up resistor?

@Nasca please help to answer this quesiton

@WATANABE i am newbie to rock4se project board. i am operating debian 11 bullseye on it.
i am unable to install mraa for debian. however i have installed mraa python 3 binding, can you please guide me how can i install mraa for debian.
i am also trying to read gpio pins using mraa.

Hello! !

I’m also a newbie, so I can’t say much, but I installed it as follows.

  1. RockPi’s official libmraa cannot be downloaded, and the explanation Wiki is currently unavailable.

  2. However, I would like to use a library to use GPIO.

  3. There are not many GPIO libraries like RaspPi.

  4. RockPi has no choice but to use mraa.

  5. By the way, the mraa library itself is a general-purpose library and is compatible with RockPi, as announced on the official website.

  6. Therefore, we have determined that the RaspPi method is also valid for installation.

  7. Although it is a Japanese site, there was a site with instructions on how to install it, so I installed it using that as a reference.

  8. Currently, I have installed this method and there are no problems.

sudo apt update
sudo apt install git build-essential swig python3-dev cmake libjson-c-dev
git clone
cd mraa
mkdir build
cd build
sudo make install
sudo ldconfig

Reference: Eclipse MRAA on Raspberry Pi 4 - Python

Just wondering, are you tied to Debian or could you use Armbian?
If you can go Armbian, the answer and results are different (as in easier).

thanks, mraa installation was successfull, but there were some issues when reading input voltages at gpio pins. i will share details later

yes i can shift to armbian also. currently i am working on another project for few days. I will update on this later.

Your instructions allowed me to install mraa successfully.

I am extremely grateful!


PS: There is one too many dots at the end of the “cmake” line.

1 Like