Select your language

Ilmaga on nii nagu on ... 
1. Tuuesuund
Kompassi moodul CJMCU-008 (HSCDTD008A) (
https://forum.arduino.cc/index.php?topic=567313.0

Tundub, et 360 kraadi  <> 360 kraadi ....... kalibreerimine ?

3.3V !!

MCU          CJMCU-008
3.3V          VCC
GND          GND
GPI04        SCL
GPI05        SDA
// Deployed onto an EPS32
#include <Wire.h> //I2C Arduino Library
#define addr 0x0C //I2C Address
int16_t x;
int16_t y;
int16_t z;
int scale =1.0;
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Wire.begin(5,4);  // these are form my application on an ESP32 else simply use Wire.begin();
Wire.beginTransmission(addr); // Set up the registers
Wire.write(0x1B);
Wire.write(0x98); //0x9A
Wire.endTransmission();
Wire.beginTransmission(addr);
Wire.write(0x1C);
Wire.write(0x0C);
Wire.endTransmission();
Wire.beginTransmission(addr);
Wire.write(0x1E);
Wire.write(0x90);
Wire.endTransmission();
}

void loop() {
Wire.beginTransmission(addr);
Wire.write(0x10);
Wire.endTransmission();
Wire.requestFrom(addr, 6);

if (6 <= Wire.available()) {
x = Wire.read(); x |= Wire.read()<<8; x=x*scale;
y = Wire.read(); y |= Wire.read()<<8; y=y*scale;
z = Wire.read(); z |= Wire.read()<<8; z=z*scale;
 }
float bearing=((atan2(y,x))*180)/PI;//values will range from +180 to -180 degrees
 if (bearing < 0)  { bearing = 360 + bearing; }

// Show Values
Serial.print(" Bearing:> "); Serial.println(bearing);
delay(300);
}​