Skip to content

Commit

Permalink
Call beginMag again when cannot read values of mag on example
Browse files Browse the repository at this point in the history
  • Loading branch information
asukiaaa committed Feb 25, 2023
1 parent f5d2e8a commit c6882ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ void loop() {
}
```

If you cannot get values by calling magUpdate, try calling beginMag and magUpdate again.
```c
void loop() {
auto result = mySensor.magUpdate();
if (result != 0) {
mySensor.beginMag();
result = mySensor.magUpdate();
}
}
```

If you get values of sensor like this..

Name | Max | Min
Expand Down
5 changes: 5 additions & 0 deletions examples/GetData/GetData.ino
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ void loop() {
}

result = mySensor.magUpdate();
if (result != 0) {
Serial.println("cannot read mag so call begin again");
mySensor.beginMag();
result = mySensor.magUpdate();
}
if (result == 0) {
mX = mySensor.magX();
mY = mySensor.magY();
Expand Down

0 comments on commit c6882ae

Please sign in to comment.