OrangePi PC GPIO UART and Arduino
1 1

9 posts in this topic

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

Share this post


Link to post
Share on other sites

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
zgoda_j likes this

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
1 1

  • Support the project

    We need your help to stay focused on the project.

    Choose the amount and currency you would like to donate in below.