I have a problem with communicating Arduino (standalone Atmega 328) with Beaglebone Black. I have made a wiring to connect the TX pin to BBB's UART2 RX (P9_22) and the RX to the UART2 TX (P9_21) using logic leven shifter. However, nothing is received in BBB's ttyO2, when trying to
cat /dev/ttyO2
. I have enabled the UART successfully, I tested it by sending from ttyO1 to ttyO2 using two wires and it worked.
What voltage is the 328 running at? And what voltage for the BeagleBone?
The level converter has an "A" side and a "B" side. The "A" side is connected to the 328 and is powered from pin 3 on the BeagleBone (3.3V). But there are also connections from pin 5 of the BeagleBone to pin 4 of your standalone 328 board (5V).
The "B" side of the converter is also powered from pin 5 (5V). I thought a BeagleBone was a 3.3V device.
328 is running at 5.0 V and it is fed by Beaglebone Black 5V pin. Beaglebone is attached to 5V/3A power supply. Since BBB needs digital signals to be inverted to 3.3V, I have to use the logic level shifter.
Try disconnecting the Arduino TX and RX wires from the level converter and instead connect those two pins on the level converter with a jumper. This should loop the transmit data from the BeagleBone back to its receive pin and you should be able to see this.
How do you set the speed of the port on the BeagleBone?
Can you post a schematic (or link to one) for the 328 board.
Did I understand your proposion right:
UART1 TX <--> High level RX -> High level TX
UART2 RX <--> High level TX
To confirm:
UART1 TX to low level (e.g. A1) - signal appears on high level B1
Jumper connects B1 to (e.g.) B2 - return signal appears on low level A2
A2 to UART1 RX or UART2 RX - whichever is easier for you to monitor.
Send data out on UART1 TX and monitor the RX - each character you send out should be received. This will test whether the level converter is working OK.
It will repeat what you have already got working but going through the level converter as well ...
I tested it by sending from ttyO1 to ttyO2 using two wires and it worked.
OK, can you post a schematic diagram of the 328 board? Or a link to one.
ADDED ...
Is the 328 board (the green component marked "atmega328" in your diagram) just a 32-pin 328 chip on a 32-pin breakout board? Or are there any other components on the breakout board?
How did you upload the program onto the 328? Is it known to be a working Arduino clone? For example, has it run a Blink program with an LED?
Do you also have an Arduino Uno? If so, you could plug your 328 into it (instead of the original 328) and check that you are getting serial output to the Serial Monitor in the IDE. That would show whether the 328 has a fault or if it is something to do with the breadboard setup.
And I'm sure you have double checked this already but the BeagleBone UART is definitely at 9600 bps? The loop-back tests you did would still work if a different bit rate was set.
ADDED ...
What frequency is the crystal / resonator that you are using with the 328 on the breadboard?
ADDED Could you please post a photo of your breadboard with the 328 and level converter.
You could try a loopback test on the 328. Disconnect TX and RX from level converter and connect them together with a jumper. Then run the code below. It sends a character every 2 seconds. If it receives the character, it briefly flashes the LED on Arduino pin 8.