Community
cancel
Showing results for 
Search instead for 
Did you mean: 
WWalb
Novice
2,474 Views

Arduino / Linux

Good evening everybody,

there's some way to use the arduino and linux in parallel in the galileo gen1 or 2, like transferring data between them both?

8 Replies
FTinetti
Honored Contributor I
56 Views

Walber wrote:

Good evening everybody,

there's some way to use the arduino and linux in parallel in the galileo gen1 or 2, like transferring data between them both?

Yes, I had a simple python process exchanging data with a sketch via the filesystem. Not very elegant, but solved a specific (and simple) problem I had at that time

HTH,

Fernando

idata
Community Manager
56 Views

Hi Walber,

 

 

Yes, you can use the Arduino and the Linux console at the same time. There are some methods you can use to transfer data between both sides, like:

 

1. You can use files in the Linux side, with this you can use system calls on the Arduino IDE and transfer data from these files. From example

 

system("ls / > /home/root/newfile")

 

With the command above, you can save the output of running ls / in the file /home/root/newfile/

 

2. You can use system calls with the Arduino IDE but instead of files you can use the UART located on pins 0 and 1. For this you will need to use the Serial1 and ttyS0

 

 

I hope you find this helpful.

 

 

Regards,

 

Charlie
idata
Community Manager
56 Views

Hey Walber - I would skip the Arduino side completely and read the data all natively using python, js, or c.

The Arduino Yun has an internal bridge for the Arduino side to speak to linux side. In my opinion it is much better than the kludge of writing files from the Arduino to the galileo side.

-Joe

FTinetti
Honored Contributor I
56 Views

joe-iot wrote:

Hey Walber - I would skip the Arduino side completely and read the data all natively using python, js, or c.

The Arduino Yun has an internal bridge for the Arduino side to speak to linux side. In my opinion it is much better than the kludge of writing files from the Arduino to the galileo side.

-Joe

I follow this guideline too, but sometimes it doesn't make sense for me. In my case, I had already working code in a sketch and, more importantly, that code involved using several libraries (and hardware through those libraries). Porting or replacing Arduino code (including libraries) would be a huge kludge for me, and more prone to error than communicating the sketch with some Linux process.

Fernando.

idata
Community Manager
56 Views

Fernando is right, sometimes reinventing the wheel is not worth the effort.

Cheers,

-Joe

WWalb
Novice
56 Views

Do you read the pins with some library? I'm not used to Galileo, actually I'm starting now and found this topic unclear...

Write and read from a file doesn't seems elegant at all. I thought was some kind of DMA between arduino and the processor

idata
Community Manager
56 Views

Hey Walber - I do just that using python. You import the mraa library, declare a pin, and read it.

To read an analog pin you do:

import mraa

pin = mraa.Aio(pinNumber)

print(pin.read())

 

To read a digital pin:

import mraa

pin = mraa.Gpio(pinNumber)

print(pin.read())

 

Here is a script set up to read the analog pins on the Galileo:

https://github.com/joemcmanus/analog GitHub - joemcmanus/analog: A python script to read analog values on the Intel Galileo

-Joe

 

WWalb
Novice
56 Views

Thank you Joe, this will help a lot!

Reply