Forum Archive

Sensors - Thanks! But a problem question with magnetic field sensor...

inHishand

Thanks for adding functions to access the other sensors on the iPad, but I am having trouble getting data from the mag field sensor. Is some kind of calibration required? (I have the same result on both an iPad 2 and 4, both of which work with compass apps.)

For example:


import motion

motion.start_updates()
g= motion.get_gravity()
mag=motion.get_magnetic_field()
acc=motion.get_user_acceleration()
att=motion.get_attitude()
motion.stop_updates()

print g
print mag
print acc
print att

gives output:


(0.10736322402954102, -0.17101316154003143, -0.9794016480445862)

(0.0, 0.0, 0.0, -1)

(-0.0050377873703837395, -0.00197572517208755, 0.01570233143866062)

(0.10918527841567993, 0.17185789346694946, 0.004843760747462511)
omz

Thanks, this seems like a bug, I'll look into it.

henryiii

I noticed that with an iPhone 5s, too.

Vaughanje

Just chiming in that I've seen the same thing on my iPhone 5s and iPad Air.

alport

I have been waiting some time for a 'python' implementation to implement a routine that would access the vector value of the magnetic field on iOS devices - as opposed to just a compass heading.
Joy to see that Pythonista offers it - but tears that it returns zero!!!
Any chance of your looking at it soon?
I confirm that motion.get_magneticfield() returns 0.0 on both iPad Air and iPhone 5.