Setting mag sensitivity

I'm just getting started with the Nano 33 BLE. I have been able to read values from the magnetometer and output them using the 'Arduino_LSM9DS1' library. What I can't accomplish next is setting the mag sensitivity. It doesn't seem like that library supports it and I'm coming up short on finding a way to do it. I'd like to see how it acts when set to 16 Gauss. I'm trying to detect the presence of metal near it and trigger a count.

How exactly, do you know that it is possible to do so? Is this a feature of the hardware?

Yes from everything I have read on the LSM9DS1; https://www.st.com/resource/en/datasheet/lsm9ds1.pdf

• ±4/±8/±12/±16 gauss magnetic full scale

You could use the Wire library to set CTRL_REG2_M (0x21) FS1 and FS0 bits appropriately. See the data sheet for the details.

For more informed help, post the code, using code tags.

A magnetometer is not a good device for detecting metal. All you will get is a change or distortion of the background (Earth's) magnetic field.

Note not many metals do affect a magnetic field, things like silver, copper and aluminium have no affects. Even some types of stainless steel have no magnetic effect.

That will be much easier with a capacitive proximity sensor, like this one.

If possible, try to find one that is NPN open collector (it is not clear whether the one I linked is open collector), as those are easiest to interface with any Arduino. You need only connect the sensor output and GND to Arduino, and read the status with pinMode set to INPUT_PULLUP.

Sensor is powered separately.

Thank you both for the suggestions. Specifically, I'm trying to capture the presence of a bicycle riding by within say 6 feet. I was hoping that by increasing the sensitivity of the magnetic field I could detect a disturbance and increment the number of passer-byers.

Not much chance of detecting a bicycle using a consumer grade magnetometer, and only then if the frame is steel.

Magnetometers do work for detecting automobiles passing by within a few feet, but those have a lot of steel and iron.

I suspect you're right. Maybe I can find a more powerful magnetometer.

In practical applications, large coils of wire under the pavement are used to detect bicycles.

Maybe it’s best I look into other sensors! I’m open to suggestions! This would be for dirt trails no more than 6 feet wide.

Light (or IR) beam break is very easy to implement.

I found someone doing something similar here: https://www.trafx.net/downloads/TRAFx_Mountain_Bike_Counter_Instructions.pdf?v=210922

I'm guessing thats a more sensitive magnetometer, I can't seem to get mine to pick up deviations unless very close.

Featuring an aerospace-quality magnetometer, this counter detects moving objects with ferrous metal content

They claim to have been working on this design for 10 years, now on the fourth generation.

The "moving" part is a very important clue. You have to detect small, short time dependent changes in the ambient magnetic field. That generally means using sophisticated filtering.

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