2016-06-05 22:59:39 +02:00
|
|
|
# HMC5883L Module
|
|
|
|
| Since | Origin / Contributor | Maintainer | Source |
|
|
|
|
| :----- | :-------------------- | :---------- | :------ |
|
2019-01-13 22:01:57 +01:00
|
|
|
| 2016-04-09 | [Jason Schmidlapp](https://github.com/jschmidlapp) | [Jason Schmidlapp](https://github.com/jschmidlapp) | [hmc5883l.c](../../app/modules/hmc5883l.c)|
|
2016-06-05 22:59:39 +02:00
|
|
|
|
|
|
|
|
2016-06-05 23:42:21 +02:00
|
|
|
This module provides access to the [HMC5883L](https://www.sparkfun.com/products/10530) three axis digital compass.
|
2016-06-05 22:59:39 +02:00
|
|
|
|
|
|
|
## hmc5883l.read()
|
|
|
|
Samples the sensor and returns X,Y and Z data.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
`hmc5883l.read()`
|
|
|
|
|
|
|
|
#### Returns
|
|
|
|
x,y,z measurements (integers)
|
|
|
|
temperature multiplied with 10 (integer)
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
```lua
|
2017-05-21 16:17:29 +02:00
|
|
|
local sda, scl = 1, 2
|
|
|
|
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
|
2017-08-05 22:10:49 +02:00
|
|
|
hmc5883l.setup()
|
2016-06-05 22:59:39 +02:00
|
|
|
local x,y,z = hmc5883l.read()
|
|
|
|
print(string.format("x = %d, y = %d, z = %d", x, y, z))
|
|
|
|
```
|
|
|
|
|
2017-05-21 16:17:29 +02:00
|
|
|
## hmc5883l.setup()
|
|
|
|
Initializes the module.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
`hmc5883l.setup()`
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
None
|
|
|
|
|
|
|
|
#### Returns
|
|
|
|
`nil`
|