0

これは、加速度計 (Grove digital) を実行するための Intel のサンプル コードです。

// Load accelerometer
var adxl345 = require('jsupm_adxl345');

// Instantiate on I2C bus
var adxl = new adxl345.Adxl345(0);

setInterval(function()
{
    adxl.update(); // Update the data
    var raw = adxl.getRawValues(); // Read raw sensor data
    var force = adxl.getAcceleration(); // Read acceleration force (g)
    var rawvalues = raw.getitem(0) + " " + raw.getitem(1) + " " + raw.getitem(2);
    console.log("Raw Values: " + rawvalues);
    console.log("ForceX: " + force.getitem(0).toFixed(2) + " g");
    console.log("ForceY: " + force.getitem(1).toFixed(2) + " g");
    console.log("ForceZ: " + force.getitem(2).toFixed(2) + " g");
}, 1000);

ビルドして Edison Arduino ボードにアップロードしますが、実行すると次のエラーがスローされます。

ERROR: /home/root/.node_app_slot/main.js:10                                                                                                                                             
ERROR: var adxl = new adxl345.Adxl345(0);                                                                                                                                               
   ERROR:         ^                                                                                                                                                                     
ERROR: Error: UPM Runtime Error: Adxl345: i2c.write() control register failed                                                                                                           
    at Object.<anonymous> (/home/root/.node_app_slot/main.js:10:12)                                                                                                                     
    at Module._compile (module.js:456:26)                                                                                                                                               
    at Object.Module._extensions..js (module.js:474:10)                                                                                                                                 
    at Module.load (module.js:356:32)                                                                                                                                                   
    at Function.Module._load (module.js:312:12)                                                                                                                                         
    at Function.Module.runMain (module.js:497:10)                                                                                                                                       
    at startup (node.js:119:16)                                                                                                                                                         
    at node.js:935:3                                                                                                                                                                    

何が問題なのかについて何か考えはありますか?加速度計は I2C ポートに接続されています。別のセンサー (温度) は正常に動作しています。

4

1 に答える 1