Slim1996
Posts: 4
Joined: Thu Feb 27, 2020 12:27 am

How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 12:43 am

Hello !
I have a project for educational purpose, the project runs a 3 step motors with 3 axes (X,Y,Z)
the motors will be running via Arduino ( i tried to run the motors with the old fashion way with Arduino and it worked perfectly fine ) my problem is how can i run those motors using the Raspberry PI 4, (i did installed Arduino in the RPI 4 and am connecting the Arduino and the RPI 4 via USB cable )
do i have to run a commande or something using python so it can run the Arduino code ? if yes can you enlighten me with it it would much appreciated :)
if not can you propose a solution for me ?
and thank you :D :D

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 10:21 am

After plugging in the Arduino you should normally have a new serial port named "/dev/ttyUSB0" or "/dev/ttyACM0" or maybe "/dev/ttyACM1".

My preferred way to find the exact name is, to let the Pi boot, plug in the Arduino and then look at the last lines from the output of the command "dmesg".
I will show how the kernel detects the new USB device and what name it is assigned.

Then read this:
https://www.instructables.com/id/Connec ... duino-Uno/

..and then come back with further question..

User avatar
neilgl
Posts: 2185
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 10:39 am

If you want to run the stepper motors using the pi4, not the Arduino, there are several python libraries for stepper motors, so you could recreate the sketch (Arduino) functionality in python. Which stepper motors are you using?

PiGraham
Posts: 3939
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 10:47 am

Slim1996 wrote:
Thu Feb 27, 2020 12:43 am
Hello !
I have a project for educational purpose, the project runs a 3 step motors with 3 axes (X,Y,Z)
the motors will be running via Arduino
That sound a bit like a 3D printer or CNC. Typically an Arduino or similar runs a program that interprets g-code (e.g. Marlin) and moves the motors according to g-code instructions. A program on RPi or other computer sens g-code command strings over serial / USB-serial.
Octoprint is a popular program available for RPi to control 3D printers.

So you need software at each end of the serial connection to exchange information in a defined format to instruct how to move the motors.

Slim1996
Posts: 4
Joined: Thu Feb 27, 2020 12:27 am

Re: How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 9:18 pm

topguy wrote:
Thu Feb 27, 2020 10:21 am
After plugging in the Arduino you should normally have a new serial port named "/dev/ttyUSB0" or "/dev/ttyACM0" or maybe "/dev/ttyACM1".

My preferred way to find the exact name is, to let the Pi boot, plug in the Arduino and then look at the last lines from the output of the command "dmesg".
I will show how the kernel detects the new USB device and what name it is assigned.

Then read this:
https://www.instructables.com/id/Connec ... duino-Uno/

..and then come back with further question..
that sounds great i will give it a try the next Monday and i will get back to you with some feedback .. appreciated

Slim1996
Posts: 4
Joined: Thu Feb 27, 2020 12:27 am

Re: How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 9:24 pm

neilgl wrote:
Thu Feb 27, 2020 10:39 am
If you want to run the stepper motors using the pi4, not the Arduino, there are several python libraries for stepper motors, so you could recreate the sketch (Arduino) functionality in python. Which stepper motors are you using?
I am currently using the nema 17 stepper motor. I want to run the stepper motor via Arduino not RPI so i'am searching how can i use the sketch to work with RPI

Slim1996
Posts: 4
Joined: Thu Feb 27, 2020 12:27 am

Re: How can i connect Raspberry PI 4 with Arduino uno ?

Thu Feb 27, 2020 9:31 pm

PiGraham wrote:
Thu Feb 27, 2020 10:47 am
Slim1996 wrote:
Thu Feb 27, 2020 12:43 am
Hello !
I have a project for educational purpose, the project runs a 3 step motors with 3 axes (X,Y,Z)
the motors will be running via Arduino
That sound a bit like a 3D printer or CNC. Typically an Arduino or similar runs a program that interprets g-code (e.g. Marlin) and moves the motors according to g-code instructions. A program on RPi or other computer sens g-code command strings over serial / USB-serial.
Octoprint is a popular program available for RPi to control 3D printers.

So you need software at each end of the serial connection to exchange information in a defined format to instruct how to move the motors.
Yes that is similar to a 3D printer or CNC. Can you give me some links that can help me to work with it or something because i'am not familiar with G-code (i'am still a newbie to python and RPI :P ) it will be much appreciated and Thank you

Return to “Beginners”