CircuitPython library for the DF DFRobot_Gravity_DRF0627_Dual_Uart
Project description
Introduction
CircuitPython library for DFROBOT Gravity: I2C to Dual UART Module
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
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”
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file circuitpython_dfrobot_gravity_drf0627_dual_uart-1.0.14.tar.gz
.
File metadata
- Download URL: circuitpython_dfrobot_gravity_drf0627_dual_uart-1.0.14.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d40734332fef73b3e657d73dcfd1fc4bf30b77ec40789328cd43933cb2687b68 |
|
MD5 | d280074944c80f8b9a591bf2796c23cb |
|
BLAKE2b-256 | 14430d660606e21be9262bb33fd84f4d83f76a1e18d928f217a7e5e34f0de163 |