Skip to content

adding temperature reading #35

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
Feb 17, 2023
Merged

adding temperature reading #35

merged 2 commits into from
Feb 17, 2023

Conversation

jposada202020
Copy link
Contributor

PR is to add the ability to read the temperature provided by the sensor. solves #32

Dessign Choices

  1. I did not include the temperature as a @Property as the library is already big, and I do no beleive that the purpose of the sensor is to measure temperature.
  2. We could read the 4 values at the same time changing _CMD_AXIS_ALL to = const(0xF) , and give them to the user, however I choose not to, because sensor application. Temeprature will need to read register 0x24 adding time to get the value.
  3. Put the temperature reading as a optional for folks that would need it

PR could be test using the following script

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import adafruit_mlx90393

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
SENSOR = adafruit_mlx90393.MLX90393(i2c, gain=adafruit_mlx90393.GAIN_1X)


while True:
    MX, MY, MZ = SENSOR.magnetic
    print("X: {} uT".format(MX))
    print("Y: {} uT".format(MY))
    print("Z: {} uT".format(MZ))

    # Display the status field if an error occured, etc.
    if SENSOR.last_status > adafruit_mlx90393.STATUS_OK:
        SENSOR.display_status()
    print("Temperature: {}C".format(SENSOR.read_temp()))
    # Display the status field if an error occured, etc.
    if SENSOR.last_status > adafruit_mlx90393.STATUS_OK:
        SENSOR.display_status()
    time.sleep(1.0)

@jposada202020 jposada202020 requested a review from a team February 16, 2023 13:23
@tekktrik tekktrik linked an issue Feb 16, 2023 that may be closed by this pull request
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make it a property so it is consistent with other libraries. It shouldn't be much bigger as a property.

@jposada202020
Copy link
Contributor Author

Will do :). Thanks

@jposada202020
Copy link
Contributor Author

Added as a property and included an example to test and further reference

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit a1546a6 into adafruit:main Feb 17, 2023
@jposada202020 jposada202020 deleted the adding_temp branch February 17, 2023 18:30
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 18, 2023
Updating https://github.com/adafruit/Adafruit_CircuitPython_MLX90393 to 2.1.0 from 2.0.16:
  > Merge pull request adafruit/Adafruit_CircuitPython_MLX90393#35 from jposada202020/adding_temp
  > Add upload url to release action
  > Add .venv to .gitignore

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could you please include temperature reading
2 participants