Envio de dados do Beaglebone Black para Arduino por meio de UART (Parte 7/15)

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

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

Required tools :

  • Black Beaglebone
  • Arduino
  • Female to female connectors

Software environment configuration

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

Working

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

Description

BBB has five UART ports on the chip, each containing two pins: RX pin and TX pin for receiving and transmitting, respectively. In this tutorial, UART1 is used to communicate with Arduino. Here, the BBB acts as the transmitter and the Arduino as the receiver. Connect the UART1 transmit pin (24th pin of P9 header) of the BBB to the receive pin ( 10th pin number) of the Arduino. I used UART software on Arduino, so I connected it to pin number 10th (I declared 10th and 11th pin as RX and TX in the program respectively). Make the common ground connection between the Arduino and the BBB, 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 play command with .py extension (i.e. led.py). Open the file with any text editor (i.e. nano, vim etc.) and write code in python language.

Connect the Arduino to the PC via the USB cable. Open it and write code to receive data in C language. For help, you can refer to the tutorial how to install and run Arduino on Linux.

UART configuration on BBB

You need to import the UART into the program to use the I2C device. You can create your own library, but it would be more time consuming. Therefore, the Ad Fruit library can be used, which provides all types of BBB's python library.

import Adafruit_BBIO.UART as UART

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

import series

Configure the UART by following the function:

UART.setup (“UART1”)

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

The first function is installation and configuration of UART1. The second function accesses the serial device with defined baud rate. Find the device port connected to UART in the list below and access it.

Magnetômetro em interface com Beaglebone preto

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

Arduino Setup

Write receiver source code on Arduino and upload it to Arduino Uno. After receiving the data, it will be displayed on the serial terminal.

Run the script in the terminal:

Enter the following command with the file name at the command prompt:

python.py file name

i.e. python uart.py

Project source code

Project source code

###

 // UART.C

#include

SoftwareSerial uart(10,11);
null configuration { Serial.begin(9600); uart.begin(9600); } empty loop { if(uart.available > 0) { Serial.write(uart.read ); } } // import Adafruit_BBIO.UART as UART import series UART.setup("UART1") disp = serial.Serial (port = "/dev/ttyO1", baud rate = 9600) disp.close disp.open while True: if disp.isOpen : print "Serial is open" message = raw_input("Enter your message:n") disp.write(message) disp.write("n") exit = raw_input("Do you want to exit or not YN:") while ((output != 'Y') and (output != 'N') and (output != 'y') and (output != 'n')): print "Invalid entry!!!n" exit = raw_input("Do you want to exit or not YN:") if (output == 'Y') or (output == 'y'): to break other: print "To continue....n" print "Sorry!!! You cannot communicate with the device" disp.close

###

Circuit diagrams

beaglebone-arduino-using-UART data

Project video

Conteúdo Relacionado

A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
ESP32-CAM is a compact camera module that combines the...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.