Peter Valencic Posted February 14, 2017 Share Posted February 14, 2017 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 ) 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 Link to comment Share on other sites More sharing options...
martinayotte Posted February 14, 2017 Share Posted February 14, 2017 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 1 Link to comment Share on other sites More sharing options...
Peter Valencic Posted February 15, 2017 Author Share Posted February 15, 2017 Thank you! will try it.. Link to comment Share on other sites More sharing options...
tcmichals Posted February 15, 2017 Share Posted February 15, 2017 Would it just easier to use serial over USB and use the DFU to upload firmware? Link to comment Share on other sites More sharing options...
martinayotte Posted February 15, 2017 Share Posted February 15, 2017 His goal wasn't to upload firmware, but to do serial communication between OPi and Arduino. Link to comment Share on other sites More sharing options...
Peter Valencic Posted February 16, 2017 Author Share Posted February 16, 2017 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 Link to comment Share on other sites More sharing options...
ezpl Posted March 18, 2017 Share Posted March 18, 2017 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 Link to comment Share on other sites More sharing options...
martinayotte Posted March 18, 2017 Share Posted March 18, 2017 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 Link to comment Share on other sites More sharing options...
Tony Weston Posted March 20, 2017 Share Posted March 20, 2017 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 Link to comment Share on other sites More sharing options...
Recommended Posts