# Saving hall sensor positions

**URL:** <https://community.simplefoc.com/t/saving-hall-sensor-positions/8040>\
**Category:** developement\
**Created:** [March 22, 2026, 8:48am UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040 "2026-03-22T08:48:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![geofrancis](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@geofrancis](https://community.simplefoc.com/u/geofrancis)\
**Post date:** [March 22, 2026, 8:48am UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040/1 "2026-03-22T08:48:49Z")

</div>

I am trying to use simple foc for a wheeeled rover but the initalisation it does on startup is a problem. is there a simple way to detect the hall sensor values then write them into the code?

---

<div class="post-metadata">

**Author:** ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)\
**Post date:** [March 23, 2026, 9:27am UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040/2 "2026-03-23T09:27:16Z")

</div>

Hey @geofrancis,

You can skip the direction check (the part of the init when the motor moves) if you provide the motor with [the sensor direction](https://docs.simplefoc.com/bldcmotor#step-61-skip-alignment---position-sensor). And the init should be a bit more repetitive if you use the hall sensor without interrupts.

```auto
// set the direction
motor.sensor_direction = Direction::CW; // CW or CCW
// then call initFOC()
motor.initFOC();

```

---

<div class="post-metadata">

**Author:** ![geofrancis](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@geofrancis](https://community.simplefoc.com/u/geofrancis)\
**Post date:** [June 15, 2026, 2:15pm UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040/3 "2026-06-15T14:15:40Z")

</div>

I have done this but the motors still move a little on startup and if its held still the wheels start turning the wrong way etc. i can only get it to initialize with the wheels off the ground.

---

<div class="post-metadata">

**Author:** ![o\_lampe](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/o/85e7bf/32.png) [@o\_lampe](https://community.simplefoc.com/u/o_lampe)\
**Post date:** [June 15, 2026, 3:02pm UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040/4 "2026-06-15T15:02:53Z")

</div>

You have probably set voltage\_align too low. Or the motor moves to angle=0 after init, because it is preset in your program.

---

<div class="post-metadata">

**Author:** ![geofrancis](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@geofrancis](https://community.simplefoc.com/u/geofrancis)\
**Post date:** [June 15, 2026, 3:20pm UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040/5 "2026-06-15T15:20:34Z")

</div>

I am using hall sensors I dont see why it needs to move. its only very slighly i just thought it was from it switching on but if the wheels cant move that tiny amount they can end up turning the wrong way.

---

<div class="post-metadata">

**Author:** ![geofrancis](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@geofrancis](https://community.simplefoc.com/u/geofrancis)\
**Post date:** [June 16, 2026, 11:12am UTC](https://community.simplefoc.com/t/saving-hall-sensor-positions/8040/6 "2026-06-16T11:12:35Z")

</div>

OK I have found this, it looks like a way to save the settings to non volatile memory, but not on esp32, would it be possible to do the detection then just hard code the settings rather than using volitile memory?

> **[Arduino-FOC-drivers/src/settings at master · simplefoc/Arduino-FOC-drivers](https://github.com/simplefoc/Arduino-FOC-drivers/tree/master/src/settings)**
>
> master/src/settings

I was looking at this,

> **[Options Reference](https://docs.simplefoc.com/cheetsheet/options_reference)**
>
> An Arduino Based Field Oriented Control(FOC) library documentation

and i found this

| motor.zero\_electric\_angle | NOT SET | Needed for FOC control. Normally set during motor FOC initialization. If set before motor.initFOC(), measurement of zero electric angle is skipped during alignment. |
| --- | --- | --- |
| motor.sensor\_direction | NOT SET | Normally set during motor FOC initialization. Determines sensor direction vs positive motor direction (can be opposite, depending how you connect your motor cables). If set before motor.initFOC(), measurement of sensor’s natural direction is skipped during alignment. |

I have motor.sensor\_direction = Direction::CCW; so is the remaining movement the motor.zero\_electric\_angle being detected? if i set that then all movement should stop as far as i can find.

```auto

  //commect out for auto detect

motor1.sensor_direction = Direction::CCW; // CW or CCW

motor1.zero_electric_angle = 4.19;

```

this looks to have fixed my issue, i just got the zero angle when its being detected then set it to be used on startup and no more movement.
