Community
cancel
Showing results for 
Search instead for 
Did you mean: 
VS121
Innovator
994 Views

Intel Edison node.js sample code not working with grove 3-axis digital I2C accelerometer

Jump to solution

This is the sample code from Intel for running an accelerometer (Grove digital):

// 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);

 

It builds and uploads to the Edison Arduino board, but when running it throws this error:

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. (/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

Any thoughts as to what's wrong there? The accelerometer is connected to an I2C port. Another sensor (temperature) is working ok.

1 Solution
VS121
Innovator
95 Views

Problem solved! Indeed, it turns out there is another module for use with this accelerometer - it's MMA7660 so the upm package should be the mma one. I had a feeling that this must be the issue and Tudor confirmed it. I tried it and it worked!

Now do any good people on here have any thoughts of how to log the movement data on to a cloud and apply some analysis to it? trying to build an activity monitor... cheers!

View solution in original post

3 Replies
Pedro_M_Intel
Employee
95 Views

Hello VladWill,

I tried to run the same code but I'm seeing the same behavior as you. In this case I believe the best option is that you contact the creator of this script, you can find his contact information in https://github.com/intel-iot-devkit/upm/blob/master/examples/javascript/adxl345.js upm/adxl345.js at master · intel-iot-devkit/upm · GitHub, maybe he'd be able to provide you a more accurate answer.

Peter.

VS121
Innovator
95 Views

Hi Peter

Thanks for looking into this as well. I actually did send him an email before posting here, but not heard anything back yet. If he has moved on from Intel, would there be no one else who looks after the sensors and could correct the code?? Maybe the adxl345 module is not even suitable for the grove digital accelerometer as it's a different maker...

VS121
Innovator
96 Views

Problem solved! Indeed, it turns out there is another module for use with this accelerometer - it's MMA7660 so the upm package should be the mma one. I had a feeling that this must be the issue and Tudor confirmed it. I tried it and it worked!

Now do any good people on here have any thoughts of how to log the movement data on to a cloud and apply some analysis to it? trying to build an activity monitor... cheers!

View solution in original post

Reply