14 Replies Latest reply on Sep 1, 2015 12:14 AM by qiki

    SPI + Edison Mini breakout board + MRAA on IoT devkit


      I been trying to use MRAA to work with SPI on the Edison mini breakout board, and I am getting some strange responses on the MISO and MOSI lines. Maybe someone went thru this and I am missing something.


      First: I am using the IoT devkit (the one where you use node) and my code is uploaded and executed with no problem. That is I don't have a problem compiling, uploading or executing my little script.

      Second: I installed and updated the MRAA library on Edison, and I can successfully run the MRA blinking example, so I can safely assume the MRAA library is updated and working.

      Third: I run a code that goes something like this:


           spi = new m.Spi(0);


           setTimeout(writeWord('Hello SPI',11),1000);

           console.log("Hello World!");

          console.log("Sending a Word size:"+size);

          var received = spi.write(x);    //write 1 byte

          if(received !== 0){

          setTimeout(console.log("Command received:"+received),200);


      The whole thing executes fine I can declare variable x = "Hello World" and pass it to spi.write and it compiles and executes.


      I have a logic analyzer and this is what the lines are doing:

      Screen Shot 2014-12-15 at 11.37.27 AM.png

      basically, MISO and MOSI lines are just flat. but the CS, and clock work fine. This makes me assume that MRAA is working but maybe those lines are blocked for some reason?  Am I missing hardware on those lines that prevent from it to executing? Any ideas on what is going on?

        • 1. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

          Hi LuigiC


          Sorry for the basic questions, it's just to discard options,

          1. Are you sure you are connecting your analyzer in the respective pins?

          2. Do you have the GND of all channels connected?

          3. Have you tried changing the mraa-mode function? Mraa-SPI functions

          4. Under Decoded Protocols (In your logic analyzer), Are you able to see if there are any change in MISO or MOSI in time? In the picture, it seems that MOSI channel maintains it's value at HIGH and MOSI as low, try sending a data package with the function write(data*, lenght) to see if in some moment this change.


          Let me know the outcome of this.




          • 2. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

            1. Yes I am connecting the analyzer according the pins described at the MRAA website, which are MISO - j18_11 and MOSI - J17_12.

            2. Yes, ground is connected. I can see the signal for SCK channel and CS channel.

            3. I tried all different mraa-mode functions and there is no difference.

            4. The Logic's SPI Analyzer seems to be working, again I can see the clock and CS working properly. For example, I can write a code that loops and writes 1 byte every second, and I can detect that CS line goes down how it is supposed to and the Clock provides timing for exactly one byte at the same time, but the MISO and MOSI lines are not doing anything.

            I feel like I am missing something, but I am following the MRAA documentation. I can create outputs with no problem, but when it comes to SPI, it seems like those two lines are not working.

            I am NOT using the Arduino board, just the mini breakout. Do I need another piece of hardware attached to those two lines? I am not much of a hardware expert but I saw in another post that the Arduino board has an ADC to make these pins analog inputs too. What happens with the SPI on the mini breakout board?

            • 3. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

              Hi LuigiC


              First there are a new mraa version according to http://iotdk.intel.com/repos/1.1/intelgalactic/ .Let's upgrade it with :

                  echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
                  opkg update
                  opkg install libmraa0

              Make sure you are using the latest Yocto Image. Edison - Software Downloads

              Some other suggestions that come to my mind are:

                   Try with pull down resistors in the CS and MISO pins.

                   What happens without setting the frequency and letting the default one and/or setting the Buffer of bytes?

                   Is the Slave device (MISO) working as it should?

                   Also, is the "x" for spi.write(x) correctly assigned? Have you tried without using the variable and put data directly inside the parenthesis?

              Please, let me know if you have any new result trying these options or if you already have tried these ones.


              There are other links related to mini breakout boards and SPI with functioning projects so we definitely are missing something to get this to work. Take a look at those:

              Hooking up Intel Edison to your breadboard ...

              AD-Matrix - interactive display system

              Support for the Adafruit 2.8" TFT display for Arduino Edison


              About the last question, could you post the thread? I think you are talking about this information but, do you want to use an ADC and receive analog inputs? Is that the reason of the question or is related to if you need an ADC to make this work?



              • 4. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                Some other suggestions.


                Is your device connected up to SPI while doing these tests? If so is it setup to handle only 1.8v?  Or do you have some form of level converters, to convert the 1.8v on MOSI to whatever voltage your device needs and likewise from the device back down to 1.8v for MISO


                what device?  Is it in Slave mode?


                Try not having anything connected except the logic analyzer and see if anything shows up on MOSI.


                Also I always wonder when I hear code is something like...


                Which pins are you actually connected up to? Photo?



                • 5. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                  Hi LuigiC ;


                  Have you had any updates in this, new results?




                  • 6. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                    -My Logic was connected directly to the pins that I mentioned before. There is no device attached to it yet.

                    -I double checked for continuity on the lines to make sure it wasn't a bad contact on the lines and the headers.

                    -I don't have pulldown resistors on any of the lines (I didn't think they were needed to sniff the lines).

                    -I plan on using a Logic Level Converter since most displays are 3.3V but I feel like I need to see some connectivity before i start scaling up.

                    -KurtE, I can't use your TFT Code because I plan on using the IoT devkit with the MRAA library and your code is used for the Arduino compiler.


                    Here is a picture of the pins I have, and another screenshot of the .



                    Thanks for the prompt replies.


                    • 7. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                      fyi, I have versions that run under mraa...  I have version that builds native or version I use with eclipse.

                      • 8. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                        Where is the MRAA version?

                        • 9. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                          I have a version of it as part of my larger Raspberry Pi project up on github (KurtE/Raspberry_Pi · GitHub)


                          I will be pushing up another project up to github in the next day or two with my Eclipse stuff (More or less same code), but set up to build in Eclipse.  Right now I am doing some cleanup of an issue where I am using SPI from two different threads, which is causing the SPI stuff to not work correctly for my little console app for launching programs and the like not to work properly... Still working on it... But if you want to take a look before then, here a zip file of some of the Eclipse workspace with it.

                          • 10. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                            Are you adding pull up resistors to the MISO and MOSI lines? or your TFT Display already has them?

                            • 11. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                              I am not currently adding PU resistors.  I would assume that it is internal to the Edison with it being Open Collector or was it Open Drain...

                              I will try to reinstall my breakout version of the TFT display on the mini breakout board.  Won't be able to do touch part of it as this breakout board does not have the STMPE chip on it so need two standard digital IO pins plus two analog pins (which Edison does not have).  Unless of course the Edison has an internal Touch Screen controller (like the chip in the Teensy 3.1 I believe does).  If it did, would need to know which IO pins...


                              If you want Touch as well, the other option includes getting the one with capacitive detection which talks through I2C...



                              • 12. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                                Sorry it took me so long to get back to this.


                                Today I finally got it hooked up again and it appears to be working again finally.  Took me several attempts to get the wiring and I tried a couple of different voltage level converters.  The one I purchased from Amazon.com (Amazon.com: Waveshare 3.3V 5V 8 Channel Logic Level Converter Convert TTL Bidirectional Mutual Convert for Arduino: Comp…) did not work very well for me.  Maybe I did something wrong, but when looking at LA running at 40mhz, it was only showing 7 pulses on the clock line for each clock, when I unplugged the converter, then showed 8... Maybe some speed issue.  So went back to Adafruit 8 channel shifter (https://www.adafruit.com/product/395)


                                Also started having better luck when I started powering the display (2.8 TFT LCD with Touchscreen Breakout Board w/MicroSD Socket [ILI9341] ID: 1770 - $29.95 : Adafruit Industries, Unique &…) using the 3.3v(J20-2) versus using V_SYS(J20-1).  Display shows the input voltage can be 3.3-5v so that is fine.  Currently I have defined:

                                #define MINI_BREAKOUT

                                #ifdef MINI_BREAKOUT

                                #define TFT_DC 46

                                #define TFT_CS 45

                                #define TFT_RST 47


                                I added the graphicTest program to my Edison_Eclipse project (which is my Eclipse workspace) which I pushed up to github (KurtE).


                                Also found a bug I introduced to MRAA where it would fault if you close a gpio object on the mini board.  I fixed it and put in a pull request which has been pulled into the main mraa project.


                                Let me know if you need any additional information.



                                • 13. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                                  Hi LuigiC


                                  Were you able to use SPI successfully?




                                  • 14. Re: SPI + Edison Mini breakout board + MRAA on IoT devkit

                                    actually I got the same thing when testing MPU6500 sensor ( I created my own board for Edison module ), whatever what I sent, always received a bunch of zero.


                                    // enable SPI







                                      // initialize SPI

                                      mraa_spi_context spi = mraa_spi_init_raw(5, 1); // /dev/spidev5.1

                                      if ( spi == NULL )


                                      syslog(LOG_ERR, "could not initialize spi");

                                      return -1;



                                      // setting CS manually that will cause MPU run at MODE3

                                      mraa_spi_mode(spi, MRAA_SPI_MODE3);

                                      uint8_t *rxbuf = NULL;

                                      uint8_t id_buf[2] = {0xD0, 0};

                                      uint8_t id_rx_buf[2] = {0, 1};

                                      gpio_write(110, 0);     //lower cs

                                      mraa_spi_transfer_buf( spi, id_buf, id_rx_buf, 2 );

                                      gpio_write(110, 1);

                                      printf( "\rMPU id is:%i", id_rx_buf[1]);