Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Black

CircuitPython library for DFROBOT Gravity: I2C to Dual UART Module

Gravity: I2C to Dual UART Module (SKU:DFR0627)

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install CircuitPython_DFRobot_Gravity_DRF0627_I2C_Dual_Uart

To install system-wide (this may be required in some cases):

sudo pip3 install CircuitPython_DFRobot_Gravity_DRF0627_I2C_Dual_Uart

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install CircuitPython_DFRobot_Gravity_DRF0627_I2C_Dual_Uart

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install CircuitPython_DFRobot_Gravity_DRF0627_I2C_Dual_Uart

Or the following command to update an existing version:

circup update

Usage Example

import time
import board
import CircuitPython_DFRobot_Gravity_DRF0627_I2C_Dual_Uart as DualUart

i2c = board.I2C()


iic_uart1 = DualUart.DFRobot_IIC_Serial(
    i2c,
    sub_uart_channel=DualUart.DFRobot_IIC_Serial.SUBUART_CHANNEL_1,
    IA1=1,
    IA0=1,
)

iic_uart2 = DualUart.DFRobot_IIC_Serial(
    i2c,
    sub_uart_channel=DualUart.DFRobot_IIC_Serial.SUBUART_CHANNEL_2,
    IA1=1,
    IA0=1,
)

try:
    iic_uart1.begin(baud=9600, format=iic_uart1.IIC_Serial_8N1)
    print("Opened: UART 1 ")
except Exception as e:
    iic_uart1 = None
    print("Error: Could not open UART 1 Exception: " + str(e))

try:
    iic_uart2.begin(baud=9600, format=iic_uart2.IIC_Serial_8N1)
    print("Opened: UART 2")
except Exception as e:
    iic_uart2 = None
    print("Error: Could not open UART 2 Exception: " + str(e))

sendID = 1
sendDelayCount = 1

while True:
    time.sleep(.3)
    sendDelayCount -= 1
    if sendDelayCount <= 0:
        sendDelayCount = 10
        iic_uart1.write("From1:" + str(sendID))
        iic_uart2.write("From2:" + str(sendID))

    if iic_uart1 is not None:
        if iic_uart1.available():
            s = ""
            while iic_uart1.available():
                b = iic_uart1.read(1)
                s += chr(b[0])
            print("<1:" + s + " len:" + str(len(s)) + ">")

    if iic_uart2 is not None:
        if iic_uart2.available():
            s = ""
            while iic_uart2.available():
                b = (iic_uart2.read(1))
                s += chr(b[0])
            print("<2:" + s + " len:" + str(len(s)) + ">")

Additional connection information

The DRF0627 comes with a cable that allows for connection to the CircuitPython hardware using a SparkFun STEMMA QT / Qwiic Breadboard Breakout Adapter Product ID: 4527 https://www.adafruit.com/product/4527

SparkFun STEMMA QT / Qwiic Breadboard Breakout Adapter

Connections:

Black wire -> Stemma Ground
Red wire -> Stemma 3.3 V
Green wire -> Stemma SDA
Blue wire -> Stemma SCA

To test the connection the “t” and “R” pins can be connected together. If you tie the “T” and “R” pins between the same UART the data will echo back to you on the same port. If you tie the “T” and “R” pins from UART1 to UART 2 data will be send between the two ports.

If RS485 is desired you can use a RS485 adapter such as the “SCM TTL to RS-485 Interface Module”

SCM TTL to RS-485 Interface Module

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Release files for circuitpython-dfrobot-gravity-drf0627-dual-uart 1.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for circuitpython-dfrobot-gravity-drf0627-dual-uart 1.0.14
File Size Uploaded
circuitpython_dfrobot_gravity_drf0627_dual_uart-1.0.14.tar.gz 34.0 kB Details

Release files / circuitpython_dfrobot_gravity_drf0627_dual_uart-1.0.14.tar.gz

Download URL circuitpython_dfrobot_gravity_drf0627_dual_uart-1.0.14.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d40734332fef73b3e657d73dcfd1fc4bf30b77ec40789328cd43933cb2687b68
BLAKE2b-256 checksum
How to use checksums
14430d660606e21be9262bb33fd84f4d83f76a1e18d928f217a7e5e34f0de163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.14 This release

1 release file

1.0.13

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page