Using TWO magnetometers HMC5883L

Hello everyone and thank you in advance for any piece of suggestion.

Short story: have two magnetometers (board: GY-271, GY-511) using same I2C hardware address and I rather find a software solution to read simultaneously (including: use a spare analog pin to 5V turn on and off the sensor), than adding an expansion module. Any hint?

Extended Poem:
As an Arduino beginner I had the brilliant idea to investigate the world of satellite tracking, and I'm in the attempt to build an antenna rotator with elevation (ham radio purpose).
By design (?) I chose not to 'guess' where my antenna is aiming using a stepper motor, but I rather want to have a real feedback of aiming and compensate with motors instead.

Turn out that magnetometers stop giving effective readings when aiming the sky (I think is somewhat matter of the 'gimbal effect'), forcing to backup and use two different sensors, one placed on the rotator itself (magnetometer, horizontal), and one on the elevator (accelerometer).
The thole point is to make it construction-wise as easy as possible, so that once the project is released open source, might be easily copy-made by others.

My aim is to to keep things as simple as possible. An Arduino board, servo for motors (BTS7960), two sensors connected I2C possibly the same, and read magnetometer from one, accelerometer from the second. As simple as that.

Turn out (#2) that all my GY-80 and GY-511 boards, all have same magnetometers hardware, and address 0x1E, ish! Truth is that GY-521 (on the way..) have ability to AD0 and change address, but having already all these seems such a trivial issue that I can't cope with not having come up with a decent solution. The power up/power down at runtime doesn't sound very long lasting, is it?

Thank you for any idea.

Then you should wait for the GY-521 to arrive. Trying to use 2x sensors with the same address by powering them up and down is not simple. They will not need much current, so powering them from Arduino output pins would not damage the pins, but the sensors might get "parasitic" or "phantom" power through other pins, which can harm them or cause other problems.

Welcome to the forum.

Magnetometers have 3 axis. It does not matter where they point. Perhaps your sketch uses only 2 axis ? Every project with a magnetometer has to be calibrated.

The HMC5883L no longer made. Sometimes it is claimed that it is a "refurbished" one, but it is not. You get a counterfeit one or a different chip.
The GY-521 has a MPU-6050 :scream: It is also no longer made. You will get a counterfeit MPU-6050. Please don't use that one, it might suddenly stop working.

If you want something that is not fake, then you should buy real things from real sellers such as Adafruit, Sparkfun, Pololu.
For example the LIS3MDL, but they have others: https://www.adafruit.com/category/684

Which Arduino board do you use ? A 5V Arduino board with 3.3V sensors is not a ideal situation.

Thank you, indeed the 'wait and see' (when package arrive) will be probably the best solution. Something inside me was saying 'don't power up by pins - couldn't tell why my inner voice was so vocal, you gave it a word :slight_smile:

Thank you for the warm and helpful welcome.

Turn out that yes, I read about the three axis but have no clue I could use at my advantage, I'm a bi-dimensional being have problems to think multi.

Thankfully, internet seems to be an excellent source of samples, but even though I found some certainly more professional than my ability to decode them, still have issues while tilting.
Then I came up with another project, tilt-compensate-compass that make full use of accelerometer's data to rectify magnetometer readings: https://www.instructables.com/Tilt-Compensated-Compass/

Bi-dimensional being as I am, that's completely sci-fi of my comprehension but it should work, the author is a real being and certainly know what he does.
This is MPU-6050 based, sorry for your opinion on it but at the present time have no alternative but to give a try as soon as the device comes.

Still, it shows to compensate up to 45° and yet at this point the included chart shows a delta from heading of -4 that is sort of unacceptable if aiming a microwave antenna to a moving satellite. No go, look like the two separate sensors still to be the best way to achieve it - although of course I'm up for any further suggestion.

Do you know what the magnetic declination is for your location and can you make a drawing of the device with the magnetometer attached to it ?

Maybe the tilt-compensated compass has its limits. Others on this forum know more about that. I learned from others that calibration is important.

That is not true. Where did you read that? Perhaps you are thinking about tilt compensation.

What you want is a 9DOF sensor and Arduino running AHRS code. It will give you 3D orientations, including a north reference. Buy any of the current crop available at Sparkfun, Adafruit, Pololu. All have AHRS code available.

The gyro and magnetometer must be carefully calibrated in place before use. For best accuracy also calibrate the accelerometer. Overview and tutorial here: Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers

You know when all your certainties dissolve in a bit? Well, in my case is a 4-bytes keyword -> 'AHRS' that sounds very very promising. From here on, another month of try-and-fail, and I'll be back with new, interesting discoveries from the mono dimensional world (that turn out wrong as soon as I encounter some true experts!).

Thank you for hint! I only hope to achieve on a budget sensor, because I'm no eager to scale up this project to the cost of a space shuttle! I'm the one on ground, after all..

Would $14.95 break the bank? This IMU works about as well any of the current crop of consumer grade IMUs. Others are available from Sparkfun and Pololu.

As an exceptionally strange coincidence, taken inspiration from AHRS hint courtesy of jremington, I ended up with a sketch for my ancient GY-80 10DOF and some github code found here: GitHub - vshymanskyy/GY80: Arduino/Processing sketch for GY80 9DOF AHRS
Guess what, the only comment to the author comes from you, Koepel. Loop closed.

Right! Pity, it's unavailable at the present time and shipping+ import tax + local VAT makes the board's cost a breeze compared to the rest, but you made your point. Let me figure out some.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.