mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
Fix incorrect factor for value calculation in MMC5603 component (#9925)
This commit is contained in:
@@ -128,21 +128,21 @@ void MMC5603Component::update() {
|
||||
raw_x |= buffer[1] << 4;
|
||||
raw_x |= buffer[2] << 0;
|
||||
|
||||
const float x = 0.0625 * (raw_x - 524288);
|
||||
const float x = 0.00625 * (raw_x - 524288);
|
||||
|
||||
int32_t raw_y = 0;
|
||||
raw_y |= buffer[3] << 12;
|
||||
raw_y |= buffer[4] << 4;
|
||||
raw_y |= buffer[5] << 0;
|
||||
|
||||
const float y = 0.0625 * (raw_y - 524288);
|
||||
const float y = 0.00625 * (raw_y - 524288);
|
||||
|
||||
int32_t raw_z = 0;
|
||||
raw_z |= buffer[6] << 12;
|
||||
raw_z |= buffer[7] << 4;
|
||||
raw_z |= buffer[8] << 0;
|
||||
|
||||
const float z = 0.0625 * (raw_z - 524288);
|
||||
const float z = 0.00625 * (raw_z - 524288);
|
||||
|
||||
const float heading = atan2f(0.0f - x, y) * 180.0f / M_PI;
|
||||
ESP_LOGD(TAG, "Got x=%0.02fµT y=%0.02fµT z=%0.02fµT heading=%0.01f°", x, y, z, heading);
|
||||
|
||||
Reference in New Issue
Block a user