Skip to content

Commit fe39249

Browse files
IMU fixed
IMU library LSM6DS3 has wrong calculation of temperature - it has been updated.
1 parent d1c14d2 commit fe39249

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

RoboHeart.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,13 @@ float RoboHeart::getRotationY(){
224224

225225
float RoboHeart::getRotationZ(){
226226
return this->_rotationZ;
227+
}
228+
229+
230+
float RoboHeart::getTemperatureC(){
231+
return (imu.readRawTemp() / 256.) + 25;
232+
}
233+
234+
float RoboHeart::getTemperatureF(){
235+
return (getTemperatureC()* 1.8) + 32 ;
227236
}

RoboHeart.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "RoboHeartStepperMotor.h"
1919
#include "pins_RoboHeart.h"
2020
#include <math.h>
21-
#define TRESHOLD 0.1 //treshold in degrees/s
21+
#define TRESHOLD 0.2 //treshold in degrees/s
2222

2323
#define MOTOR_A_CHANNEL1 0
2424
#define MOTOR_A_CHANNEL2 1
@@ -65,6 +65,8 @@ class RoboHeart {
6565
static float _driftZ;
6666
static bool tick;
6767
static void rotationCallBack(void *pvParameter);
68+
float getTemperatureC();
69+
float getTemperatureF();
6870

6971
private:
7072
Stream* _debug = NULL;

examples/RoboHeartIMU/RoboHeartIMU.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void setup() {
2020
// Set up the RoboHeart
2121
heart.begin();
2222

23-
Serial.println("RoboHeart MPU Demo");
23+
Serial.println("RoboHeart IMU Demo");
2424
}
2525

2626
void loop() {
@@ -45,9 +45,9 @@ void loop() {
4545

4646
Serial.print("\nThermometer:\n");
4747
Serial.print(" Degrees C = ");
48-
Serial.println(heart.imu.readTempC(), 4);
48+
Serial.println(heart.getTemperatureC(), 4);
4949
Serial.print(" Degrees F = ");
50-
Serial.println(heart.imu.readTempF(), 4);
50+
Serial.println(heart.getTemperatureF(), 4);
5151
F("=====================================================\n");
5252
prevPrintTime = millis();
5353
}

0 commit comments

Comments
 (0)