Best communication solution between Arduino and Pi

Hi All,

I'm begining a new IT project and need to connect one or more Arduino MEGA to a Raspberry Pi 3.

Pi will be the master, sending commands to slave Arduino that will trigger some relay and other electronical components according to the orders received from PI.

I started testing a lot of communication solutions (serial cable, CAN bus, I2C, 433Mhz, USB, ESP8266, ...) and would like to get your feedbacks about the best solutions ???

My requirements are : getting a stable and reliable connection (got some trouble with 433Mhz RF com) to ensure 100% of orders sent got received, avoiding cables if possible and getting a quite reasonable speed of communication.

Which protocol, solution would you advise me to use ?

Many thanks for your feedback and advices.

Best Regards,
Ben

What distances are we talking here?

If it is less than two feet, I'd say I2C. For really long distances, I'd say use RS-485.

Hi power_Broker,

Thanks for your reply.

The distance will vary between 5 to 30 meters.

I2C seems limited to 25 meters using a P82B715PN, so I agree with the choice of a solution with RS-485 bus.

Have you tried HC-12 serial radio ? Some people seems 100% satisfied with no interference and range limitation.

Best Regards,
Ben

I have had great success with Can Bus, it also implements a few other layers when compared to RS 485 and you can use standard Linux tools to send, receive and debug messages... or grab some Python can bus library if you are failiar with the language.

Different from RS 485, Can Bus tskes care of message Priority, error checking, Crc.. and if a message is transmitted but not acknowledge by at least another other node in the Bus, you will know that.

Cheers

Hi Musskopf,

Yes I think that CAN bus is also a very good alternative to my project.

I already worked with during my hobby time: model train railroad layouts. It is quite good documented with good libraiires. My Project main programming language is Python, so!

The only issue is that's not a Wireless solution and I prefer to avoid cabling for my project purpose.

So I will try HC-12 Wireless serial shields first before going on CAN or RS485.

Best Regards,
Ben

I believe the nRF24L01+ wireless transceivers work with the RPi and they certainly work well with Arduinos. And they are cheap.

I got my nRF24s working with this Tutorial

The pair of programs in this link may be useful.

They require the TMRh20 version of the RF24 library which solves some problems from the earlier ManiacBug version

...R

Thanks Robin2 for your advice.

I've just ordered nRF24L01+ modules to perform test with.

Best Regards,
Ben

I don't have an RPi so I will be interested to learn how they work with it.

...R