Comments (13)
from qmc5883l.
Hard to say, I haven't seen this behavior.
What's your hardware setup?
from qmc5883l.
I am using an Ardunio UNO hooked up to Sparkfun's GPS Mouse that has one of these onboard (although their documentation doesn't say how to interface with it, it's there and on the SCL and SDA lines).
from qmc5883l.
Just for comparison, I have been using this code for on an Arduino Nano, Ardunio Mega, and Teensy-2.0 on a soldered circuit board with a short (centimeters) I2C bus with three devices (BMP-180, MPU-6050, QMC5883L), and haven't observed any hanging problems.
For reference, I assume you are using this, right?
https://cdn.sparkfun.com/assets/learn_tutorials/5/7/1/GPM-808G--UAV_GNSS_receiver_ublox8030_QMC5883.pdf
It possible there is a problem in the QMC5883L driver. As a first debugging step, I would suggest adjusting your sketch to use readRaw()
and print out the raw compass values instead of the calibrated values. If that runs stably for a long time, then it means there is some problem in the calibrated readHeading()
.
It's also possible there is a problem in the hardware. From the picture in the datasheet, I am somewhat concerned about the length of the leads: I2C isn't really designed to be used as an off-board connection, although it can work sometimes. You may also need to add (or adjust or remove) the termination resistors on the bus: some devices have them built in, and some don't. Sometimes the termination needs to be adjusted depending on the bus voltage.
And, just to eliminate all the possibilities, you might just try some other simple long running sketch (e.g. just print out the time once per second) and see if the board crashes. If that's the case, then you have some other underlying issue.
Hope that helps, let me know what you find.
from qmc5883l.
I did some digging and it turns out I was using 5 volt logic to the chip, however it was being powered with 3.3v. Now that I added a level shifter, the chip wont even init which is annoying. I am a little over my head here
from qmc5883l.
This seems to be a pretty common arrangement -- the chip runs at 3.3v, but the board has a regulator (and sometimes) a level shifter for the signals, so it appears as a 5V device externally.
from qmc5883l.
Yeah, I have same problem. For my case, i'm using Arduino Mega 2650 R3, I put directly SCL and SDA (that two without number - close to ICSP port). It works for me.
from qmc5883l.
Let's try to narrow down the source of the crash by eliminating some code.
This sketch just reads and prints the raw values, without calibrating.
If you run this, does it still crash?
#include <QMC5883L.h>
#include <Wire.h>
QMC5883L compass;
void setup()
{
Wire.begin();
compass.init();
compass.setSamplingRate(50);
Serial.println("QMC5883L Compass Demo");
Serial.println("Turn compass in all directions to calibrate....");
}
void loop()
{
int16_t x, y, z, t;
compass.readRaw(&x,&y,&z,&t);
Serial.print(x);
Serial.print(" ");
Serial.print(y);
Serial.print(" ");
Serial.print(z);
Serial.print("\n");
}
from qmc5883l.
The code above still crashes on my Wemos Mega after about 20 values have been printed.
from qmc5883l.
I moved the QMC5883L closer to the SCL,SDA pins on the Wemos Mega.
Now, it appears to run like a dream.
The funny thing is, I didn't shorten the cable.
I'm a programmer, not an electronics engineer, so I'll just write that up as 'Spooky Hardware At A Distance'.
from qmc5883l.
I swear by my mother's cold, dark grave. With the cable attached, I moved the sensor closer to the board. Values are still ticking out. I can move it, I can shake it, I can rattle it.
Before I moved it, it would barely print 20 values before locking up.
It's probably something with picoFarads, but to me, it's magic.
Or microHenries? The cable was straight, now it's arced.
The sensor was at the other side of an L298N motor driver board, but I ran the Wemos Mega off the USB, so the L298N should be powered down.
Others have had similar experiences in the distant past:
http://www.catb.org/~esr/jargon/html/magic-story.html
from qmc5883l.
Ok, I think we have established that it's a hardware problem.
I2C was really designed as an on-board communication mechanism.
It can be carried by wires off-board, but they have to be kept very
short, otherwise strange things can happen...
from qmc5883l.
Ok, I think we have established that it's a hardware problem.
I2C was really designed as an on-board communication mechanism.
It can be carried by wires off-board, but they have to be kept very
short, otherwise strange things can happen...
Are you sure you are using the right pullup resistors on both the SDA&SCL pins? See https://en.m.wikipedia.org/wiki/I%C2%B2C, physical layer: measure the line capacitance C and pick a high resistance R allowing a bitrate up to 1/RC
from qmc5883l.
Related Issues (17)
- M_PI Deprecated HOT 3
- Missing Wire.begin() HOT 4
- Don't while(1) in loop() HOT 2
- ATTiny85 compile issue HOT 3
- Example HOT 1
- sensor is not responding HOT 1
- License? HOT 1
- How to calculate Yaw by accelerometer data Fusion? HOT 1
- I2C stops working at fast reading (100Hz) solved HOT 4
- 90° only
- readHeading returns 1 HOT 2
- compass stop working after couple of minutes HOT 2
- This function will never return an Angle. HOT 4
- fail to calibrate QMC5883L module HOT 1
- Wrong example in the library. HOT 4
- Calibration HOT 1
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 qmc5883l.