RigacciOrg / py-qmc5883l

Python driver for the QMC5883L 3-axis magnetometer, developed for the Raspberry Pi
GNU General Public License v3.0
68 stars 31 forks source link

Aiuto! Non riesco a ottenere valori sensati #8

Open federicoparroni opened 4 years ago

federicoparroni commented 4 years ago

ENG: Hi! First of all, congratulations for the fantastic library. I know that this is not the right place for question like this, but I am really lost! I cannot read correct values from the magnetometer, also during the calibration phase (I turn it around of 360 degrees) values do not seem coherent. I am far away from magnets and other magnetic objects. The only thing is my pc, which is about half meter from the Raspberry. I tried to go outdoor, but the same problem occurs. I did not get overflow warning. Can you give me a suggestion on what I am doing wrong?

ITA: Ciao! Innanzitutto, complimenti per la libreria fantastica. So che non è il posto giusto per domande di questo tipo, ma non saprei a chi altro chiedere. Non riesco a leggere valori corretti dal magnetometro, anche durante la calibrazione (in cui ho fatto fare un giro completo di 360°) i valori non sembrano essere coerenti. Non ho vicino calamite o altri oggetti magnetici. L'unico oggetto a circa mezzo metro di distanza dal Raspberry è il mio pc portatile. Ho provato anche andando all'esterno, ma stesso problema. Da escludere anche overflow, dato che non ricevo avvisi. Potresti darmi un tuo parere so cosa potrei aver sbagliato?

image

RigacciOrg commented 4 years ago

ENG: From the picture above, it seems that your magnetometer returns values only in a small sector of the full rotation. Theoretically it should return values in the range (-X) to (+X) and (-Y) to (+Y). Can you please take note of the values (X, Y) shown by the testing program? Tha problem may be that you are rotating the device not on the X-Y plane (i.e. you must keep it flat while rotating). Or simply the device can be defective.

ITA: Dall'immagine sopra, sembra che il tuo magnetometro restituisca valori solo in un piccolo settore della rotazione completa. Teoricamente dovrebbe restituire valori nell'intervallo da (-X) a (+ X) e (-Y) a (+ Y). Puoi prendere nota dei valori (X, Y) mostrati dal programma di test? Il problema potrebbe essere che stai ruotando il dispositivo non sul piano X-Y (cioè devi tenerlo orizzontale durante la rotazione). O semplicemente il dispositivo può essere difettoso.

taviroquai commented 2 years ago

Hi all,

Thanks you so much for this library!

I also have the same problem, please see screen attached.

Rotating the device on XY plane in a full 360 degrees, only gives values on one side. When rotating, it looks like at some point, the indicator goes back and not moving in opposite direction.

image

Any help is appreciated. Thank you.

federicoparroni commented 2 years ago

Hello @taviroquai. In my case, the problem was caused by other circuits that were interfering with the magnetometer. Try to place the magnetometer away from other electromagnetic sources (like motors, raspberry, ...). I just put the sensor 20 cm away from any other device and that solved the issue.

taviroquai commented 2 years ago

I'm using more distance from the Pi now but still returns values only in one side of the compass.

image

This time returns in the opposite site from the first attempt.

I'm trying with bigger cables. How far does it has to be? I'm building a robot, can't have the QMC58883l too far.

magnetometer_calibrate

federicoparroni commented 2 years ago

At this distance I am not experiencing any problem (18cm more or less):

image

federicoparroni commented 2 years ago

Are you connecting the magnetometer directly to the raspberry? I am doing like so. Since these sensors are so cheap, I would suggest trying with a new one, it’s very probable that yours is faulty.

taviroquai commented 2 years ago

Are you connecting the magnetometer directly to the raspberry? I am doing like so. Since these sensors are so cheap, I would suggest trying with a new one, it’s very probable that yours is faulty.

I'm using a breadboard to connect. I will try to connect directly also. Yes it is not expensive, but takes at least a week to get another! :'(

Is there any constraint regarding the chip being horizontal/vertical?

federicoparroni commented 2 years ago

For me getting a new one required months 😢

Direction of the chip is really important. Printed on the sensor you should find a schema of the axes, X-Y plane should coincide with the chip board (and Z axis should be perpendicular to the chip), so basically the sensor needs to be kept flat respect to the ground (as you can see from my image)

taviroquai commented 2 years ago

I got it working the complete 360º calibration but I had to disconnect everything from the PI, leaving only the pi and the sensor and keeping the cable 40cm pointing the sky with the sensor.

I'm not sure if I can use this sensor on my small robot... I need a way to know how much my robots turns when navigating.

magnetometer-calibration

federicoparroni commented 2 years ago

Try to connect back one by one all the other stuff and check which is the disturbing component

taviroquai commented 2 years ago

I have two speakers in my robot so it can talk =) Most certainly they are creating the interference (speaks have magnets) with the sensor.

federicoparroni commented 2 years ago

If you disconnect them, does the magnetometer work properly?

taviroquai commented 2 years ago

I'm going to say yes. I don't think it is a problem with this library so we can close this issue. There are so many variables in the hardware that can affect the results.

Thank you so much for your support!