0

Question about connect arduino primo to BMI160 using SPI..

ttn115 gravatar image

asked 2017-12-07 12:43:54 +0100

updated 2017-12-07 12:46:02 +0100

Hi l trying to hookup arduino primo and BMI160,but recently my develop is in a strange situation,that i sent 0x00 and others register but alway return 0xff, here shows the pin connection and my test code, any suggestion would be thankful..

image description

.#include "SPI.h"

void setup() {
  Serial.begin(9600);
  pinMode (SS, OUTPUT);
  digitalWrite(SS, LOW);
  delay(10);  
  digitalWrite(SS, HIGH);
  SPI.begin();


}

void loop() {
  byte returnValue=0;
  digitalWrite(SS, LOW);
  returnValue=SPI.transfer(0x7F);
  digitalWrite(SS,HIGH);
  Serial.println(returnValue);    
  digitalWrite(SS, LOW);
  returnValue=SPI.transfer(0x00);
  digitalWrite(SS,HIGH);
  Serial.println(returnValue);
  delay(1000);

}
edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
0
Bjørn Kvaale gravatar image

answered 2017-12-12 14:06:37 +0100

updated 2017-12-12 14:09:27 +0100

Hi TTN, I am pretty sure you have connected the wires correctly (see this link here, see Section Wiring, SPI Mode). I'm guessing you have already taken a look at the Arduino SPI library, but it might be a good idea to double check (see this link). On the bottom of that page, two different examples with code are given for a barometric pressure sensor & digital potentiometer control.

Comparing your code to the barometric pressure sensor, I can see there are a few differences. Let me test your code & the example code on my Primo first. I will get back to you soon.

edit flag offensive delete publish link more

Comments

thanks for your reply. I try to do some example to make sure my realization on SPI is correct.

TTN ( 2017-12-13 08:10:26 +0100 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools

1 follower

Stats

Asked: 2017-12-07 12:43:54 +0100

Seen: 34 times

Last updated: des. 12