I trying to use a new sensor the KMX63 with a Arduino Uno board, my sensor is on a evaluation board made by kionix. For the connexion il linked as follows:
| Pin Uno | Pin evaluation board |
| A5 | 5 |
| A4 | 7 |
| 3.3 | 1 |
| GND | 8 |
Here the schematic of the evaluation board:
I found a technical note from the constructor that advice to do some steps after the power up of the sensor to insure it's well functioning I wrote a code following it:
#include <Wire.h>
#include "KMX62.h"
void setup(){
Serial.begin(9600);
Wire.begin();
Serial.println(F("Starting"));
byte error=7;
byte id=0;
byte command=0;
delay(60);
Wire.beginTransmission(KMX62_I2C_ADD_2);
Wire.write(0x7F);
Serial.println(F("Write 0x7F"));
Wire.write(0x00);
Serial.println(F("Write 0x00"));
delay(100);
error=Wire.endTransmission();
Serial.print(F("retour 1 : "));
Serial.println(error);
if( error==0 ){
Wire.beginTransmission(KMX62_I2C_ADD_2);
Wire.write(CNTL2);
Wire.write(0x00);
error=Wire.endTransmission();
if( error==0 ){
Wire.beginTransmission(KMX62_I2C_ADD_2);
Wire.write(CNTL1);
Wire.write(0x80);
error=Wire.endTransmission();
if(error==0){
delay(5);
Wire.beginTransmission(KMX62_I2C_ADD_2);
Wire.write(WHO_AM_I);
Wire.endTransmission(false);
Wire.requestFrom(KMX62_I2C_ADD_2,1);
id=Wire.read();
error=Wire.endTransmission();
if(id==0x18||id==0x2D){
Wire.beginTransmission(KMX62_I2C_ADD_2);
Wire.write(COTR);
Wire.endTransmission(false);
Wire.requestFrom(KMX62_I2C_ADD_2,1);
command=Wire.read();
error=Wire.endTransmission();
if(command==0x55){
Serial.println(F("device ok"));
}else{
Serial.println(F("Issue with the sensor step e : need to be rebooted"));
}
}else{
Serial.println(F("Issue with the sensor step d id=wrong : need to be rebooted"));
}
}else{
if(error==2||error==3){
Serial.println(F("Issue with the sensor step c : need to be rebooted"));
}
}
}else{
if(error==2||error==3){
Serial.println(F("Issue with the sensor step b : need to be rebooted"));
}
}
}
}
void loop(){
}
but i have an issue the steps , the program seem to freeze when i try to write into the register 0x7F.
I don't get any trace that i should have after the wire.endtransmission().
Here the trace i obtain :
09:56:35.477 -> Starting
09:56:35.511 -> Write 0x7F
09:56:35.511 -> Write 0x00
i have use the I2C scanner to check if the sensor appear, i had to modify the scanner to add a delay before Wire.beginTransmission and the Wire.endTransmission to avoid the scanner to be freeze too at the first address tried. After the modification i did saw the sensor at the address it was mean to be. here the trace for the I2C scanner :
Scanning...
I2C device found at address 0x0F !
done
Anyone have an idea of why i can't write anything to my sensor without making my program freeze indefinitely each time ?
PS : After the advice of chrisl i rerunned all my programs on a arduino mini pro on 3.3V / 8Mhz and got the same result.