1 Reply Latest reply on May 26, 2014 6:36 PM by Carlos_Intel

    interfacing python/c/c++ programs with arduino sketches

    Tom1988

      Hi guys,

       

      I am scoping out a project with a Galileo that requires Wifi, a display (an arduino LCD screen, I2C or SPI) and a sensor (SPI or UART). I'm just thinking through in my mind how it will work and would appreciate any advice that you could offer. I'm thinking of creating an application program in Python to process the incoming data (perform some calculations etc) from the sensor. I was going to use existing arduino sketches to take the incoming sensor data via SPI and pass it to the python program. I was also going to use existing arduino sketches to display the output on the screen and send some processed data over Wifi also.

       

      I am thinking that this is practically the same as Sparkfun's unread email counter tutorial (except no sensor data).

      https://learn.sparkfun.com/tutorials/galileo-unread-email-counter/the-arduino-sketch

       

      My question is what would be the best way to interface the python application program with the arduino sketches? The sparkfun example writes the data to a file which is then read to display the content. Is this the only option? Or are there other options? There will be a lot of data coming in via the sensor and I need the application to run as quickly as possible. Would you have any other suggestions to improve the concept?

       

      Also, something else that I have no experience with, but is it possible to write a python script to take the data straight in via SPI and not use an Arduino sketch? 

       

      Also, if I wanted to write the application program in c/c++, would that be possible? Would I have to do it using the IoT dekit? Do you write the c/c++ program in the Eclipse IDE and then load it onto the board like an arduino sketch? Can Arduino sketches interact with c/c++ programs?

       

      https://www.google.com/#q=iot+developer+kit+intel

       

      Many thanks for your help, I understand that there is quite a lot of vague questions here

      Tom

        • 1. Re: interfacing python/c/c++ programs with arduino sketches
          Carlos_Intel

          Hello Tom1988!

           

          I hope to cover all the questions in order:

           

          • My question is what would be the best way to interface the python application program with the Arduino sketches?

           

               Since the function system () sets the processor to execute a Linux command, it is a good way to interface a python script with the Arduino sketch.

           

          • Would you have any other suggestions to improve the concept?

           

               If you have a serial cable you can program the Galileo using Python (without Arduino IDE at all) and run a your *.py routine. As you might know, the concept is more related to the Linux environment, board pin out, file management and Python skills programming.

           

          • is it possible to write a python script to take the data straight in via SPI and not use an Arduino sketch?

           

               I think it is possible, but you’ll need to program some more settings than the required using an Arduino sketch. For instance, in this link https://learn.sparkfun.com/tutorials/programming-the-pcduino/spi-communications you can find some code for SPI using C++ and Python for a similar board, you can use the same code and adapt it to your needs in the Galileo one.

               In this additional link, you can find information about the GPIO Mapping in Galileo Intel Galileo - Programming GPIO From Linux - Malinov Family Web Presence and how the SPI pins are confirgured.

           

          • if I wanted to write the application program in c/c++, would that be possible? Would I have to do it using the IoT dekit? Do you write the c/c++ program in the Eclipse IDE and then load it onto the board like an arduino sketch? Can Arduino sketches interact with c/c++ programs?

           

               Regarding the IoT Dev Kit, we highly recommend you to visit this link https://software.intel.com/en-us/forums/internet-of-things where you can find more resources

           

          Best Regards!