8 Replies Latest reply on Apr 8, 2016 9:58 PM by Walber

    Arduino / Linux

    Walber

      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?

        • 1. Re: Arduino / Linux
          FGT

          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

          • 2. Re: Arduino / Linux
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            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

            1 of 1 people found this helpful
            • 3. Re: Arduino / Linux
              joe-iot

              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

              • 4. Re: Arduino / Linux
                FGT

                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.

                • 5. Re: Arduino / Linux
                  joe-iot

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

                   

                  Cheers,

                  -Joe

                  • 6. Re: Arduino / Linux
                    Walber

                    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

                    • 7. Re: Arduino / Linux
                      joe-iot

                      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:

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

                       

                      -Joe

                       


                      • 8. Re: Arduino / Linux
                        Walber

                        Thank you Joe, this will help a lot!