Enable UART on Cubieboard with Lubuntu

I wanted to connect my cubieboard with lubuntu to my arduino via serial communication. For that I had to enable a UART and connect pins to my arduino (only RX/TX is needed). I have arduino mini 3.3V on which I have attached some sensors (outside temperature).
By this command you can check if the port is enabled:

stty -F /dev/ttyS0 -a

In fresh installation of lubuntu the ttyS0 is configured and used by kernel and ttyS1 is not enabled. You will get this message for ttyS1:

stty: /dev/ttyS1: Input/output error

I followed the how-to by cubieboard.

sudo mount /dev/nanda /mnt
cd /mnt
sudo bin2fex script.bin script.fex
sudo vi script.fex

I changed only 1 uart – I selected the one that is using only 2 pins uart_para4:

[uart_para4]
uart_used = 1
uart_port = 4
uart_type = 2
uart_tx = port:PG10<4><1><default><default>
uart_rx = port:PG11<4><1><default><default>

I use mc for as easy text editor

save and convert fex file back to bin file:

sudo fex2bin script.fex script.bin

restart to have new UART visible in lubuntu:

sudo reboot

You can find the pin definition on cubie site.

For my case I have configured in script.fex file port PG10 as tx and PG11 as rx which are pins 17 and 18 on the connector on USB side.

17PG10 (CSI1-D6/UART4-TX)18PG11 (CSI1-D7/UART4-RX)

 

I have attached cables (I have 2.54mm ones, but they somehow fit). I used 3.3V from the front side of cubieboard but I could used also PIN 44 next to SATA port.

Pin 17/18 for RX/TX and PIN19 for GND

Arduino mini pro 3.3V

The device number of ttySx depends on how many uarts you have opened. In my case I have opened uart0 and uart4, so the uart4 is mapped to the device ttyS1.

To test my changes I used utility called “cu” that I have installed and started on ttyS1 with 9600 baud rate.

 

sudo apt-get install cu
cu -s 9600 -l /dev/ttyS1

Arduino was programmed to send me outside temperature (in C) and humidity so I started to receive data.

Now I will setup a crontab and a web server to have history of temperature available on the internet. I will do another post, because it took me a while to create such graph on my web page hosted on Cubieboard2 with Apache.

Outside temperature for last 4 days using Google charts API


Related Posts

Cubieboard2 – Lubundu – Extending NAND from 2GB to 4GB

NAND

When I install new Lubuntu NAND image to my new Cubieboard2 I had only 2GB of space out of 4GB available. I followed this forum to expand the filesystem to 4GB. In my case I[…]

Continue reading ...

DLNA media server on Cubieboard with Lubuntu

DLNA_logo

I have installed Lubuntu on my new Cubieboard 2. I have also attached HDD to SATA so I have more space to store my media. This posts describes the steps needed to install and configure[…]

Continue reading ...

Upgrade Ubuntu 12.10 (Linaro 13.04) to Ubuntu 13.10 (Linaro 14.01) and later to Ubuntu 14.04 LTS

Ubuntu_Update

I wanted to keep my existing configuration and programs on my Cubieboard2 with Linaro Lubuntu, but at the same I wanted to upgrade the packages since the Lubuntu 12.10 is quite outdated. This post describes[…]

Continue reading ...