1

I recently prototyped and programmed a system that used some SPI sensors on an Arduino Uno. I wanted to get the size down a bit, so I was thinking I might buy an Arduino Nano and re-wire my system around that. The problem is that I have seen mention of SPI not working on the Nano. From the Nano product page:

These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

Yet I have also seen mention of SPI working on this board, or at least people saying that it should. Someone asked a similar question on Stack Overflow and was told that it should work with the same level of support as I2C, even if it isn't built in to the core framework. But that answer does not definitively answer the question of whether SPI does work, and it doesn't explain any caveats that one may come across. In this question, the OP's premise is that their SPI device works on the Nano but not on other boards; this seems to be a strong indication that SPI does work.

I figured it would be worth it to buy a Nano 3 and see if it worked. SPI devices did not work on that board, including the same radio module mentioned in the question linked to above. So, I am inclined to believe the Arduino product page when they say it isn't supported. But that still isn't satisfactory, and it is the opposite conclusion from that of the other questions: The hardware is all there and the software framework is in place, so what does one need to do to make SPI work on the Arduino Nano? Why is it that some sources say it works while others say it doesn't?

  • 2
    Don't always trust the arduino website. It's very outdated and often incorrect. You could try compiling some example code that uses SPI. If it compiles, the statement from the arduino site would be incorrect. – Gerben Apr 20 '16 at 9:23
  • You can always connect your logic analyser or oscilloscope to the SPI pins and actually look at what is happening on the pins... You do have the basic test tools you need to do electronics, don't you? hackingmajenkoblog.wordpress.com/2016/03/23/… – Majenko Apr 20 '16 at 11:18
  • @Gerben Although I did not try to run one of their samples, I did run my own code (the same code that works on the Uno) and double-checked the wiring. While the compile and build were fine, the SPI device did not respond with any data, nor could I see any other sign that it was working. – Wasabi Fan Apr 20 '16 at 13:40
  • I thought this was a purely theoretical question. Showing your wiring and your code would be helpful. – Gerben Apr 20 '16 at 17:23
  • @Gerben I am asking it theoretically, having been prompted (as mentioned) by seeing a certain behavior in reality. I would like to keep this question away from my specific test and focus on the theoretical situation: Does the Nano support SPI, and is there anything that must be done differently on the Nano to use it? If the answer is that it does support SPI out-of-the-box, I will then investigate on my own why I was unable to get it to work. – Wasabi Fan Apr 20 '16 at 19:02
2

Yes, the Nano supports SPI when used with a modern Arduino version, and no, you do not have to do anything special to utilize it on this board.

The information you found that seems to suggest something to the contrary is simply a result of the fact that that the web page for the Nano is sadly out of date date and does not reflect the current state of the Arduino libraries which support SPI on this processor and hence board.

In terms of components, the Nano it is very nearly just a form-factor shrink of the discontinued Duemilanove, and in the current version updated to an an ATmega328p it has capabilities essentially comparable to an Uno, differing primarily the in the USB interface which has nothing to do with SPI.

In terms of what is wrong with the web page, if we examine archive.org's records for the page of the comparable Duemilanvoe, on September 15th, 2010 it said:

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

But a few days later on September 26th, 2010 it had been changed to say:

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.

Although the page for that once-flagship product was updated to reflect SPI support nearly six years ago, they've not yet made a corresponding correction to the Nano page. But as the difference is in the software and the same software is used in either case, the addition of SPI support to the Duemilanove was also automatically an addition of that support to the Nano.

0

In this Nano schematic, I see MOSI, MISO & SCLK on pins J1-14, J1-15 & J2-15.

On this page I see a SPI library.

The Nano is not specifically listed in the latter link. However the Nano and other Arduino boards are similar.

  • The Nano is just a smaller version of the Leonardo. – Gerben Apr 20 '16 at 17:21
  • Sorry. I was thinking of the Arduino MICRO. – Gerben May 20 '16 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.