Raspberry Pi – Arduino - Link the two serial / UART

To receive data in 433Mz on the Raspberry Pi, you can use different libraries but all use almost 100% of the CPU 100% (If you know one that does not I'm interested in !). Then a solution is through an Arduino which will send us the valid data on serial port.

Arduino Raspberry Pi serial uart

I continue to progress slowly on my project PI Home Connect, and therefore continued to my article on the creation of a node, It is necessary to receive data. Using for the moment a 433Mz transmission should therefore be able to receive messages from my probe. The reception directly on the Raspberry using the CPU has (almost) its maximum, I chose to use an Arduino.

As I didn't have multiple power sources, I found the excellent article from Jared Wolff on a quick and easy connection between the two :

PiHomeConnect - Arduino - Serial UART with Raspberry Pi

This is how with 4 wires connect the two. Thanks Jared !!

To exploit the communication between the two you need to disable the extra console on the Raspberry Pi :

  • Updating your system
    apt-get update && apt-get upgrade
  • Install if necessary raspi-config
    apt-get install raspi-config
  • Run raspi-config and select the following steps :
    PiHomeConnect - Arduino - Serial UART with Raspberry Pi - Disable console - 1 PiHomeConnect - Arduino - Serial UART with Raspberry Pi - Disable console - 2 PiHomeConnect - Arduino - Serial UART with Raspberry Pi - Disable console - 3
  • Restart Raspberry Pi

Now you can communicate with your Arduino on the serial port. For the Raspberry you can use a program in Python for example :

[code lang =”Python”]
import serial
import sys
import string

SER = serial.Serial(‘/dev/ttyAMA0’, 115200)
While True :
try:
# Read data incoming on the serial line
data=ser.readline()
print data
except:
print "Unexpected error:", sys.exc_info()
sys.exit()
[/code]

And on the Arduino :

[code lang =”plain”]
void setup() {
Serial.begin(115200);
}

void loop() {
Serial.println("Hello");
delay(1000);
}
[/code]

Like this article ? Bear with me on patreon!

You may also like...