Question

I want to implement a Metal Detector app which will react to a magnetic field in the phones surroundings.

How do I read the magnetic field readings from the magnetometer on the iPhone? Does anyone have sample code for accessing the magnetometer readings directly?

Thanks!

Was it helpful?

Solution

I would recommend you look at the O'Reilly book called iOS Sensor that is coming out. They have an entire chapter (6) on the magnetometer and a sample app.

iOS Sensor Programming

Apple Sample Code for Reading the Raw Values from the Magnetometer

OTHER TIPS

No. You can't.

UPDATE : there is no metal detecting components in iPhone. However, there is a magnetometer available since iPhone 3GS. The Compass App makes use of the sensor to detect direction. It just reads magnetic North, but not reading magnetic fields surrounding. Therefore, you can't make a metal detector with it.

Physics Fact: Metal does not generate magnetic fields. Magnets do.

p.s. correct me if I am wrong.

There is already an app which does this. Check this and this blog.

This is what the description says,

The app has an adjustable sensitivity and makes an audible sound signal if the sensitivity reaches a medium level. The phone needs to be shook once to be calibrated if you intend to use the device again.

The app makes use of the magnetometer on the iPhone to find interference with the compass to detect metal objects. Just hover the backside of your mobile, the area under the camera, over the metal and the app should find the metal and there should be an increase in sensitivity.

However I am not sure if it is a fake app or it can be really done this way. Try downloading that and check it yourself. It is a free app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top