KX134 SPI Topic

Hello community,

SPI connection to Kx_134 works on arduino uno but not on arduino nano, what is wrong? I’m using same code:


#include <SPI.h>

#include “SparkFun_Qwiic_KX13X.h”

const int CS = 10;

QwiicKX134 kxAccel;

outputData myData; /

void setup() {

while(!Serial){

delay(50);

}

Serial.begin(115200);

Serial.println(“Welcome.”);

SPI.begin();

pinMode(CS, OUTPUT);

if ( !kxAccel.beginSPI(CS, 8000000, SPI) ){

Serial.println(“Could not communicate with the KX134. Freezing.”);

while(1);

}

else

Serial.println(“Ready.”);


Arduino uno: code runs ok.

Arduino nano: Freezing: could not communicat with the KX134

Arduino nano has a ATmega328P(old bootloader)

Who can help?

Reto

Hi, I didn’t try myself but looks like for Arduino Nano,the CS pin must be changed to pin#4.

http://lab.dejaworks.com/arduino-nano-s … onnection/

You can give it a try.

Hi, tried it, but will not communicate.

Which Arduino Nano are you using?

Arduino Nano 3.0 compatible - ATmega328P(old bootloader)

Bootloader shouldn’t matter, are you using the exact same pins on the Nano as the Uno?

Any chance you could post a photo showing your setup?

That should work, maybe you have a bad nano?