Electronic – arduino – Problem with SPI Communication between Arduino/Atmega328P and Raspberry Pi

arduinoraspberry pispi

I have an Atmega328P chip (being used as an Arduino) that I would like to connect to a Raspberry Pi via SPI.

I originally had an Atmega328P running on 3.3V using its own internal 8MHz crystal instead of an external 16MHz crystal. The Atmega was powered from the Raspberry Pi's 3.3v pin. I could directly connect MISO/MOSI/SCLK/CE0 pins between the two devices and I successfully used the Pi as SPI master and the Atmega as SPI slave.

Now I want to use an Atmega328 at 5V powered from external DC (LM317, etc) using an external 16MHz crystal. Obviously, the 5V Atmega pins can't talk to the 3.3V Pi pins so I got a Bi-Directional Logic Level Convertor (https://www.sparkfun.com/products/12009). This is my current schematic:

Schematic

My SPI code no longer works and I'm not quite sure why. Is this the correct way to hook up 5V Atmega and 3.3V Pi for SPI communication? Am I missing any connections?

UPDATE: I ended up trying out I2C communication and it worked right away, so I think I'm going to switch to that. I only needed low speed communication between the Atmega and Pi so it suits my needs. Someday I'll have to try out some of the suggestions below.

Best Answer

The problem with level converters like that is they can only go so fast. Try slowing down your SPI speed.

If you have a scope, check the levels on the signals to make sure they are high enough, especially the clock line, on both sides.