Project tutorial
Interfacing Arduino Uno & Onion Omega 2

Interfacing Arduino Uno & Onion Omega 2

Interfacing Arduino and Onion Omega2 IoT platform will make creating connected devices easier!

  • 52 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

One of the method of communicating between the Omega and the microcontroller ATmega is through the serial interface UART (Universal Asynchronous Receiver/Transmitter)

The UART connection provides two-way communication using three pins on the Omega: TXD (transmitting data from Omega) and RXD (receiving data from ATmega) and one for common ground.

In order to communicate between Omega and the ATmega, we use command line or python script to send and receive data on the Omega. On the ATmega side, we flash the micro-controller with a sketch to read and write data.

One important thing to note is the baud rate, which is the rate at which the data is transferred in bits per second. The baud rate can be varied but the Omega and the ATmega UART must be programmed to have the same baud rate.

However, when it comes to powering !, in the case of the Arduino Uno and Omega2, we will be using a 3.3v Power Supply, This is just to avoid damaging the Omega2, as the Omega2 it cannot tolerate anything above 3.3v as an input.

Code

Flashing the ArduinoArduino
First we need to flash the arduino with a sketch that is programmed to communicate (read and/or write data) using serial communication on pins TX/RX .

We will use the Arduino serial library to send data back and forth. Here’s a very simple example sketch that will make the arduino continously send out “arduino”
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("arduino");
  delay(100);
}
Arduinoreadfromomega.inoArduino
Here is an example arduino program that will make the arduino continuously read from the Omega , Only after it reads the string “ArduinOnion”, it will send out the string “Received” to the Omega:
String readSerial;

void setup() {
  // start serial for output at baud rate 9600
  Serial.begin(9600);
}

void loop() {
  delay(100);
  // wait until there's serial data available
  if (Serial.available() > 0) {
    readSerial = Serial.readString();

    // check is the received data is "ArduinOnion"
    if (readSerial == "ArduinOnion") {
      Serial.print("Received");       // send the string "Received" to the Omega
      readSerial = "";
    }
  }
}
PythOnionPython
Here is some example Python code that will make the Omega continuously send “ArduinOnion” until it reads the response “Received” from the micro-controller. In order for this to work correctly, your micro-controller will have to be flashed with the example Serial sketch I've introduced above.
                        import serial

                        response = ""
                while (response != "Received"):
                  
                        # Setup serial
  ser = serial.Serial(port = '/dev/ttyS1', baudrate = 9600, timeout = 2)

                     # Write string on UART1
                     ser.write("ArduinOnion")

                   # Read 8 byte response
                     response = ser.read(8)
                     ser.cancel_read()
                     print repr(response)

            print "Received ArduinOnion from the microcontroller!"

Custom parts and enclosures

Components Required
Airbrush 20191115192337 crp77drd4u

Schematics

Assembling Hardware
3.3V supply (+) - 3.3v input Onion omega
3.3v supply (-) - GND onion omega
Gnd Arduino - GND onion omega
Tx arduino - Rx onion omega
Rx arduino - Tx onion omega
Airbrush 20191115220050 shqqqjk5yh
Datasheet Onion Omega
Datasheet gz8nfizunr

Comments

Similar projects you might like

XBee Arduino Interfacing

Project tutorial by Fouad_Roboticist

  • 1,286 views
  • 4 comments
  • 5 respects

16x2 LCD Backpack with Enclosure for the Onion Omega

Project in progress by Carlos Silva

  • 5,397 views
  • 5 comments
  • 18 respects

Embedis : Arduino Uno Keystore

Project tutorial by thingSoC

  • 2,213 views
  • 0 comments
  • 3 respects

Simple UNO calculator

Project tutorial by Joprp05

  • 15,237 views
  • 2 comments
  • 16 respects
Add projectSign up / Login