SPI between two RPi's
I connected with 3(MOSI,MISO,CLK)wires between two RPi for SPI. Is a CS needed in between two RPi. In one RPi i connected MOSI to MISO to measure maximum speed and i able to achieve nearly 3MB/s when i measure between two RPi(MOSI-MOSI,MISO-MISO) i got only 6KB/s. I'm transmitting equal no. of bytes at same time. why it slows down?
Re: SPI between two RPi's
SPI and I2C both require a master device and one or more slave devices. In certain setups, multiple master devices can be possible.
As far as I know, the Pi can only act as a master, so a direct connection between two Pis isn't possible, not with SPI anyway.
MOSI is always an output, MISO is always an input. So if you connect MOSI to MOSI of two Pis, the outputs work against each other and can be damaged!
To transfer data, you can use a multi-master-setup (more common with I2C) using an external memory chip, or just use the UART. Bit-banging an SPI slave would be possible, but slow.
As far as I know, the Pi can only act as a master, so a direct connection between two Pis isn't possible, not with SPI anyway.
MOSI is always an output, MISO is always an input. So if you connect MOSI to MOSI of two Pis, the outputs work against each other and can be damaged!
To transfer data, you can use a multi-master-setup (more common with I2C) using an external memory chip, or just use the UART. Bit-banging an SPI slave would be possible, but slow.
Re: SPI between two RPi's
As both are masters can i connect MOSI(RPi1)-MISO(RPi2) n MOSI(RPi2)-MISO(RPi1) ?
- gordon@drogon.net
- Posts: 2023
- Joined: Tue Feb 07, 2012 2:14 pm
- Location: Devon, UK
- Contact: Website Twitter
Re: SPI between two RPi's
No. As both will driver their clocks, and read data is synchronised on the clock of the master, so if you don't connect the clocks the recieving one will be out of sync.venksntu wrote:As both are masters can i connect MOSI(RPi1)-MISO(RPi2) n MOSI(RPi2)-MISO(RPi1) ?
If you want to pass data at high speed between 2 Pi's I'd suggest using Ethernet. (or serial for slower speeds)
-Gordon
--
Gordons projects: https://projects.drogon.net/
Gordons projects: https://projects.drogon.net/
Re: SPI between two RPi's
You can do that without danger of damaging anything - and without the possibility to transmit datavenksntu wrote:As both are masters can i connect MOSI(RPi1)-MISO(RPi2) n MOSI(RPi2)-MISO(RPi1) ?

The master is the one who generates the clock signal, and a slave inputs and outputs data at the edges of this clock signal.
Two connected masters will both generate a clock signal and not listen to the other master's clock. So no sync, so no data.
Re: SPI between two RPi's
"Slower speeds" are up to 1 megabit. The uart itself can easily do 4MBit and more, but the CPU will struggle to even store the data on a ramdisk in time. If you're employing hardware handshake (rts/cts), you may transmit 4MBit via uart without a problem.gordon@drogon.net wrote: (or serial for slower speeds)
Re: SPI between two RPi's
i did tat pairing and im able to receive @101KB/s(maximum).karlkiste wrote:So no sync, so no data.
UART in the sense? configuring TX,RX pins or USB to USB(ttyusb0)
Re: SPI between two RPi's
Did you check the data? It may well be that you did receive something, and if you've been transmitting /dev/zero you might even "see" "correct" data. Transfer real data, and check for integrity.venksntu wrote:i did tat pairing and im able to receive @101KB/s(maximum).karlkiste wrote:So no sync, so no data.
The SPI master cannot know if there's a slave sending "0000000", or if there's no slave present. The master will receive, even if noone's sending.
The USB port is a USB-Host. Same problem like with SPI: You can't simply connect a Host to another Host. There are "USB-Null-modem-cables" which can directly connect two hosts, but they usually require drivers to setup something like a network.UART in the sense? configuring TX,RX pins or USB to USB(ttyusb0)
The easy ways to connect two pis together are:
- Network (if using model B)
- UART (connect RX(pi1) to TX(pi2) and vice versa)
Re: SPI between two RPi's
overall i'm receiving 2.21MB/s, real data 132KB/s and only junk data 2.01MB/s.
when i displayed the receive bytes, i found the bytes being bounce back which i sent to another RPI. why is it so?
when i displayed the receive bytes, i found the bytes being bounce back which i sent to another RPI. why is it so?
-
- Posts: 19
- Joined: Wed Jun 24, 2015 7:34 am
Re: SPI between two RPi's
Hi Venk,
Did u already find a solution for SPI communication between two PIs?
BR, Krish
Did u already find a solution for SPI communication between two PIs?
BR, Krish
- DougieLawson
- Posts: 40579
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: SPI between two RPi's
Don't hold your breath waiting for an answer. The last respondent on this thread hasn't visited the forum since "Thu 13 Jun 2013, 00:24".
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.