Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Sending Data from Beaglebone Black to Arduino Through UART (Part 7/15)

By Ashish Vara

This tutorial represents communication between Beaglebone black and Arduino through UART.  You don’t need any another peripheral for this tutorial. UART stands for universal asynchronous receiver and transmitter.  It transmits and receives data asynchronously with another device which also supports UART protocol.

Required Tools:

  • Beaglebone Black
  • Arduino
  • Female to Female connectors

Setup of Software environment

Install the latest python version in BBB as explained in tutorial How to make first python program with Beaglebone Black. Install the adafruit python-GPIO library.

Working

Beaglebone transmits the message which is entered from command prompt and Arduino receives the data and displays it on Arduino serial terminal. Run the python script from SSH terminal and at the same time open Arduino serial in PC. Write some message from SSH terminal. BBB transfers the data through UART which is then received by Arduino and displayed on serial terminal. 

Description

BBB has on chip five UART ports each containing two pins: RX pin and TX pin  to receive and transmit respectively. In this tutorial, UART1 is used for communication with Arduino. Here, BBB acts as transmitter and Arduino as receiver. Connect the UART1 transmitting pin (24th pin of header P9) of BBB to receiving pin (pin number 10th) of Arduino.  I have used software UART in Arduino that’s why I have connected it with pin number 10th (I declared 10th and 11th pin as RX and TX in program respectively). Make the common ground connection between Arduino and BBB  which is necessary for communication.

Open the command terminal and  access Beaglebone black through SSH as explained in getting started with Beaglebone black. Create a new file using touch command with .py extension (i.e. led.py). Open the file with any text editor (i.e. nano, vim etc.) and write a code in python language.

Connect Arduino with PC through USB cable. Open  it and then write a code for receiving data in C language. For help, you may  refer to the tutorial how to Install and run Arduino in Linux.

UART setup in BBB

You need to import UART in program to make use of I2C device. You can create your own library but that would consume more time. Hence Ad fruit library can be used that provides all kind of python library of BBB.

import Adafruit_BBIO.UART as UART

Also import the serial from python library. It encapsulates access  to serial port.

import serial

Configure UART by following function:

UART.setup(“UART1”)

serial.Serial (port = “/dev/ttyO1”, baudrate=9600)

First function is setup and configuration of UART1. Second function accesses the serial device with defined baud rate. Find the device port attached with UART from  the list below and access it.

Magnetometer interfacing with Beaglebone black

Now, you can transmit and receive data through UART. You can close the port when you don’t want to use it.

Arduino Setup

Write a receiving source code in Arduino and load it  onto Arduino Uno.  After the data is received, it will be displayed on the serial terminal.

Run the script from terminal:

Enter the following command with file name from command prompt:

            python filename.py

i.e. python uart.py

Project Source Code

 

Project Source Code

###

// UART.C

#include <SoftwareSerial.h>

 
SoftwareSerial uart(10,11);
 
 
void setup()
{
  Serial.begin(9600);
  uart.begin(9600);
  
}
 
void loop()
{
 
  if(uart.available() > 0)
  {
    Serial.write(uart.read());
  }
 
}
 
//
 
import Adafruit_BBIO.UART as UART
 
import serial
 
UART.setup("UART1")
 
disp = serial.Serial (port = "/dev/ttyO1", baudrate=9600)
 
disp.close()
disp.open()
 
while True:
        if disp.isOpen():
 
                print "Serial is Openn"
                message = raw_input("Enter your message:n")
 
                disp.write(message)
                disp.write("n")
 
                exit = raw_input("You want to exit or not YN:")
 
                while ((exit != 'Y') and (exit != 'N') and (exit != 'y') and (exit != 'n')):
 
                        print "Invalid Input!!!n"
 
                        exit = raw_input("You want to exit or not YN:")
 
 
                if (exit == 'Y') or (exit == 'y'):
                        break
 
                else:
                        print "To be continue....n"
 
 
print "Sorry!!! You not able to do communicate with device"
disp.close()

###

 


Circuit Diagrams

data-from-beaglebone-arduino-using-UART

Project Video


Filed Under: Electronic Projects

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Fpga wake up
  • Code Optimization
  • Avalanche Pulser
  • Pull up via GPIO
  • Poly Spacing Effect

RSS Electro-Tech-Online.com Discussions

  • Someone please explain how this BMS board is supposed to work?
  • HV Diodes
  • Question about ultrasonic mist maker
  • DIY bluetooth speaker
  • Disabled son needs advice please
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering