Ruuvitag with external I2C sensor

Posted 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 ?

    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());
    }
    
  • It looks like D28 and D29 are already used for SPI for the onboard sensors: http://www.espruino.com/modules/Ruuvitag¬≠.js

    So setting them to I2C is likely to mess things up. Are there any other pins you think you could get to?

  • Oh i did not think to check that. I just assumed the external pads were free. Easy to swap over.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Ruuvitag with external I2C sensor

Posted by Avatar for jonreid @jonreid

Actions