Git Product home page Git Product logo

Comments (28)

edgarsilva avatar edgarsilva commented on August 26, 2024

I'm checking this now.

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

It seems nothing is being read from the i2c port on the arduino, either you have it incorrectly wired to the arduino, or it is not returning anything, damaged?...

I'll post a small fix to prevent this error from showing but when the read data from the arduino does not exist, give it another try after that, see if maybe the arduino is taking longer than expected to initialize the i2c device.

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

Thank you for your attention !
I have arduino duemilanove, A4 (SDA) A5 (SCL) this is the wiring, this correct?

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

That is correct, do you have any other way to check if the sensor is working correctly, it seems the firmata library is not being able to read anything back from the arduino, let me give the code another read, also could you pls paste here the code you are trying to run.

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

I've added some error handling to this branch, give that branch a try see what we get.

https://github.com/hybridgroup/cylon-i2c/tree/fix-hmc6352

You can give it a try see if the error sends anything useful, you can use something like this for testing:

var Cylon = require('cylon');

Cylon.robot({
  connection: { name: 'uno', adaptor: 'firmata', port: '/dev/ttyACM0' },
  device: { name: 'mpu6050', driver: 'mpu6050' },

  work: function(my) {
    every((1).seconds(), function() {
      my.mpu6050.getMotionAndTemp(function(err, data) {
        if (err) {
          Cylon.Logger.error('Err ===>', err);
        } else {
          Cylon.Logger.info('Data ===>', data);
        }
      });

    });
  }
}).start();

Also share your code so we can check if you have any other type of error.

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

@MarceloTomaz Just noticed you mentioned tyou have an arduino duemilanove, have you tried other examples like the blink LED or the servo one? some arduino boards have issues with the firmata protocol try this:

  1. Upload the firmata protocol to the arduino using our gort.io CLI tool.
  2. Try the Blink LED example.
  3. Make sure you have the correct serial port on the example, you can check it out in the arduino IDE.
var Cylon = require('cylon');

Cylon.robot({
   connection: { name: 'arduino', adaptor: 'firmata', port: 'COM0' },
   device: {name: 'led', driver: 'led', pin: 13},

   work: function(my) {
     every((1).second(), function() {
        my.led.toggle();
     });
   }
}).start();

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

CONSIDERATIONS

  • I am using the example provided in the test site --- http://cylonjs.com/documentation/drivers/mpu6050/
  • Using the Arduino Firmata example - StandardFirmata
  • Serial port OK
  • Example Blink OK
  • When using the GORT to send Firmata get error: OS not yet supported.
  • My OS WINDOWS 7 64
  • Tests with Arduino and Arduino Pro Mini duemilanove

doubts -

  • What is the value of resistor to pull up?
  • The test in duemilanove and Pro mini connection is used with MPU6050:
    Dc: 3.3v-5v
    GND: Ground
    SCL: A5
    SDA: A4
    AD0: Ground
    INT: Digital 2
       It would take some other connection?
  • Which version of Firmata to climb on arduino?

Thank you again!

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

@MarceloTomaz

I do not have the sensor so it is difficult for me to test this, You do not need the pull-up resistors, at least on the Arduino UNO, it already has them internally, not sure about the duemilanove, you could investigate.

Standard firmata from the Arduino IDE examples should do the job, if the blink example I provided above works then firmata is good to go and the problem is likely with the sensor connections.

Just for the sake of it, could you please paste here the exact example you are trying to run.

As far as I know you only need 4 wires from the sensor to the arduino:

VCC -> 3.3V
GND -> GND
SCL -> A5
SDA -> A4

The int pin serves to tell the arduino when data is available to be read, or the buffer is ready, but only when the sensor is in buffer mode, should not be the case so you can probably not connect this.

Same thing with AD0 this serves the purpose of selecting a different address, try leaving it free, not connected. The driver tries to read from the default address, so this might be causing the sensor to setup in a different address, which makes cylon not able to find it in the I2C bus.

My suggestion first of all disconnect AD0 and run the example, if still does not work connect it to Grd and run, if does not work connect to 3.3v and run again check if that fixes it.

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

@edgarsilva, would you like to test, how to send a simple message to the arduino?
I tested the codes that suggested above and below the test code I've been running.


var Cylon = require('cylon');

Cylon.robot({
connection: { name: 'arduino', adaptor: 'firmata', port: 'COM3' },
device: { name: 'mpu6050', driver: 'mpu6050' },

work: function(my) {
every((1).seconds(), function() {
my.mpu6050.getMotionAndTemp(function(data) {
Logger.info(data);
});

});

}
}).start();


TNKS !

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

There is a mistake in that code, cylon no longer registers a Logger, but it seems you are not getting to that point yet, the code should look like this:

var Cylon = require('cylon');

Cylon.robot({
  connection: { name: 'arduino', adaptor: 'firmata', port: 'COM3' },
  device: { name: 'mpu6050', driver: 'mpu6050' },

  work: function(my) {
    every((1).seconds(), function() {
      my.mpu6050.getMotionAndTemp(function(data) {
        Cylon.Logger.info(data); // This should be referenced through cylon
      });
    });
  }
}).start();
  1. Did you do any changes to the sensor wires and setup?
  2. Did you try the branch I provided yesterday? Give it a try with the example code I provided above, just update the serialport for the correct one.

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

@MarceloTomaz Hey any progress here? Anything else I can help you with?

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

Hello, I did some testing, but no success.
I decided to use the SERIALPORT library for reading data from the arduino, I uploaded the example MPU6050_DMP6 for arduino and so could receive using NodeJS, thus ruling out a hardware failure.
My experience with NodeJS is minimal, so I think I will install the entire environment for Cylon.js on a computer with linux, talvem think something may be blocking the windows.
I have a new doubt, what would extrutura folders within "node_module"? believe #npm may be importing the wrong way.

Thank you!

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

In your project, where your code javascript code that will run on node.js resides, every time you install a npm module is installed inside the node_modules folder.

So if you install cylon you should have ./node_modules/cylon and cylon will have another node_modules folder inside with its dependencies.

so if you install everything you need to run cylon on the arduino you should have:

./node_modules
  cylon/
  cylon-firmata/
  cylon-gpio/
  cylon-i2c

and also any other dependency you might be using on your code.

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

My question about that is inside the module cylon-Firmata, it repeats root dependence as the extrutura?
Attached image for my directory structure.
cylonfirmata

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

I did test with servo motor and also got error, but did not save log

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

@MarceloTomaz The stricture is find as you have it, cylon-firmata does have a dependency for cylon, and the way npm works it has to be included in the dependency tree like that, it does not get it from the root of the project.

if you have issues with other hardware there's probably some other issue with arduino duemilanove and firmata, and not with your sensor, do you have any other arduino or microcontroler? Raspberry Pi? Beaglebone black? arduino Uno?

I don't have a duemilanove, but I know firmata has issues with the mega and I think also with the leonardo, I'll test my arduino Uno with a servo and another i2c device just to make sure there is no other bug with the libraries. but it sounds like it might be a problem with firmata and duemilanove.

from cylon-i2c.

deadprogram avatar deadprogram commented on August 26, 2024

I think this issue was addressed by the most recent release of cylon-i2c. Can you please give this a try?

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

Ok deadprogram, I will test and return the results.

from cylon-i2c.

deadprogram avatar deadprogram commented on August 26, 2024

I also have an MPU6050, so I can solder it up and check it out. Do note that this is a 3.3v device, you might need a level shifter.

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

Hello!
I did the test, but with no success MPU6050.
The example blink this works, below the return.

|======================================================================|
C:\Users\marcelo.tomaz\Documents\NODEJS\cylon>node cylon_test.js
I, [2014-10-04T15:45:07.310Z] INFO -- : Initializing connections.
I, [2014-10-04T15:45:07.312Z] INFO -- : Initializing connection 'arduino'.
D, [2014-10-04T15:45:07.313Z] DEBUG -- : Loading adaptor 'firmata'.
D, [2014-10-04T15:45:07.412Z] DEBUG -- : Registering Firmata adaptor for Robot 25785
D, [2014-10-04T15:45:07.416Z] DEBUG -- : Registering i2c BlinkM driver for Robot 25785
D, [2014-10-04T15:45:07.419Z] DEBUG -- : Registering i2c HMC6352 driver for Robot 25785
D, [2014-10-04T15:45:07.420Z] DEBUG -- : Registering i2c MPL115A2 driver for Robot 25785
D, [2014-10-04T15:45:07.421Z] DEBUG -- : Registering i2c BMP180 driver for Robot 25785
D, [2014-10-04T15:45:07.422Z] DEBUG -- : Registering i2c MPU6050 driver for Robot 25785
D, [2014-10-04T15:45:07.423Z] DEBUG -- : Registering i2c LCD driver for Robot 25785
D, [2014-10-04T15:45:07.424Z] DEBUG -- : Registering i2c LSM9DS0G driver for Robot 25785
D, [2014-10-04T15:45:07.425Z] DEBUG -- : Registering i2c LSM9DS0XM driver for Robot 25785
I, [2014-10-04T15:45:07.426Z] INFO -- : Initializing devices.
I, [2014-10-04T15:45:07.427Z] INFO -- : Initializing device 'mpu6050'.
D, [2014-10-04T15:45:07.428Z] DEBUG -- : Loading driver 'mpu6050'.
I, [2014-10-04T15:45:07.431Z] INFO -- : Starting connections.
I, [2014-10-04T15:45:07.434Z] INFO -- : Connecting to 'arduino' on port com3.
I, [2014-10-04T15:45:10.661Z] INFO -- : Starting devices.
I, [2014-10-04T15:45:10.662Z] INFO -- : Starting device 'mpu6050'.
I, [2014-10-04T15:45:10.666Z] INFO -- : Working.
null
null
null
null
null
null
null
I, [2014-10-04T15:45:29.052Z] INFO -- : Halting device 'mpu6050'.
I, [2014-10-04T15:45:29.053Z] INFO -- : Disconnecting from 'arduino' on port com3.

|====================================================================|

Is there any documentation for more functions MPU6050 as "getMotionAndTemp"?

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

Test image
cylon

from cylon-i2c.

MarceloTomaz avatar MarceloTomaz commented on August 26, 2024

@deadprogram , based on image, this correct?

from cylon-i2c.

deadprogram avatar deadprogram commented on August 26, 2024

@MarceloTomaz where did you get your MPU6050 from? Looks like it might take 5V in instead of 3.3V.

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

@MarceloTomaz did you ever get this to work? have you seen any issues or tried the latest release?

from cylon-i2c.

janaka avatar janaka commented on August 26, 2024

Hi,
The example code here http://cylonjs.com/documentation/drivers/mpu6050/ seems to have a bug.

Should be

    every((1).seconds(), function() {
      my.motionsensor.getMotionAndTemp(function(err, data) {
        console.log(data);
      });

    });

Note the err param

My environment:

  • Windows 7 64bit
  • Arduino Uno
  • GY-521 - MPU 6050 breakout board

This fixed my issue.

I think @edgarsilva Aug 5th tweak adding extra error handling broke the example in to doco

Thanks

from cylon-i2c.

janaka avatar janaka commented on August 26, 2024

@edgarsilva have fixed the documentation and sent a pull request

hybridgroup/cylon-site#83

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

@janaka seems to be correct, checking the PR now.

from cylon-i2c.

edgarsilva avatar edgarsilva commented on August 26, 2024

Any news on this, seems the problem was solved but never logged here, I'm closing the issue.

from cylon-i2c.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.