diff --git a/README.md b/README.md index 6c8c69e..fcb5b66 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/GetData/GetData.ino b/examples/GetData/GetData.ino index d54bc32..468ce06 100644 --- a/examples/GetData/GetData.ino +++ b/examples/GetData/GetData.ino @@ -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();