95 lines
3.3 KiB
Markdown
Raw Normal View History

2021-01-29 12:31:58 +01:00
[![Arduino CI](https://github.com/RobTillaart/HMC6352/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-12-19 13:57:35 +01:00
[![Arduino-lint](https://github.com/RobTillaart/HMC6352/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/HMC6352/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/HMC6352/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/HMC6352/actions/workflows/jsoncheck.yml)
2021-01-29 12:31:58 +01:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/HMC6352/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/HMC6352.svg?maxAge=3600)](https://github.com/RobTillaart/HMC6352/releases)
2021-12-19 13:57:35 +01:00
2020-11-27 11:16:22 +01:00
# HMC6352
Arduino library for HMC6352 compass sensor
2021-12-19 13:57:35 +01:00
2020-11-27 11:16:22 +01:00
## Description
2021-01-29 12:31:58 +01:00
**BETA: WARNING: BETA: WARNING: BETA: WARNING: BETA:**
2020-11-27 11:16:22 +01:00
This library is BETA, only tested partially and not thoroughly
No guarantees, use at own risk, all disclaimers apply
2021-12-19 13:57:35 +01:00
The example sketch can be used to configuration the compass.
2021-06-07 18:21:42 +02:00
For switching operational mode one must reboot the device.
2020-11-27 11:16:22 +01:00
2021-01-29 12:31:58 +01:00
**WARNING: BETA: WARNING: BETA: WARNING: BETA: WARNING:**
2021-06-07 18:21:42 +02:00
## Interface
2021-01-29 12:31:58 +01:00
### Constructor
2021-06-07 18:21:42 +02:00
- **hmc6352(uint8_t address, TwoWire \*wire = &Wire)** set the I2C address and optional the Wire interface.
- **bool begin(uint8_t sda, uint8_t scl)** for ESP32 ea. Returns true if address can be seen on the I2C bus.
- **bool begin()** for UNO, Returns true if address can be seen on the I2C bus.
- **bool isConnected()** Returns true if address can be seen on the I2C bus. Can be used as 1st order diagnostics.
2021-01-29 12:31:58 +01:00
### Base calls standby mode
2021-06-07 18:21:42 +02:00
- **int getHeading()** is a combination of **askHeading()** and **readHeading()**
- **int askHeading()** requests a new read of the heading (compass direction).
- **int readHeading()** reads the new value from the device.
- **int wakeUp()** if the deivice is in sleep mode, wake it up.
- **int sleep()** puts the device in sleep mode.
2021-01-29 12:31:58 +01:00
### Expert calls
2021-06-07 18:21:42 +02:00
Warning: use with care: read the datasheet for the details
- **int factoryReset()** idem
- **int setOperationalModus(hmcMode mode, uint8_t frequency, bool periodicReset)**
2021-01-29 12:31:58 +01:00
- **int getOperationalModus()**
2021-06-07 18:21:42 +02:00
- **int setOutputModus(uint8_t outputModus)**
2021-01-29 12:31:58 +01:00
- **int getOutputModus()**
2021-06-07 18:21:42 +02:00
- **int callibrationOn()**
- **int callibrationOff()**
- **int setI2CAddress(uint8_t address)** writes the I2C address in EEPROM to use after the next reboot.
- **int getI2CAddress()** reads the I2C address stored in EEPROM.
### Helper functions
Warning: use with care: read the datasheet for the details
- **int writeEEPROM(uint8_t address, uint8_t data)** EEPROM IO function
- **int readEEPROM(uint8_t address)** EEPROM IO function
- **int writeRAM(uint8_t address, uint8_t data)** RAM IO function
- **int readRAM(uint8_t address)** RAM IO function
2021-01-29 12:31:58 +01:00
- **int saveOpMode(byte OpMode)** allow power users to set operational mode flags
2021-06-07 18:21:42 +02:00
### NOT TESTED
Warning: use with care: read the datasheet for the details
2021-01-29 12:31:58 +01:00
2021-06-07 18:21:42 +02:00
- **int setTimeDelay(uint8_t milliSeconds)**
2021-01-29 12:31:58 +01:00
- **int getTimeDelay()**
2021-06-07 18:21:42 +02:00
- **int setMeasurementSumming(uint8_t NrOfMeasurements)** 1..16
- **int getMeasurementSumming()** returns 1..16
2021-01-29 12:31:58 +01:00
- **int updateOffsets(void)**
2020-11-27 11:16:22 +01:00
## Operation
See examples
2021-12-19 13:57:35 +01:00
## Future
- update documentation
- testing AVR
- testing ESP32
- test examples => more specific?