Comments (25)
So i've been trying to figure out this problem by debugging some js files in cylon lib folder.
https://docs.google.com/document/d/1PMi3lyb1PIpfdH3ThgH2Ftx7nCoRRxQDfEaPOpANfJ4/edit?usp=sharing
In the document, it shows some specific results from my debugging and I was just wondering if this could help you figuring out what's the problem with the program with not having the hardware.
I tried to connect hmc6352's scl and sda to pin 2, 3 on Yun and pin sda and scl on Yun.
from cylon-i2c.
my friend and i figured out that target[method] gets grabbed from your device list (target is an array? or json list including whole bunch of information about my program). We are wondering what i2cConfig: [function] does since when i print out target[method].appy(targer, arguments)), the result is undefine
from cylon-i2c.
Hi @dongkibravo
I'm working on this i2c issues right now, I'll update shortly.
PS: BTW yes, the info you posted here helps
from cylon-i2c.
It seems there is an issue either on how you wired up the sensor to the arduino or with the sensor itself, do you have any other way of testing if it is working correctly?
I did a small fix in to of the repos, these are the branches and changes, I think this might fix the problem:
hybridgroup/cylon-firmata@9ff319e
I recommend that you just modified the files in your node_modules/cylon-firmata
and node_modules/cylon-i2c
inside your project folder in the YUN, since it is just a couple of lines and that way you do not have to clone the branches and manually move everything over.
@dongkibravo I think there's a good chance this will fix the problem since it seems it was looking for those two calls to a function that does not exist. Let me know how it goes.
from cylon-i2c.
How did you connect the compass?
from cylon-i2c.
@dongkibravo http://cylonjs.com/documentation/drivers/hmc6352-compass/
See the image at the end, you actually do not need the pull-up resistors to connect it to the arduino, the arduino already has them wired up internally.
SDA should be connected to pin A4 on the arduino and SCL to pin A5.
Is your setup correct?
from cylon-i2c.
A4 and a5 meaning analog pin 4 and 5?
from cylon-i2c.
Yes, analog pin 4 is SDA and analog pin 5 is SCL
from cylon-i2c.
@dongkibravo any progress?
from cylon-i2c.
@edgarsilva
so i finally got rid of all of the errors but now it's only saying reading i2c and not getting output inside
my.hmc6352.heading(function(data){
console.log("Debug");
console.log("heading " + data);
});
why am i not going into that function
from cylon-i2c.
@dongkibravo Could you pls paste all the code you are using for the example here?
Are you using the changes I pasted in the branch yesterday?
from cylon-i2c.
Also paste a gist of output when you run your program .
from cylon-i2c.
@dongkibravo any progress? anything I can help you with? if you can share the code you are running and an actual picture of the setup, how you are connecting everything, I might be able to help some more.
from cylon-i2c.
@edgarsilva This is code that i'm using
var Cylon = require('cylon');
// define the robot
var robot = Cylon.robot({
// change the port to the correct one for your Arduino
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyATH0' },
device: { name: 'hmc6352', driver: 'hmc6352'},
work: function(my) {
every((1).second(), function(){
my.hmc6352.heading(function(data){
console.log("debug");
console.log("heading " + data);
});
});
}}).start();
and this is the result
I, [2011-09-08T19:46:57.524Z] INFO -- : Initializing connections.
I, [2011-09-08T19:46:57.585Z] INFO -- : Initializing connection 'arduino'.
D, [2011-09-08T19:46:57.600Z] DEBUG -- : Loading adaptor 'firmata'.
D, [2011-09-08T19:47:00.007Z] DEBUG -- : Registering Firmata adaptor for Robot 80994
D, [2011-09-08T19:47:00.013Z] DEBUG -- : Registering GPIO AnalogSensor driver for Robot 80994
D, [2011-09-08T19:47:00.040Z] DEBUG -- : Registering GPIO Button driver for Robot 80994
D, [2011-09-08T19:47:00.043Z] DEBUG -- : Registering GPIO ContinuousServo driver for Robot 80994
D, [2011-09-08T19:47:00.046Z] DEBUG -- : Registering GPIO LED driver for Robot 80994
D, [2011-09-08T19:47:00.049Z] DEBUG -- : Registering GPIO MakeyButton driver for Robot 80994
D, [2011-09-08T19:47:00.052Z] DEBUG -- : Registering GPIO Maxbotix driver for Robot 80994
D, [2011-09-08T19:47:00.055Z] DEBUG -- : Registering GPIO Motor driver for Robot 80994
D, [2011-09-08T19:47:00.057Z] DEBUG -- : Registering GPIO Servo driver for Robot 80994
D, [2011-09-08T19:47:00.060Z] DEBUG -- : Registering GPIO IR Range Sensor driver for Robot 80994
D, [2011-09-08T19:47:00.063Z] DEBUG -- : Registering GPIO DirectPin Driver for Robot 80994
D, [2011-09-08T19:47:00.068Z] DEBUG -- : Registering i2c BlinkM driver for Robot 80994
D, [2011-09-08T19:47:00.097Z] DEBUG -- : Registering i2c HMC6352 driver for Robot 80994
D, [2011-09-08T19:47:00.100Z] DEBUG -- : Registering i2c MPL115A2 driver for Robot 80994
D, [2011-09-08T19:47:00.104Z] DEBUG -- : Registering i2c BMP180 driver for Robot 80994
D, [2011-09-08T19:47:00.107Z] DEBUG -- : Registering i2c MPU6050 driver for Robot 80994
D, [2011-09-08T19:47:00.112Z] DEBUG -- : Registering i2c LCD driver for Robot 80994
I, [2011-09-08T19:47:00.125Z] INFO -- : Initializing devices.
I, [2011-09-08T19:47:00.129Z] INFO -- : Initializing device 'hmc6352'.
D, [2011-09-08T19:47:00.140Z] DEBUG -- : Loading driver 'hmc6352'.
I, [2011-09-08T19:47:00.173Z] INFO -- : Starting connections.
I, [2011-09-08T19:47:00.190Z] INFO -- : Connecting to 'arduino' on port /dev/ttyATH0.
I, [2011-09-08T19:47:06.187Z] INFO -- : Starting devices.
I, [2011-09-08T19:47:06.192Z] INFO -- : Starting device 'hmc6352'.
I, [2011-09-08T19:47:06.197Z] INFO -- : Driver hmc6352 started.
I, [2011-09-08T19:47:06.219Z] INFO -- : Working.
Reading I2c
Reading I2c
Reading I2c
Reading I2c
Reading I2c
Reading I2c
from cylon-i2c.
Seems like the sensor is either not working, or not connected properly can you share a pic of the setup of the sensor and how it is connected to the arduino?
from cylon-i2c.
scl is connected to pin a5 sda is connected to pin a4
from cylon-i2c.
I confirmed that the chip works fine by using this code
#include <Wire.h>
void setup() {
Serial.begin(57600);
Serial1.begin(57600);
Wire.begin();
}
void loop() {
Wire.beginTransmission(0x21);
Serial.write(Wire.write("A"));
delay(100);
Wire.requestFrom(0x21, 2); //get the two data bytes, MSB and LSB
byte MSB = Wire.read(); // Result will be in tenths of degrees (0 to 3599)
byte LSB = Wire.read(); // Provided in binary format over two bytes."
Wire.endTransmission();
// Compute result from the two bytes results
float myres = ((MSB << 8) + LSB) / 10;
Serial.print(myres);
Serial.println(" degrees");
delay(3000);
}
in arduino
and got result like this
�247.00 degrees
�247.00 degrees
�256.00 degrees
�255.00 degrees
�255.00 degrees
�147.00 degrees
�142.00 degrees
(ps the connected pins were digital 2,3)
from cylon-i2c.
Are those accurate readings?
I can't make the connections to the chip very well on the pic, but does not seem to be hooked up like this?
http://bildr.org/2011/01/hmc6352/
from cylon-i2c.
yes the reading was pretty accurate compare to my iphone compass and the connection is exactly like it on the website
from cylon-i2c.
Here are more examples, from the picture it seems some cables are swaped.... but the picture might not be that accurate, since I cannot make out the last pin:
http://www.funnyrobotics.com/2011/03/arduino-with-hmc6352-digital-compass.html
http://wiring.org.co/learning/libraries/hmc6352sparkfun.html
Check those examples and verify it works and it is 100% wired correctly if that is the case I can dig up some more in the code, try to debug the output.
I'll start checking the driver while you test only on the arduino side.
from cylon-i2c.
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at EventEmitter.addListener (events.js:160:15)
at EventEmitter.once (events.js:185:8)
at Board.sendI2CReadRequest (/usr/lib/node_modules/firmata/lib/firmata.js:723:10)
at Adaptor.i2cRead (/root/drone/node_modules/cylon-firmata/lib/firmata.js:95:14)
at Connection.base.(anonymous function) as i2cRead
at Hmc6352.heading (/root/drone/node_modules/cylon-i2c/lib/hmc6352.js:36:19)
at Device.base.(anonymous function) as heading
at null. (/root/drone/testa.js:11:17)
at wrapper as _onTimeout
at Timer.listOnTimeout as ontimeout
i got this error in the middle of running the program. And can we assume that Uno board and Yun board have the same pin diagrams?
from cylon-i2c.
yes, if you upload a sketch to the uno with the sensor connected should work just fine on the arduino Yun.
from cylon-i2c.
That error is happening because the firmata lib never hears back from the I2C device, so it requests to read from the I2C bus and waits for a response that never arrives, then it just keeps adding listeners every time you call heading and all of them are waiting for a response, causing the EventEmitter error, which makes me think the sensor is not being detected by the arduino board.
Let's log the heading function in the driver, could you replace the heading function with this one pls:
// ./node_modules/cylon-gpio/lib/hmc6352.js
Hmc6352.prototype.heading = function(callback) {
var self = this;
console.log('BEFORE I2C read:');
this.connection.i2cRead(this.address, this.commandBytes('A'), 2, function(data) {
console.log('DATA FROM CALLBACK:', data);
callback(self.parseHeading(data));
});
};
Then run it and share the output, BUT before that run the examples I pasted above just on the arduino to make sure the sensor is hooked up correctly and working as expected, you'll need to upload the sketches and then reupload the modified firmata file to the arduino.
from cylon-i2c.
I think this issue was addressed by the most recent release of cylon-i2c. Can you please give this a try?
from cylon-i2c.
@dongkibravo did you ever got this to work? did you try the latest release? I will close the issue since it should be addressed by latest release.
If you ever got it to work please let us know, so this info can be useful to someone else, regards.
from cylon-i2c.
Related Issues (11)
- Driver MPU6050 not working as expected. HOT 28
- Any advice on edison + LSM9DS0 HOT 16
- got driver for DS1337 real time clock HOT 3
- Device agnostic driver HOT 3
- Bosch BME280 HOT 1
- Is my screen incompatible ? HOT 3
- BMP180 not working HOT 12
- How to register just created new driver
- I2C lcd backlight flickering on Arduino Yún
- i2c blocking with multiple devices
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cylon-i2c.