rwaldron / galileo-io

Intel Galileo & Intel Edison IO Plugin for Johnny-Five
http://johnny-five.io
MIT License
101 stars 26 forks source link

Johnny five + Intel Edison + BMP180 #47

Open teuteuguy opened 8 years ago

teuteuguy commented 8 years ago

When trying to launch a simple barometer read it fails on: RangeError: Trying to access beyond buffer length at checkOffset (buffer.js:582:11) at Buffer.readUInt8 (buffer.js:588:5) at Galileo. (/home/root/tests/barometer/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:696:24) at Timer.listOnTimeout as ontimeout

rwaldron commented 8 years ago

Thanks for the report! This error will occur when the expected I2C peripheral (in this case, the BMP180) isn't found—which could be a wiring issue or just plain not attached. I agree that this is a crummy error. Can you tell me more about your circuit? In the meantime, I will add some better output for this

teuteuguy commented 8 years ago

Hi rwalton,

unfortunately, you closed this a bit fast, cause the device IS connected via I2C to the board, and wiring is correct...

Intel Edison + Arduino Grove shield + Grove BMP180

rwaldron commented 8 years ago

Yes, I used the exact same setup. Can you install the latest version and test again?

rwaldron commented 8 years ago

unfortunately, you closed this a bit fast

Sorry, github does this automatically when i include "Fixes gh-XXX" in the commit message. I will reopen until you confirm.

teuteuguy commented 8 years ago

Nope, no success. Still getting errors:

1457926875390 Device(s) Intel Edison 1457926875405 Connected Intel Edison 1457926875429 Repl Initialized

RangeError: Trying to access beyond buffer length at checkOffset (buffer.js:582:11) at Buffer.readUInt8 (buffer.js:588:5) at Galileo. (/home/root/tests/barometer/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:696:24) at Timer.listOnTimeout as ontimeout

teuteuguy commented 8 years ago

Investigated a little further. (excuse the markdown problems)

Note 1: this fix is for galileo-io, which is depended in, by edison-io (which is the module you need, I believe) for running Johnny-five on Edison. So, I've gone into the node-modules/edison-io, updated the package.json to reflect the 0.9.3 version of galileo-io, npm installed. Rerunning, seems to "fix" the issue. (However new issue now). So regarding note1: I believe you probably have to update edison-io module to reflect the 0.9.3 change in galileo-io.

Note 2: now that note1 fixed it, I get a different issue (below is the output)


I2C: Could not read 3 Bytes from peripheral with address 0x77 I2C: Could not read 3 Bytes from peripheral with address 0x77 I2C: Could not read 2 Bytes from peripheral with address 0x77 I2C: Could not read 2 Bytes from peripheral with address 0x77 barometer

pressure : 0.2360

barometer

pressure : 0.2360

I2C: Could not read 3 Bytes from peripheral with address 0x77 I2C: Could not read 3 Bytes from peripheral with address 0x77 I2C: Could not read 2 Bytes from peripheral with address 0x77 I2C: Could not read 2 Bytes from peripheral with address 0x77


in a never ending loop.

My code:
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {

  var barometer = new five.Barometer({
    controller: 'BMP180'
  });

  barometer.on('data', function() {
    console.log("barometer");
    console.log("  pressure : ", this.pressure);
    console.log("--------------------------------------");
  });

});
rwaldron commented 8 years ago

Sorry, I did miss the dependency update in Edison-IO, that's fixed.

Note 2: now that note1 fixed it, I get a different issue (below is the output)

This error is only possible if the device being read is not actually connected to the board. There is nothing this library can do to fix that, as it's simply forwarded up from native bindings. The board itself is saying "I can't find this thing you want me to read, sorry".

Can you post a picture or two of your hardware as it's presently connected?

teuteuguy commented 8 years ago

Updated code which has the I2C working properly (cause LCD Screen displays the message): But the barometer does not.

var five = require("johnny-five"); var Edison = require("edison-io"); var board = new five.Board({ io: new Edison() });

board.on("ready", function() {

var lcd = new five.LCD({ controller: "JHD1313M1" });

lcd.useChar("heart"); lcd.cursor(0, 0).print("I :heart: Johnny-Five");

var barometer = new five.Barometer({ controller: 'BMP180' });

barometer.on('data', function() { console.log("barometer"); console.log(" pressure : ", this.pressure); console.log("--------------------------------------"); });

});

And picture: https://dl.dropboxusercontent.com/u/9822239/IMG_1611.jpeg

rwaldron commented 8 years ago

Thanks, that's helpful. Can you try this program without the sparkfun blocks attached? Just attach the edison directly to the intel arduino breakout, like this:

rwaldron commented 8 years ago

Also, can you list here which blocks you have attached? Thanks again!

teuteuguy commented 8 years ago

Hi rwaldron,

I've removed the Sparkfun blocks as requested (agree that it could have been a potential problem). My setup is same as before, Grove Shield, LCD and Barometer.

I've borrowed another Barometer sensor from friend to test (maybe the one I have is broken).

Exactly same result as before, ie. I2C Could not read 2 Bytes ...

Happy to get on gitter to discuss live with you (assuming timezone is OK).

rwaldron commented 8 years ago

@teuteuguy I apologize for not replying sooner—I tried to catch you on gitter, but I agree the time zones make that hard! I'm going to try to put together a very basic test case for you to try.

Also, I really appreciate your patience as we work through this together :)

rwaldron commented 8 years ago

I think I might have a different sensor here, can you link me to the exact sensor you're using?

rwaldron commented 8 years ago

Is this it?

rwaldron commented 8 years ago

Adding you image here:

rwaldron commented 8 years ago

Or is it this one?

rwaldron commented 8 years ago

ssh to you Edison and run this:

i2cdump -y 6 0x77

And paste the results here

teuteuguy commented 8 years ago

Hey rwaldron, No apologies needed :)

The sensor I have is the latter (ie. the one with Address is 0x77 written on it). Barometer Sensor (BMP180) v1.0

i2cdump -y 6 0x77

root@edison:~# i2cdump -y 6 0x77 No size specified (using byte-data access) 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX

I guess it's failing to connect to that sensor, given this I2C dump. This is very odd.

rwaldron commented 8 years ago

Well, we're getting somewhere right? :D

Did you try connecting the sensor to other I2C ports on the shield? (I'm guessing you did)

Another update: I've ordered this same sensor for Seeed

teuteuguy commented 8 years ago

I did try on a different port. Same result :(

rwaldron commented 8 years ago

Ok, then the best we can do is wait until my sensor arrives and then work together to figure out what's going on—thanks again for your patience :)

teuteuguy commented 8 years ago

Awesome :) Let me know if I can help. Thanks

rwaldron commented 8 years ago

Absolutely—as soon as the sensor arrives, I will let you know