Faire fonctionner la boussole GY-271 QMC5883L

Bonjour, j'ai acheté un module boussole avec la puce GY271 mais je n'arrive pas a le faire fonctionner.

J'ai essayé cette librairie sans succé: GitHub - mprograms/QMC5883LCompass: QMC5883L Compass is a Arduino library for using QMC5583L series chip boards as a compass. Supports: - Getting values of XYZ axis. - Calculating Azimuth. - Getting 16 point Azimuth bearing direction (0 - 15). - Getting 16 point Azimuth bearing Names (N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW) - Smoothing of XYZ readings via rolling averaging and min / max removal. - Optional chipset modes

Quelqu'un peut t'il me conseiller un code ou une librairie qui fonctionnerais avec ce module:

https://fr.aliexpress.com/item/1005005692459217.html?pdp_npi=2%40dis!EUR!1%2C43€!1%2C29€!!!!!%40211b801616899586289581696ee800!12000034025856040!btf&_t=pvid%3Ab9734be4-37e1-467c-9657-ea84195d7147&afTraceInfo=1005005692459217__pc__pcBridgePPC__xxxxxx__1689958629&spm=a2g0o.ppclist.product.mainProduct&gatewayAdapt=glo2fra

Merci d'avance

Bonsoir cyrilcarlita

Je n'ai malheureusement pas ce composant, mais c'est étonnant qu'une librairie spécifique au processeur de ton module ne fonctionne pas.
Quel Arduino et sur quelles pin as tu connecté les pin du module?
Eventuellement, fait une photo en gros plan.

Fais un scan du bus i2C pour voir si tu vois ton module (adresse 0x1E ou 30).

A+
Cordialement
jpbbricole

Bon , je viens de faire marcher une autre librairie HMC5883L_Simple, qu'on trouve ici:
GitHub - sleemanj/HMC5883L_Simple: Simple to use Arduino library to interface to HMC5883L Magnetometer (Digital Compass) (j'obtiens de mon résultats, le nord magnetique en degres)

J'utilise un arduino uno, j'ai alimenté en 5v le module et j'ai connecté sda à a4 et scl à a5

J'ai vu que les nouveaux arduino uno ont d'autres pin pour sca et scl, peu etre sa viens de sa.

Bonsoir
:+1:
HMC5883 ou QMC 5883, les vendeurs de cartes s'emmèlent parfois les pinceaux...
Il me semble que le premier, de marque Honeywell, est l'original : tu es bien tombé

Bonsoir cyrilcarlita

Ce ne sont pas de nouvelles pin, la pin SDA = A4, SCL = A5

Cordialement
jpbbricole

Finalement j'ai parlé trop vite, j'ai modifié la déclinaison magnetique par rapport a la ou je me trouve, je n'ai plus la bonne direction du nord magnetique.

J'ai suivi les instruction qu'il y avait dans le fichier mais ca ne m'indique pas la bonne orientation.

/*
 * 
 * Compass.ino - Example sketch for reading a heading from an HMC5883L triple axis magnetometer.
 * 
 * GY-273 Compass Module  ->  Arduino
 * VCC  -> VCC  (See Note Below)
 * GND  -> GND
 * SCL  -> A5/SCL, (Use Pin 21 on the Arduino Mega)
 * SDA  -> A4/SDA, (Use Pin 20 on the Arduino Mega)
 * DRDY -> Not Connected (in this example)
 * 
 * Voltage Note
 * ~~~~~~~~~~~~  
 * The GY-273 Board has a 3v3 Regulator on it, and the SDA/SCL are pulled up to that so it is OK to 
 * use with 5v Arduino's.
 * 
 * If you are using any other breakout, or the raw IC, you need to be using 3v3 to supply and signal!
 * 
 * Datasheet: http://goo.gl/w1criV
 * 
 * Copyright (C) 2014 James Sleeman
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a 
 * copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the 
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
 * THE SOFTWARE.
 * 
 * @author James Sleeman, http://sparks.gogo.co.nz/
 * @license MIT License
 * 
 */

#include <Arduino.h>
#include <Wire.h>
#include <HMC5883L_Simple.h>

// Create a compass
HMC5883L_Simple Compass;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
    
  // Magnetic Declination is the correction applied according to your present location
  // in order to get True North from Magnetic North, it varies from place to place.
  // 
  // The declination for your area can be obtained from http://www.magnetic-declination.com/
  // Take the "Magnetic Declination" line that it gives you in the information, 
  //
  // Examples:
  //   Christchurch, 23° 35' EAST
  //   Wellington  , 22° 14' EAST
  //   Dunedin     , 25° 8'  EAST
  //   Auckland    , 19° 30' EAST
  //    
  Compass.SetDeclination(23, 35, 'E');  
  
  // The device can operate in SINGLE (default) or CONTINUOUS mode
  //   SINGLE simply means that it takes a reading when you request one
  //   CONTINUOUS means that it is always taking readings
  // for most purposes, SINGLE is what you want.
  Compass.SetSamplingMode(COMPASS_SINGLE);
  
  // The scale can be adjusted to one of several levels, you can probably leave it at the default.
  // Essentially this controls how sensitive the device is.
  //   Options are 088, 130 (default), 190, 250, 400, 470, 560, 810
  // Specify the option as COMPASS_SCALE_xxx
  // Lower values are more sensitive, higher values are less sensitive.
  // The default is probably just fine, it works for me.  If it seems very noisy
  // (jumping around), incrase the scale to a higher one.
  Compass.SetScale(COMPASS_SCALE_130);
  
  // The compass has 3 axes, but two of them must be close to parallel to the earth's surface to read it, 
  // (we do not compensate for tilt, that's a complicated thing) - just like a real compass has a floating 
  // needle you can imagine the digital compass does too.
  //
  // To allow you to mount the compass in different ways you can specify the orientation:
  //   COMPASS_HORIZONTAL_X_NORTH (default), the compass is oriented horizontally, top-side up. when pointing North the X silkscreen arrow will point North
  //   COMPASS_HORIZONTAL_Y_NORTH, top-side up, Y is the needle,when pointing North the Y silkscreen arrow will point North
  //   COMPASS_VERTICAL_X_EAST,    vertically mounted (tall) looking at the top side, when facing North the X silkscreen arrow will point East
  //   COMPASS_VERTICAL_Y_WEST,    vertically mounted (wide) looking at the top side, when facing North the Y silkscreen arrow will point West  
  Compass.SetOrientation(COMPASS_HORIZONTAL_X_NORTH);
  
}

// Our main program loop.
void loop()
{
   float heading = Compass.GetHeadingDegrees();
   
   Serial.print("Heading: \t");
   Serial.println( heading );   
   delay(100);
}

J'obtiens environs 60 degres pour le nord, etrange non?

vous avez bien 2 axes parallèles à la surface de la terre comme dit dans le code?

  // The compass has 3 axes, but two of them must be close to parallel to the earth's surface to read it, 
  // (we do not compensate for tilt, that's a complicated thing) - just like a real compass has a floating 
  // needle you can imagine the digital compass does too.

Oui, j'ai verifié plusieurs fois avant de poster

dans votre code il y a

vous êtes en Nouvelle Zélande ?

Non, c'est le createur de la librairie qui est en nouvelle zelande, j'ai bien modifié le fichier avec l'endroit ou je suis. Soit :

Compass.SetDeclination(2, 28, 'E');

En Algérie alors c'est ça? du côté de la wilaya de Ouargla ?

est-ce que votre carte a un régulateur 3.3V embarqué ? pas de masse métallique ou moteur à proximité ?

Oui la carte supporte le 5 v car il y a un regulateur 3.3v,

En fait ce n'est pas la position ou je me trouve mais l'angle de déclinaison par rapport a ma position.

On peut la trouver en utilisant ce site:

ah oui OK

je n'ai pas été parcourir la bilbiothèque utilisée.

Bonjour

2 degrés comme déclinaison , ça parait OK en gros dans l'hexagone

a quoi sert le seond paramètre auqiuel est donné la valeur 28 ?

curieux : les 60° qui intriguent seraient une valeur crédible de l'inclinaison

oui - en fait à plein d'endroits :slight_smile:

Je viens d'essayer le premier exemple sur cette page: Arduino & HMC5883L ou QMC5883L (compas magnétique numérique) - /dev/tbo

Toujours un problème d'orientation

avez vous essayé ce tuto (en anglais)

la déclinaison est 2°28' Est

Je n'ai pas de vraie boussole pour vérifier la position du nord, j'ai simplement pris une feuille collée sur le bureau sur laquelle j'ai mis en place les points cardinaux, trouvé avec la boussole de mon téléphone.

Et non il n'y a rien qui peut comprometre la détection du nord magnetique.

Avant ça j'avais utilisé un autre module qui n'est plus disponible (avec un pic 16f877a et ccs) Un module cmps03

Je suis allé voir le lien, je n'ai pas essayé, il semble ne pas indiquer le nord magnetique...

Ce qui m'interresse c'est le nord magnetique en degres