Based on this article I tried to connect the accelerometer to my Espruino board. Wrote some lines and get an error
INTERNAL ERROR: Timeout on I2C Write Transmit Mode 2
INTERNAL ERROR: Timeout on I2C Write Transmit
at line 2 col 33
this.i2c.writeTo(id,reg | 0x80);
´´´
function GY291(i2c,sda,scl){
this.i2c = i2c;
var id = 0x53>>1;
this.i2c.setup({scl:scl,sda:sda});
}
GY291.prototype.write = function(reg,val){
this.i2c.writeTo(this.id,[reg,val]);
};
GY291.prototype.read = function(reg,count){
this.i2c.writeTo(id,reg | 0x80);
return this.i2c.readFrom(id,count);
};
GY291.prototype.turnOn = function(){
this.write(0x2d,0);
this.write(0x2d,16);
this.write(0x2d,8);
};
var a = new GY291(I2C2,B11,B10);
setInterval(function(){
var c = a.read(0x32,6);
console.log(c);
},2000);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Based on this article I tried to connect the accelerometer to my Espruino board. Wrote some lines and get an error
INTERNAL ERROR: Timeout on I2C Write Transmit Mode 2
INTERNAL ERROR: Timeout on I2C Write Transmit
at line 2 col 33
this.i2c.writeTo(id,reg | 0x80);
´´´
function GY291(i2c,sda,scl){
this.i2c = i2c;
var id = 0x53>>1;
this.i2c.setup({scl:scl,sda:sda});
}
GY291.prototype.write = function(reg,val){
this.i2c.writeTo(this.id,[reg,val]);
};
GY291.prototype.read = function(reg,count){
this.i2c.writeTo(id,reg | 0x80);
return this.i2c.readFrom(id,count);
};
GY291.prototype.turnOn = function(){
this.write(0x2d,0);
this.write(0x2d,16);
this.write(0x2d,8);
};
var a = new GY291(I2C2,B11,B10);
setInterval(function(){
var c = a.read(0x32,6);
console.log(c);
},2000);
´´´