# Data retrieved via magnetometer

**URL:** https://community.thunkable.com/t/data-retrieved-via-magnetometer/3819277
**Category:** Questions about Thunkable X
**Created:** [May 11, 2025, 12:20pm UTC](https://community.thunkable.com/t/data-retrieved-via-magnetometer/3819277 "2025-05-11T12:20:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fabienleromancer1hz8](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@fabienleromancer1hz8](https://community.thunkable.com/u/fabienleromancer1hz8)
#### Post date: [May 11, 2025, 12:20pm UTC](https://community.thunkable.com/t/data-retrieved-via-magnetometer/3819277/1 "2025-05-11T12:20:30Z")

</div>

Hello everyone,

I am currently working on a robotics project that requires the use of a magnetometer.

-I’m looking at x y z flux values.  
-I also use the “heading” function  
-I’ve coded a heading function

When I point the phone north, I get X=0 Y=20, which is normal.  
The “heading” function returns 90° and not 0 which may be normal depending on thunkable logic (if trigonometric angle returns 0 = west; 90 = north; 180 = east).

I’ve coded the Atan2 function myself and the modulo returns the same value as the heading (variable “azimut app 2"” = “app variable heading”).

My questions are :

Can I trust the flux reading to make my calculations (the flux respects Y to the top of the screen X from left to right), in order to find north = 90 on all phones that download the application?  
In fact, magnetometers have no mounting convention in smartphones, and the data is processed by the devices.  
The data streams can be  
Sensor.TYPE\_MAGNETIC\_FIELD\_UNCALIBRATED  
or  
Sensor.TYPE\_MAGNETIC\_FIELD  
which would not give an orientation relative to the phone but to the sensor itself.

My second question is:  
Is it possible to synchronize the accelerometer to correct drift if the phone isn’t perfectly flat?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/a/8a7b8cafd0b9cc7814c20f1fe96146dd71e10a3d.png)

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [May 16, 2025, 9:57pm UTC](https://community.thunkable.com/t/data-retrieved-via-magnetometer/3819277/2 "2025-05-16T21:57:12Z")

</div>

As shared on a different support channel, we use the library expo-sensors for this component. he doc for that is here:  
[https://docs.expo.dev/versions/latest/sdk/magnetometer/](https://docs.expo.dev/versions/latest/sdk/magnetometer/)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [August 14, 2025, 9:57pm UTC](https://community.thunkable.com/t/data-retrieved-via-magnetometer/3819277/3 "2025-08-14T21:57:57Z")

</div>

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