This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI communication between nRF51422 and Arduino

I want to set up an SPI communication between nRF51422 SOC (integrated on nRF51 DK) and Arduino board. I know that it is possible since I've read it in various posts and nRF51 reference manual. But, I couldn't find a working example for it (SPI) in the nRF51 SDK, as is given for UART communication.

I have read the SPI master loopback example and the SPI slave example, provided with the SDK, but I couldn't comprehend whether they could be used for TX or RX from nRF51's side. If they can be, then how?

For the SPI TX/RX from the Arduino's side, I've read the Arduino SPI Library and trying to implement it, in a similar manner as this (www.arduino.cc/en/Tutorial/SPITransaction). Does it look fine? If not, then what should be used instead?

  • Hi. Can you please elaborate a bit on what you want to achieve specifically? As you know we have a SPI master and slave driver and a couple of master/slave examples. And I'm afraid that that is pretty much it. But (dependent on what you want to do) it shouldn't be too hard to get started and communicate with other devices using SPI.

  • Hi Martin. Specifically, I am using Arduino to collect some data from a device. I want to transmit this data to nRF51422, using SPI communication. How should I achieve that?

  • It is certainly possible, but you will need to determine who is the "mastermind" in your system. Is the nRF51 pulling data from the Arduino or vise versa, i.e. which is the master and which is the slave? We have both master and slave drivers in our SDKs and there is some documentation of the functionality here: master & slave (it is somewhat complicated i know). How these drivers and the nRF51 will interact with your Arduino is highly dependent on your particular application.

    Are you communicating with a regular Arduino controller or are you using a shield with specific sensors on it? Specific sensors usually have a datasheet describing the communication protocol. If you are just communicating with a regular Arduino I guess you will have to come up with a protocol yourself (or get inspiration from the google).

  • You can take a look at the SPI example where the nRF51 is the SPI slave and the Arduino is the SPI master. This is a 5 wire SPI interface (MISO, MOSI, SCK, REQN and RDYN) The code for this is part of the https://github.com/NordicSemiconductor/nRF51-ble-bcast-mesh

    The Arduino SPI master code is available in "application_controller/serial_interface" folder. The readme for this folder has additional documentation links.

    The nRF51 SPI slave code is present in the "rbc_mesh/src/serial_handler.c" , this should provide you with a working example.

  • Thanks David for the link. It is pretty much what I was expecting. Follow-up: The example that you provided above would help me setting up a mesh-connection using "Bluetooth". I want to connect 8 to 12 devices in my network. Is it possible to achieve so using the Bluetooth SoftDevice? Also, does that example provide peer-to-peer support among all the nodes, or would I have to set up a "master" to control the entire mesh-connection? If it is not possible to connect 8 to 12 devices using "Bluetooth", can that example be used (with some modifications) to set up the mesh-connection using "ANT+"? If so, kindly explain the modifications to be done to the above example, as I'm a newbie. I've read that ANT can support upto 8 connection channels simultaneously, where each channel can support upto 65533 nodes. So, it would be possible to add more devices to my network in the future, using ANT.

Related