Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

OrangePi PC GPIO UART and Arduino

Featured Replies

Hi,

I have a project to do and this consists of:

Arduino board which work as frequency counter and OrangePi PC which will be some kind of server (mysql, python).

The idea is to use UART port to communicate (send / recevie) datas from arduino to OrangePi using C, Java or python..

 

Here is my schema using LLC (converter between arduino and orangePC) (hope this will work :) )

screenshot_190.jpg

 

 

Is there some example in C, python or java on how to use GPIO UART pin 8/10 on orangepi as serial port?

 

For now I have installed library from: https://github.com/zhaolei/WiringOP

and second for python from: https://github.com/duxingkei33/orangepi_PC_gpio_pyH3

For UARTs, you don't need those library, you only need to access kernel serial device, such /dev/ttyS1, using python-serial.

 

For example, the following piece of code will print any character received on RX :

import serial

serport = serial.Serial("/dev/ttyS1", 115200, timeout=1)
while True:
    while serport.inWaiting() > 0:
        c = serport.read()
        print c
  • Author

Jap.. my goal is to have Arduino connected over Gpio to orangpi pc.. (using pin 8 and 10).

I'am using arduino to measure frequency up to 15 kHz (have some temp/salinity sensors which gives me frequency on the output). The measured frequency  is then send over serial port to "third" components in my case will be Orangepi..

 

 

I have experience with Java so I think I can use RxTx library to read data from serial port ( /dev/ttyS3)? 

 

$ sudo apt-get install librxtx-java

On 15/02/2017 at 0:05 AM, martinayotte said:

For UARTs, you don't need those library, you only need to access kernel serial device, such /dev/ttyS1, using python-serial.

 

For example, the following piece of code will print any character received on RX :


import serial

serport = serial.Serial("/dev/ttyS1", 115200, timeout=1)
while True:
    while serport.inWaiting() > 0:
        c = serport.read()
        print c

 

Thanks for the tip!

I'm on Orange Pi Zero running  4.10.1-sun8i 

After importing pySerial, I tested this code:

import serial

port = serial.Serial("/dev/ttyS1", 115200, timeout=1)
print(port.name)

Unfortunately it fails with 'serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')'

 

Listing the ports using:  python -m serial.tools.list_ports , results in "no ports found"

 

I also tried adding the port using overlays as suggested in this post : https://forum.armbian.com/index.php?/topic/3651-uart-on-orange-pi-zero/#comment-26402

 

 

Any other suggestions?

 

Thanks,

 

ezpl

You've probably missed some steps about overlays.

Try manually the following steps, although not the same way as described in the above post :

mkdir /sys/kernel/config/device-tree/overlays/uart1
cat /boot/dtb/overlay/sun8i-h3-uart1.dtbo > /sys/kernel/config/device-tree/overlays/uart1/dtbo
python
import serial
port = serial.Serial("/dev/ttyS1", 115200, timeout=1)
while True:
    while serport.inWaiting() > 0:
        c = serport.read()
        print c

 

Have you enabled the UART port on the pi?

 

You need to update the pi's boot script to do this. Checking back in the forums, I find these instructions:

 

Also,  

 1) If you use a 8mhz arduino, these run on 3.3 volts, so you dont need the level converter.

 2) If you use the arduino software serial library, this lets you continue to use the built in serial on pins 0 and 1, for uploading and debugging your code on the arduino side.  Makes things easier to develop. https://www.arduino.cc/en/Reference/softwareSerial

 

 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.