Skip to content

improving_docs #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions adafruit_mlx90614.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
https://circuitpython.org/downloads
"""

from micropython import const
Expand Down Expand Up @@ -72,14 +72,37 @@


class MLX90614:
"""Create an instance of the MLX90614 temperature sensor. You must pass in
the following parameters:
- i2c: An instance of the I2C bus connected to the sensor.
- frequency=100000 - this sensor does not respond to the default 400000 i2c bus speed
"""Create an instance of the MLX90614 temperature sensor.

Optionally you can specify:
- address: The I2C address of the sensor.
If not specified the sensor's default value will be assumed."""
:param ~busio.I2C i2c_bus: The I2C bus the MLX90614 is connected to.
frequency=100000 - this sensor does not
respond to a 400000 i2c bus speed
:param int address: I2C device address. Defaults to :const:`0x5A`.

**Quickstart: Importing and using the MLX90614**

Here is an example of using the :class:`MLX90614` class.
First you will need to import the libraries to use the sensor

.. code-block:: python

import board
import adafruit_mlx90614

Once this is done you can define your `board.I2C` object and define your sensor object

.. code-block:: python

i2c = board.I2C()
mlx = adafruit_mlx90614.MLX90614(i2c)

Now you have access to the :attr:`ambient_temperature` attribute

.. code-block:: python

temperature = mlx.ambient_temperature

"""

def __init__(self, i2c_bus, address=_MLX90614_I2CADDR):
self._device = i2c_device.I2CDevice(i2c_bus, address)
Expand All @@ -88,12 +111,12 @@ def __init__(self, i2c_bus, address=_MLX90614_I2CADDR):

@property
def ambient_temperature(self):
"""Ambient Temperature in celsius."""
"""Ambient Temperature in Celsius."""
return self._read_temp(_MLX90614_TA)

@property
def object_temperature(self):
"""Object Temperature in celsius."""
"""Object Temperature in Celsius."""
return self._read_temp(_MLX90614_TOBJ1)

def _read_temp(self, register):
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Table of Contents
.. toctree::
:caption: Tutorials

https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/DIY_Thermal_Light_Painting
Using Melexis MLX90614 Non-Contact Sensors Learning Guide <https://learn.adafruit.com/using-melexis-mlx90614-non-contact-sensors>

.. toctree::
:caption: Related Products
Expand Down
6 changes: 2 additions & 4 deletions examples/mlx90614_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
# products from Adafruit!

import board
import busio as io
import adafruit_mlx90614

# the mlx90614 must be run at 100k [normal speed]
# i2c default mode is is 400k [full speed]
# the mlx90614 will not appear at the default 400k speed
i2c = io.I2C(board.SCL, board.SDA, frequency=100000)
# the mlx90614 will not appear at the 400k speed
i2c = board.I2C()
mlx = adafruit_mlx90614.MLX90614(i2c)

# temperature results in celsius
Expand Down