User Tools

Site Tools


arduino:hmc5983

HMC5983

magnetmeter

https://github.com/arduino/HMC5983

https://www.aliexpress.com/item/32697682602.html

http://arduinolearning.com/code/arduino-hmc5983-magnetometer-example.php

#include <HMC5983.h>
#include <Wire.h>
 
HMC5983 compass;
 
void setup () {
   Wire.begin(23, 19); //I2C setup
  Serial.begin(115200);
  compass.begin(true); // use "true" if you need some debug information
}
 
void loop() {
  float c = -999;
  c = compass.read();
  if (c == -999) {
    Serial.println("Reading error, discarded");
  } else Serial.println(c);
  //delay(500);
}
arduino/hmc5983.txt · Last modified: by aistis