(SOLVED) Serial connection between Arduino and BeagleBone Black

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.

Arduino code is as simple as this

void setup() {
  Serial.begin(9600);

}

void loop() {
  Serial.print("Test");
  delay(1000);


}

What's wrong? I have no ability to use a TTL-USB converter, so this is an annoying problem. :frowning:

Hi kataja

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.

Regards

Ray

Hello

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.

My latest edit crossed with your last post :slight_smile:

Check your wiring. The way it is in the fritzing diagram has the power connections to the level converter the wrong way round.

Ok, my bad, I draw it wrong. Now it should be correct. :confused:

Anyhow, it's not still working...

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

And then I should see in ttyO2, what I send to ttyO1.

Beaglebone's tty speed is 9600 bps, and it can be set with

stty -F /dev/ttyO2

.

Here's a link for the whole scheme: Dropbox - Error - Simplify your life

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.

Yes, the logic shifter does work. Just tested it by the setup as above.

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?

I edited the diagram to use a vanilla 328 board, which pins are here: https://www.arduino.cc/en/uploads/Hacking/Atmega168PinMap2.png

And Beaglebone's: http://elinux.org/images/9/91/4.5_serial_UARTs.PNG

Yes, the 328 is working, I used Usbasp to program it and blinking led works.

I'm confused. Which 328 chip are you using? 28-pin DIL? 32-pin TQFP on a breakout board?

Hackscribble:
I'm confused. Which 328 chip are you using? 28-pin DIL? 32-pin TQFP on a breakout board?

The 28-pin version.
This is really a mystery, I have no idea why this just doesn't work...

You ought to add a 100nF decoupling capacitor across 328 pins 7 and 8.

Also connect pin 20 to 5V and pin 22 to GND.

Add a 10K resistor between pin 1 and 5V.

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 :slight_smile: 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?

Hackscribble:
You ought to add a 100nF decoupling capacitor across 328 pins 7 and 8.

Also connect pin 20 to 5V and pin 22 to GND.

Add a 10K resistor between pin 1 and 5V.

Done all of these, still no luck. :o
The crystal is 16 Mhz.
Unfortunately, I don't have a normal Arduino for further testing.

I checked and forced set the baud rate to 9600 bps, but the result remains...

Presumably, the 328 was burned with an Arduino Uno bootloader, which would set the fuses for 16MHz external oscillator?

If you run a blink program with, for example, LED on for 1 second and LED off for 1 second, does it flash at the correct speed?

Hackscribble:
Presumably, the 328 was burned with an Arduino Uno bootloader, which would set the fuses for 16MHz external oscillator?

If you run a blink program with, for example, LED on for 1 second and LED off for 1 second, does it flash at the correct speed?

Yes, I burned the Uno bootloader.

Now there's a led attached to the pin 8 and it's off/on every 1 second. And I checked, blinking frequency is correct.

I'm running out of ideas :frowning:

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.

#define LED_PIN 8
#define PING_INTERVAL 2000UL
uint32_t lastPing;

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);
  Serial.begin(9600);
  lastPing = millis();
}

void loop()
{
  if (millis() - lastPing >= PING_INTERVAL)
  {
    lastPing += PING_INTERVAL;
    Serial.write('A');
  }

  if (Serial.available())
  {
    if (Serial.read() == 'A')
    {
 digitalWrite(LED_PIN, HIGH);
 delay(100);
 digitalWrite(LED_PIN, LOW);
    }
  }
}

^That works like a charm. :o

So the problem must be that BBB doesn't get/recognize Arduino's serial signal?