Welcome, Guest. Please Login.
YaBB - Yet another Bulletin Board
May 10th, 2025, 1:56pm
News: Welcome to the Cabin! If you want to register send me an e-mail. you can link to my e-mail under the welcome page.


Pages: 1
Raspberry Pi and the Serial Port (Read 183 times)
Fernando
YaBB Administrator
*****
NY City




Posts: 2380
Gender: male
Raspberry Pi and the Serial Port
May 30th, 2017, 12:32am
 
I was looking over the pcDuino Nano4 forum when I ran into a webpage on the forum about the serial I/O Port on the GPIO on the pcDuino. One of my biggest problems is wanting to use the serial port on the R-Pi and use it to talk to a network of Arduinoes over the serial port. I’ve done this with 8bit hardware in reverse - connecting a bunch of Atari 800’s together to talk to a single printer. Likewise I did the same with Macs to talk to a single printer later on but Macs have AppleTalk Network so it was simple to set up.
 
In having a bunch of Arduinoes talking to a single computer (an R-Pi) through the serial port, one can save space and wiring and not need to use the USB or Ethernet Port and special adapters for using it. It also saves on coding as drivers are not needed to be added to the Raspberry Pi and the Arduino. But the problem is how to access the Serial Port on the Raspberry Pi. The same is true with the Arduino but there are many examples using the serial port on the Arduino; and in some cases, the Arduinio has 2, 3, 4, as many as 8 serial ports! Writing a program that uses the serial port on the Arduino is easier than on the Raspberry Pi.
 
In such a network - one Raspberry Pi can blindly throw text (of commands) out the serial port where the Arduinoes are listening to the serial port.
 
Code:
TX (R-Pi) - - - - - - - - - + - RX (Arduino 01)
			    |
			    + - RX (Arduino 02)
			    |
			    + - RX (Arduino 03)
			    |
			    + - RX (Arduino 04)
And so on.
 


 
Each Arduino is looking for a string which calls it and then its command and ending tag:
 
Coded String: [Arduino X] [command] [end]
(Where X is a number)
 
All the Aduinoes will receive the code but the Arduino with the correct ID Tag will act on it, and then send back text saying the command was received and then the code executed as per its program, returning a “Done” string.
 
In this, one can have parallel processes going on as one Arduino does one thing while another Arduino does another. You can have one Arduino with a sensor network to check out its environment while another Arduino runs the motors to make it move. The Raspberry Pi Computer can decide what to do based on what the sensors are picking up and what the motors are doing. In this an Arduino can send an “All Stop” command request if it senses something it should not be nearby, which the Raspberry Pi receives and then sends an “All Stop” command to the motors on Arduino controlling the motors.
 
Though the Serial Port is not the fastest of options, it is one that is the least hackable. USB, Ethernet, Bluetooth, and Wifi can be hacked into, as these ports are accessible from the outside. The Serial Port is internal, making it harder to get into.
 
All this requires a lot of programming, especially depending on what the program will be for each of the Arduinos. But the sending and the receiving the command requests now becomes the easy part.
 
Of course, in Linux and UNIX, the serial port is used as a diagnostic port to see what is going on with the system. Systems like the Beagle Bone Black, Orange Pi, Nano Pi and Banana Pi has a separate Serial Port to “talk” to the unit if there is no monitor or console on it, as they have 2 or more serial ports on their boards. The Raspberry Pi only has 1 serial port on the GPIO. And until now, it has been difficult to get access too.
 
This requires a lot of reading, so here are some links I found.
 
Links:
 
eLinux’s R-Pi Technical Information Page on the Serial Port (shows R-Pi Model B but includes information for all R-Pies):  http://elinux.org/RPi_Serial_Connection
 
Indestructable’s Webpage on how to access the Serial Port (Need to get some sort of 3.5v to 5v TTL converter): http://www.instructables.com/id/Read-and-write-from-serial-port-with-Raspberry-P i/
 
David Hunt’s webpage (shows what to get, not to build it, shows a Model B but good for all R-Pi’s): http://www.davidhunt.ie/add-a-9-pin-serial-port-to-your-raspberry-pi-in-10-minut es/
 
R-Pi’s Web Forum (not much information there...): https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=41055
 
R-Pi Exchange Tech Page (lots of good info there, though it is for the R-Pi 3, it should be good for all of them): https://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-
on-the-raspberry-pi3
 
AB Electronics UK (sells adapters and shows code to turn it on, setting up the serial port on the R-Pi and then talk to its board. For the board is R-Pi 3 and R-Pi 0 but the code works for all the others.): https://www.abelectronics.co.uk/kb/article/1035/raspberry-pi-3-serial-port-usage
 
HobbyTronics (how to set up the serial port and explains why it is there, good for all R-Pies): http://www.hobbytronics.co.uk/raspberry-pi-serial-port
Back to top
 
 
View Profile   IP Logged
Hondo I. Sackett
YaBB Administrator
*****
Behind you!




Posts: 1349
Gender: male
Re: Raspberry Pi and the Serial Port
Reply #1 - May 30th, 2017, 8:14pm
 
Cool! Great info again! Thanks
Back to top
 
 

Well the cowboy, like the red man, you had to leave your land
You can't raise your stock and plant your crop in the gumbo and the sand
Greed disguised as progress has put us to the test
They won't be glad until we're gone from our home out in the west
It's sad to see those good old days replaced with greed and doubt
Soon we'll leave the country, the campfire has gone out
Bid 'em all adieu, you can't turn the world about
The cowboy left the country, the campfire has gone out
View Profile WWW   IP Logged
Pages: 1