Community
cancel
Showing results for 
Search instead for 
Did you mean: 
YWang92
Novice
981 Views

How to add mraa/gpio library to the arduino

Jump to solution

Hi all,

I'm using Intel Edison and trying to run a GPIO example. First I include signal.h and mraa/gpio.h, but the error message appeared when I compiled the codes.

Arduino: 1.6.5 (Windows 8.1), Board: "Intel® Edison"

sketch_nov13b.ino:3:23: fatal error: mraa/gpio.h: No such file or directory

compilation terminated.

Error compiling.

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

Does anyone know how to solve this problem? Thank you!

Yicheng

1 Solution
Pedro_M_Intel
Employee
117 Views

Hello wych,

I'm afraid that's not the right way to use MRAA. I'll give you a brief explanation on how to use MRAA with your Edison, for this you will have to access your board's Linux terminal, here's a guide on how to do it: https://software.intel.com/en-us/get-started-edison-windows-step3 IoT - Step 3: Set up a serial terminal | Intel® Developer Zone.

1. Set up AlexT's repo. Learn how to do it in http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html Edison Package Repo Configuration Instructions.

2. Run the commands "opkg update" and "opkg install libmraa0".

3. Now, to run the simple blink code:

# include

# include

# include

# include "mraa/gpio.h"

int main(int argc, char** argv)

{

mraa_platform_t platform = mraa_get_platform_type();

mraa_gpio_context gpio, gpio_in = NULL;

char* board_name = mraa_get_platform_name();

int ledstate = 0;

gpio = mraa_gpio_init(13);

fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);

mraa_gpio_dir(gpio, MRAA_GPIO_OUT);

for (;;) {

if (gpio_in != NULL && mraa_gpio_read(gpio_in) == 0) {

return 0;

}

ledstate = !ledstate;

mraa_gpio_write(gpio, !ledstate);

sleep(1);

}

return 0;

}

Create a file with the code called blink.c and save it, then run the command "gcc blink.c -o blink.out -lmraa", this will create an executable file called blink.out, run it with "./blink.out" and you should see a blinking LED on your board.

Peter.

View solution in original post

3 Replies
Pedro_M_Intel
Employee
118 Views

Hello wych,

I'm afraid that's not the right way to use MRAA. I'll give you a brief explanation on how to use MRAA with your Edison, for this you will have to access your board's Linux terminal, here's a guide on how to do it: https://software.intel.com/en-us/get-started-edison-windows-step3 IoT - Step 3: Set up a serial terminal | Intel® Developer Zone.

1. Set up AlexT's repo. Learn how to do it in http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html Edison Package Repo Configuration Instructions.

2. Run the commands "opkg update" and "opkg install libmraa0".

3. Now, to run the simple blink code:

# include

# include

# include

# include "mraa/gpio.h"

int main(int argc, char** argv)

{

mraa_platform_t platform = mraa_get_platform_type();

mraa_gpio_context gpio, gpio_in = NULL;

char* board_name = mraa_get_platform_name();

int ledstate = 0;

gpio = mraa_gpio_init(13);

fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);

mraa_gpio_dir(gpio, MRAA_GPIO_OUT);

for (;;) {

if (gpio_in != NULL && mraa_gpio_read(gpio_in) == 0) {

return 0;

}

ledstate = !ledstate;

mraa_gpio_write(gpio, !ledstate);

sleep(1);

}

return 0;

}

Create a file with the code called blink.c and save it, then run the command "gcc blink.c -o blink.out -lmraa", this will create an executable file called blink.out, run it with "./blink.out" and you should see a blinking LED on your board.

Peter.

View solution in original post

YWang92
Novice
117 Views

Thank you Peter! I am sorry to say I am only a beginner in Linux, could you tell me more detail steps about how to replace anything I have in /etc/opkg/base-feeds.conf? Like what command should I use to get to the file /etc/opkg/base-feeds.conf and how to replace things as the instruction shows?

===/etc/opkg/base-feeds.conf contents below===

 

src/gz all http://repo.opkg.net/edison/repo/all http://repo.opkg.net/edison/repo/all

 

src/gz edison http://repo.opkg.net/edison/repo/edison http://repo.opkg.net/edison/repo/edison

 

src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32 http://repo.opkg.net/edison/repo/core2-32

===end of /etc/opkg/base-feeds.conf contents===

Thank you again!

Yicheng

Pedro_M_Intel
Employee
117 Views

Sure wych, follow these steps:

echo "src/gz all http://repo.opkg.net/edison/repo/all http://repo.opkg.net/edison/repo/all" > /etc/opkg/base-feeds.con

echo "src/gz edison http://repo.opkg.net/edison/repo/edison http://repo.opkg.net/edison/repo/edison" >> /etc/opkg/base-feeds.con

echo "src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32 http://repo.opkg.net/edison/repo/core2-32" >> /etc/opkg/base-feeds.con

opkg update

opkg install libmraa0

That should set up the AlexT's repo and download the mraa library.

Peter.

Reply