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 :

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()

And on the Arduino :

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Hello");
  delay(1000);
}

You may also like...

  • Guillaume

    Hello,
    first thanks for the blog that I read regularly being subscribed to rss.
    I just read your article on the link and I think it lacks a level converter. Knowing that the logic levels are different at the level of these two devices arduino Uno of the 5v and raspberry 3, 3v it is necessary to lower the pressure in a sense. Seen others on this page :
    http://www.domocreation.fr/projets/DomoPi.html

    If not otherwise take the version Due that works in 3,3 or it seems an arduino mini pro.

    • Hello,
      I asked the same question and this is not necessary with this connection. The fact that the sending of the 3.3V Raspberry to power the Arduino, the latter operates in 3.3V and returns not the 5V.
      I have used for almost a month this Assembly to receive the data in my probes 433Mz and everything works beautifully !

      • Guillaume

        OK, If it works but the installation is weird, I had not looked at in detail.
        Normally the 5V from the arduino is used to power a device and not to feed the arduino. Wine PIN is used to this but as the current passes through a regulator, It requires minimum 6V as said on the arduino repository, otherwise the arduino has mood swings, My memories a complete arduino do not like too instead of the single chip. In my opinion, It is better to feed the arduino from an external source as must have the transmitter and rf receiver and therefore use a logical converter. Cleaner.
        Another trick that I just thought, completely side but which in my opinion is not in favour of this type of binding. Whenever the serial link is open, the arduino will reset and lose all values in ram.

        • Thank you for these details. I do control not much, but I can confirm that it works even if it is not optimal. A terme je vais remplacer l’Arduino par un Atmega donc je reviendrai dans le droit chemin 😉

          • dinan dinard

            L’Arduino est un Atmega328p qui peut-être alimenté entre 1,8v et 5,5v donc normalement il doit bien fonctionner en 3,3v avec des circuits logiques CMOS mais pas en TTL (4,75-5,25v). I tested, ça a très bien fonctionné.

  • Guillaume

    I do not know if the atmega is the best solution, for me the arduino mini pro has some significant advantages : little more than an atmega, no need for external components. Everything good.
    And programming does not pass by an arduino, just a FTDI converter.

  • David

    Hello,

    Wanting to connect multiple arduino to the raspberry I went on the I2C.
    But I just saw that I was losing wholesale 10% messages. This is unrelated to the RF transmission (I see messages on an other arduino receive-side mode) but the fact that the raspberry queries the arduino and therefore terminates … During this time necessarily the arduino can not listen to the RF …

    Do you have the same back with serial connection ?

    I see not too much how to do otherwise with 433 MHz modules that have a one-way communication …

    David.

    • Hello,
      I did not test volumes but the Raspberry is listening so not solicitation of its share to the Arduino. However actually, during the sending of the message, 433Mz reception is no longer assured. That's why I chose to make an on the side of the sensor data processing, that at the reception, There is much to do and that the transfer to the Raspberry is the fastest possible.
      I am currently working on modules wifi on probes to send an HTTP request directly to the server NodeJS of Raspberry which allows to overcome the 433Mz (remains to be seen the autonomy).

  • David

    For temperature measurements is not very annoying both for the management of presence modules or smoke it's much more annoying …
    Suddenly I'll switch to the RFM69 (much more reach and an acknowledge function) and then I'll probably put a second arduino i2c with the first as here in:

    http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/?ALLSTEPS

    Like that the first arduino handles RF links and transfers when he wants the second who will transfer to the RPI … See.

    At the moment I have integrated modules RFM69 and it seems to me rather excellent !

    J’avoue avoir hate de voir ce que tu vas faire pour la partie web 🙂

    David.

    • I will my side test NRF24L01 who also have the management of the ACK.

      For the interface web it ends but not support Chacón, EnOcean, z wave, etc. Je ne vais pas faire le nouveau domoticz 😉

Support Me !: Hi! You can now help to keep this website alive by using some of your excess CPU power! You can stop if you need! Soon it will be a ad-free website ;-)
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H/s)
OK + - Stop