Skip to content

Adding learning guide, changing references to board.I2C #5

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 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ Usage Example
.. code-block:: python

import time
import busio
import board
import adafruit_sht4x

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sht = adafruit_sht4x.SHT4x(i2c)
print("Found SHT4x with serial number", hex(sht.serial_number))

Expand Down
11 changes: 5 additions & 6 deletions adafruit_sht4x.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,25 @@ class SHT4x:
"""
A driver for the SHT4x temperature and humidity sensor.

:param ~busio.I2C i2c_bus: The `busio.I2C` object to use.
:param int address: The I2C device address for the sensor. Default is :const:`0x44`
:param ~busio.I2C i2c_bus: The I2C bus the SHT4x is connected to.
:param int address: The I2C device address. Default is :const:`0x44`


**Quickstart: Importing and using the SHT4x temperature and humidity sensor**

Here is one way of importing the `SHT4x` class so you can use it with the name ``sht``.
Here is an example of using the :class:`SHT4x`.
First you will need to import the libraries to use the sensor

.. code-block:: python

import busio
import board
import adafruit_sht4x

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

.. code-block:: python

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sht = adafruit_sht4x.SHT4x(i2c)

You can now make some initial settings on the sensor
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit Sensirion SHT40 Temperature & Humidity Sensor <https://learn.adafruit.com/adafruit-sht40-temperature-humidity-sensor>

.. toctree::
:caption: Related Products

Expand Down
3 changes: 1 addition & 2 deletions examples/sht4x_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
# SPDX-License-Identifier: MIT

import time
import busio
import board
import adafruit_sht4x

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
sht = adafruit_sht4x.SHT4x(i2c)
print("Found SHT4x with serial number", hex(sht.serial_number))

Expand Down