Serial (RX/TX) UART Communication with Raspberry Pi

Hi Folks,

I am trying to create some proof of concept project to show a small software based on QT and wiringPi on my Raspberry Pi 3 to controll the Arduino Uno via the Serial Interface (RX/TX).

I connected both devices with a logic level converter and RX/TX crossed and Setup the Raspberry Pi for serial communication.

Communication between the Serial Monitor and minicom on the Raspberry Pi works fine. Also the communication from my QT Program is shown in the Serial Monitor as expected.

The Arduino is programmed to toggle a LED on one Port, when an 'a' is send via Serial Communication. This works fine when I send the 'a' from the Serial Monitor, but there seems to be no communication with the Raspberry anymore as soon as I use one of the following codelines in my Setup sequence in the arduino:

Serial.setup (9600);

or

Serial.setup (9600,8N1);

The RX/TX leds onboard do not flicker anymore and the arduino receives no signals from my QT program. It doesn't matter if the Arduino is connected via USB to my Mac or not and if I provide power to the Arduino via USB or an external power device. Also restarting the Arduino after uploading the Software or connecting RX/TX only after reboot does not help. Another try I gave was using <termios.h> as well as <wiringSerial.h> on the Raspberry but both lead to no different result.

Has anybody already managed to establish a real Serial Connection between the raspberry (using termios.h or wiringSerial.h) and the Arduino passing information forth and back?

Does the use of the USB Port interfere with Serial Communication on Port 0 and 1?

Any ideas out there?

You need to post your complete Arduino program.

The correct syntax is Serial.begin(9600);

...R
Python - Arduino demo
Serial Input Basics

Sorry :wink: will post the full code when I am at home.

And yes :wink: I messed up Serial.begin (9600) as I was (stupidly enough) referring from my brain and not the code in front of me...

Thanks in advance. I will look through your huge amount of info provided in that other thread this evening at home.

Regards,

Sascha

Here is the code from the Arduino, nothing really special, just make the LED Flash for 100ms when the Raspberry sends anything (in my case an 'a' on pushing a button):

const int RED_LED_PIN = 2;

void setup()
{
pinMode(RED_LED_PIN, OUTPUT);
Serial.begin(9600);
}

void loop()
{
   digitalWrite (RED_LED_PIN, LOW);
   while (Serial.available ()) {
     digitalWrite (RED_LED_PIN, HIGH);
     char inChar;
     inChar = (char)Serial.read ();
     delay (100);
   }
}

That moment you double-check your circuit and feel stupid.

RX/TX was not crossed (actually it was crossed twice so the result was uncrossed) and the HiPower Pin of the logic converter was wrongly connected to the raspi 5v power instead of closing the circuit on the arduino...

Sorry all for my stupidity....

NerdsPlayground:
That moment you double-check your circuit and feel stupid.

Welcome to the club :slight_smile:

...R