Interfacing the Onion Omega2 and Arduino Uno via UART

Interfacing the Onion Omega2 and Arduino Uno via UART

Bring the versatility of the Arduino Uno to the powerful world of IoT with the Onion Omega board. Make any Arduino project IoT compatible.

  • 21 respects

Components and supplies

Apps and online services

About this project

Project Overview

After learning that both the well-known Arduino board and the world's most affordable Linux device, the Omega2 support UART protocol, I decided to interface the two devices and take advantage of the best of both worlds. Once implemented, this allows you to create projects entirely based on Arduino and then make them could-compatible through the Onion Omega2 or Omega2+. An example would be an Arduino based robot with the power of AWS behind it.

UART or Universal Asynchronous Receiver/Transmitter is a form of 1-to-1 serial communication, which relies on three connections between the two devices. One to transmit data, one to receive data and one for common ground. The below diagram demonstrates this. However in the case of the Arduino Uno and Omega2, we will be using a simple voltage divider circuit as well. This is just to avoid damaging the Omega2's internal circuitry, as the Omega2 cannot tolerate anything above 3.3v as an input.

Step 1: The Hardware

Wire the below circuit on a prototyping board. You will need two resistors (3.3 k and 1.7 k) and of course your Arduino Uno board as well as the Omega2. While the expansion dock for Omega2 is not required, it would make the wiring easier. If you don't have one, follow the instructions here.

Step 2: Power On

Connect the Arduino Uno board to your computer's USB port. Then power up the Omega2 board.

Step 3: Program

Open the Arduino IDE and program the Arduino Uno board with the provided code in the "Code" section titled "arduino_serial.ino". The Arduino board is now ready and configured.

Step 4: Test

To test the serial communication, we will be using the 'screen' command on the Omega2 side and the 'serial monitor' tool on the Arduino IDE. On the Arduino IDE click on Tools > Serial Monitor.

To program the Omega2, you can either ssh to your device or use Omega's terminal utility through your web browser. For more information on setting up the Omega2, take a look at the Omega2 documentation.

On the Omega2 terminal, type in these commands to install the screen tool.

opkg update
opkg install screen

Now use the following command to monitor the serial port connected to the Arduino board.

screen /dev/ttyS1 9600

Once you run the command, a blank screen will open. When you type something in this screen, it is sent to the Arduino and should be displayed on the Serial Monitor window. Likewise, if you send a message using Arduino's Serial Monitor tool, you should see this message appear on the blank window.

Congratulations! You have now successfully established the UART link between the two devices.

For a more thorough overview of Omega's UART capabilities, click here.

Step 5: Using pySerial

In a more practical scenario, you would interact with the Arduino board through a Python script. The pySerial library allows you to achieve this. For instance, you may be reading sensor values through the script and you may wish to send those values to an IoT cloud platform, such as AWS through MQTT protocol.

To demonstrate this, I have written a very simple Python script (, that reads one-digit integers from the Arduino board and displays them on the screen. Feel free to experiment with this code and use it as a template for your projects.


This it the code for programming the Arduino Uno board to setup the UART communication. This code monitors the receiving pin of the arduino and relays the messages to the USB serial port (which can be viewed using the "serial monitor" tool of the Arduino IDE). Additionally, the code relays messages sent from the serial monitor tool to the programmed transmitter port of the Arduino, which means you can use the serial monitor tool to send messages to the Omega2. In a more practical setup, you would send those values directly to the transmitter pin for delivery to the Omega2.
#include <SoftwareSerial.h>

SoftwareSerial gtSerial(8, 7); // Arduino RX, Arduino TX

void setup() {
  Serial.begin(9600);    // serial / USB port
  gtSerial.begin(9600);  // software serial port

byte rx_byte = 0;        // stores received byte

void loop() {
  // check if byte available from USB port
  if (Serial.available()) {
    rx_byte =;
    // send a byte to the software serial port

  // check if byte available on the software serial port
  if (gtSerial.available()) {
    // get the byte from the software serial port
    rx_byte =;
This is a Python script for monitoring the receiver pin of the Omega2, when interfacing with the Arduino Uno board. Please note: this is just a sample code that receives one-digit integers. This will have to be modified to work with your specific application. For instance, you may want to implement a send function to send commands to the Arduino board or add cloud connectivity to the code using MQTT.
import serial

ser = serial.Serial('/dev/ttyS1', 9600, timeout = None)

while True:
        input =


Hardware setup
Untitled sketch 2 bb1 uisshdn44n


Similar projects you might like

16x2 LCD Backpack with Enclosure for the Onion Omega

Project in progress by Carlos Silva

  • 18 respects

Programming ATtiny13 with Arduino Uno

by Tauno Erik

  • 32 respects

Control Arduino Uno Using ESP8266 WiFi Module and Blynk App

Project tutorial by Adithya TG

  • 46 respects

Interfacing Nokia 5110 LCD with Arduino

by Aqib

  • 9 respects
Add projectSign up / Login