Jump to content


Photo

OrangePi PC GPIO UART and Arduino


  • Please log in to reply
5 replies to this topic

#1 Peter Valencic

Peter Valencic

    Member

  • Senior Members
  • PipPip
  • 14 posts

Posted 14 February 2017 - 09:32 PM

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/d...pi_PC_gpio_pyH3



#2 martinayotte

martinayotte

    Advanced Member

  • Senior Members
  • PipPipPip
  • 442 posts

Posted 15 February 2017 - 12:05 AM

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

#3 Peter Valencic

Peter Valencic

    Member

  • Senior Members
  • PipPip
  • 14 posts

Posted 15 February 2017 - 06:51 AM

Thank you! 

will try it.. 



#4 tcmichals

tcmichals

    Member

  • Senior Members
  • PipPip
  • 12 posts

Posted 15 February 2017 - 03:48 PM

Would it just easier to use serial over USB and use the DFU to upload firmware? 



#5 martinayotte

martinayotte

    Advanced Member

  • Senior Members
  • PipPipPip
  • 442 posts

Posted 15 February 2017 - 04:24 PM

His goal wasn't to upload firmware, but to do serial communication between OPi and Arduino.



#6 Peter Valencic

Peter Valencic

    Member

  • Senior Members
  • PipPip
  • 14 posts

Posted 16 February 2017 - 09:28 AM

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