I have attached a SI7055 temperature sensor to a Ruuvitag as I need 2x temperature sensors for an application. My simple test app is below . If I call readBmpTemp() I get a correct temperature. If I then call read7055Temp() - the first time I get an I2C arbitration error and then the second call works. If I switch back to readBmpTemp() the first reading is incorrect etc
Is there something I have setup wrong ?
var i2c;
var Ruuvitag;
function onInit() {
Ruuvitag = require("Ruuvitag");
Ruuvitag.setEnvOn(true);
i2c = new I2C();
i2c.setup({ scl : D28, sda: D29 });
}
function read7055Temp() {
i2c.writeTo(0x40, [0xf3,0x40,0x40,0x40]);
setTimeout(function() {
var rawTemp = i2c.readFrom(0x40, 2);
var val = (rawTemp[0] << 8) + rawTemp[1];
var temp = (175.72*val) / 65536 - 46.85;
console.log(temp);
}, 10);
}
function readBmpTemp() {
console.log(Ruuvitag.getEnvData());
}
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.
I have attached a SI7055 temperature sensor to a Ruuvitag as I need 2x temperature sensors for an application. My simple test app is below . If I call readBmpTemp() I get a correct temperature. If I then call read7055Temp() - the first time I get an I2C arbitration error and then the second call works. If I switch back to readBmpTemp() the first reading is incorrect etc
Is there something I have setup wrong ?