User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Connect Model A to Model B via serial lines

Fri Aug 02, 2013 4:17 pm

for Jessie see viewtopic.php?f=44&t=51633&start=25#p828064

Model B is server and connected to local network,
Model A is client


see :- http://elinux.org/images/2/2a/GPIOs.png for GPIO
connect pin 6 to both machines [Ground]
connect GPIO 14 [TXD] pin 8 on one machine to GPIO 15 [RXD] pin 10 on the other
and visa vesa

on both machines edit
/boot/cmdline.txt
and remove any ttyAMA0 parts
i.e.
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
becomes
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

also edit /etc/inittab
and # out
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
so it looks like
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
this is probably the last line in the file

you need an IP that is not used by your network or anywhere else for that matter
e.g.
192.168.36.1 on the server and 192.168.36.2 on the client

on the server machine
create a file called
/etc/ppp/options.ttyAMA0
and fill it with
noauth
nocrtscts
xonxoff
passive
local
maxfail 0
192.168.36.1:192.168.36.2 #note this is opposite to below

and the client
create a file called
/etc/ppp/options.ttyAMA0
and fill it with
noauth
nocrtscts
xonxoff
passive
local
maxfail 0
defaultroute
persist
192.168.36.2:192.168.36.1 #note this is opposite to above

on the server run install dnsutils
sudo apt-get update && sudo apt-get install dns-utils -y

reboot both machines

on the server
type
sudo pppd -d /dev/ttyAMA0 115200
on the client type
sudo ppdd -d /dev/ttyAMA0 115200

they should now connect
and you should be able to
ssh 192.168.36.2
and log into your Raspberry PI model A

now I'm going to see if I can get this to be automated so the connection will re-connect when dropped
but that's enough for a Friday afternoon

hopefully I've not missed any stages or typos in the above ....

this image was taken from the RPi Model A via sshing in from the Model B over the serial lines
Image
Last edited by RaTTuS on Tue Oct 13, 2015 9:29 am, edited 1 time in total.
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Mon Aug 05, 2013 9:50 am

having done this again over the weekend at a mates he's a couple of other things that you really need to do to get it working properly
...

on the server in the
options file add
proxyarp [this means that other hosts can find the computer on the end of the ppp line]
and edit /etc/sysctrl.conf
and enable
net.ipv4.ip_forward=1
this means packets can get back OK
apt-get update && apt-get upgrade takes a while over a serial link ;) but works
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
joan
Posts: 13453
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Connect Model A to Model B via serial lines

Mon Aug 05, 2013 9:56 am

115200 seems a bit conservative. I think the settings allow you to go to 4000000. I haven't tried so I have no idea if it works or is at all reliable.

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Mon Aug 05, 2013 10:47 am

joan wrote:115200 seems a bit conservative. I think the settings allow you to go to 4000000. I haven't tried so I have no idea if it works or is at all reliable.
I've just tried at
230400 and I get timeout errors ...
will have an extended look later [one is over-clocked and the other not]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Mon Aug 05, 2013 2:03 pm

I've not tried the options again as I've just moved the connection to another machine so I can use the existing one as a host for my Pi Lite/....
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Fri Aug 09, 2013 9:25 am

OK ... just got 1Mb out of the setup ...
edited
/boot/config.txt
on both machines to add
init_uart_clock=16000000 #that is 16 mil

rebooted them both and they now can connect at

sudo pppd -d /dev/ttyAMA0 1000000

so getting this from a scp :-
100% 2342KB 93.7KB/s 00:25

so approx 94KB/s

not bad and will do for me ...
I'm not sure how fast this can go ... may try and bump it later

this is with about 1Mtr of cable

img just for the lols
Image
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Fri Aug 09, 2013 9:53 am

I may be at the limit of either cable or data rates as I do get a fair number of
rcvd [CCP ResetAck id=0x02]
and Req...
so I may experiment with some other tuning figures
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
joan
Posts: 13453
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Connect Model A to Model B via serial lines

Fri Aug 09, 2013 9:54 am

RaTTuS wrote:OK ... just got 1Mb out of the setup ...
edited
/boot/config.txt
on both machines to add
init_uart_clock=16000000 #that is 16 mil

rebooted them both and they now can connect at

sudo pppd -d /dev/ttyAMA0 1000000

so getting this from a scp :-
100% 2342KB 93.7KB/s 00:25

so approx 94KB/s

not bad and will do for me ...
I'm not sure how fast this can go ... may try and bump it later

this is with about 1Mtr of cable

img just for the lols
Image
That's the way to do it.

You've got to try 4Mbs!

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Fri Aug 09, 2013 10:45 am

1Mb/s is the limit for me...
it just wont connect at higher
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
joan
Posts: 13453
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Connect Model A to Model B via serial lines

Fri Aug 09, 2013 10:54 am

Oh well, 1Mbs will have to do. :)

ColinShorts
Posts: 2
Joined: Tue Mar 12, 2013 2:18 pm

Re: Connect Model A to Model B via serial lines

Sun Aug 18, 2013 2:20 pm

You might want to try using some better cable rather than just unshielded straight wires - you might get better results with UTP/STP network cable, or possibly using some ribbon cable with a conductor between the rx/tx conductors that's grounded at one end (similar idea to 80 conductor PATA cables). I guess line noise will be the biggest enemy at higher baud rates, but I'm no expert on the matter - most of the time I use serial cables I'm either using 9600 or 115200. (fine for terminal connections)

ghans
Posts: 7770
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Connect Model A to Model B via serial lines

Sun Aug 18, 2013 2:48 pm

Isn't SCP encrypted ? Perhaps FTP is faster ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Mon Aug 19, 2013 8:10 am

I an using cat6 cable [had some around I could butcher]
I may get a chance to have another play later this week ...

would it be better to have the twist around a grounded lead or the
tx/rx
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

mikerr
Posts: 2696
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Connect Model A to Model B via serial lines

Sat Jun 14, 2014 10:05 pm

I'm not sure I have a real world use for this, but went ahead and did it anyway,
thanks for the easy step-by-step

Anything over 115200 seemed problematic but I was using untwisted servo wires...
Android app - Raspi Card Imager - download and image SD cards - No PC required !

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1776
Joined: Thu Jul 11, 2013 2:37 pm

Re: Connect Model A to Model B via serial lines

Sun Jun 15, 2014 12:33 am

You will get significantly higher speeds if you series-terminate the driver (i.e. TXD) on each Pi with a 33 ohm resistor.

Insert a 33 ohm resistor between the TXD pin and the interconnecting line. To prevent crosstalk you can either use a twisted pair, with the A in each line tied to ground and the B line for signal - or coax cables.

It'd be interesting to see how fast you can get inter-Pi communication over the UART.
Rockets are loud.
https://astro-pi.org

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1776
Joined: Thu Jul 11, 2013 2:37 pm

Re: Connect Model A to Model B via serial lines

Sun Jun 15, 2014 2:12 am

For fun and profit I've poked around with this a bit.

I can set the UART block input clock (config.txt init_uart_clock) up to 250MHz before everything breaks: however this high clock rate is a bit pointless due to other limitations. It appears you can't set the UART baud rate in linux above 4,000,000bps - setting it to 4,000,001 gives "invalid argument".

Even so, I can't test yet at 4Mbaud - FT232R devices only go up to 3Mbaud. I'd have to connect two Pis back to back and set both up.
Rockets are loud.
https://astro-pi.org

User avatar
Cancelor
Posts: 751
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Connect Model A to Model B via serial lines

Sun Jun 15, 2014 7:40 am

Going for distance rather than speed, how far apart could two devices be if they were connected with low grade wire (e.g. bell wire) lets say at 300bps?
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
Gert van Loo
Posts: 2474
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Connect Model A to Model B via serial lines

Sun Jun 15, 2014 4:51 pm

If you really want distance go for current drivers. (I think it is RS424) instead of RS323.
You can then do a mile or more.
Always when using long wires beware of lightning spikes pickup!

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1776
Joined: Thu Jul 11, 2013 2:37 pm

Re: Connect Model A to Model B via serial lines

Sun Jun 15, 2014 8:40 pm

Gert van Loo wrote:If you really want distance go for current drivers. (I think it is RS424) instead of RS323.
You can then do a mile or more.
Always when using long wires beware if lightning spikes pickup!
Or possibly RS-422.

RS-422 is the go-to for duplex transmission over long distances (>3 metres or so) - differential transmit/receive also lend themselves nicely to using standard CAT5/5e cables. Converter ICs are also readily available and cheap, and need little interfacing.

With the PPP approach described above, you could get a modest 4Mbps "network" connection to a Model A via the UART. I shall poke around and see why the 4Mbaud limit exists.
Rockets are loud.
https://astro-pi.org

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Wed Jun 25, 2014 1:29 pm

updated for sanity
though not tried with 33ohm resistors yet will see if I can get some

Model B is server and connected to the local network
Model A is client and connected to the model B via the GPIO serial Lines
see http://elinux.org/images/2/2a/GPIOs.png for GPIO
connect pin 6 on both machines together [GND]
connect pin 8 [GPIO 14 TXD] to Pin 10 [GPIO 15 RXD] on the other machine - and visa vesa

on both machines edit
/boot/cmdline.txt
and remove the ttyAMA0 bits
so

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
becomes

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
for example - your root may be different if you use noobs

edit
/etc/inittab
find the serial link - probably the last line :-

Code: Select all

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
and change it to

Code: Select all

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
to comment it out
and add :-

Code: Select all

S1:23:respawn:/usr/sbin/pppd /dev/ttyAMA0 1000000
edit /boot/config.txt
and add

Code: Select all

init_uart_clock=16000000
..
On the server machine [Model B]
edit /etc/ppp/options.ttyAMA0

Code: Select all

noauth
nocrtscts
xonxoff
passive
local
maxfail 0
nodetach
192.168.11.254:192.168.11.1
persist
proxyarp
on the client [Model A]

Code: Select all

noauth
nocrtscts
xonxoff
passive
local
maxfail 0
defaultroute
persist
nodetach
192.168.11.1:192.168.11.254
note the IP address above should be in your network range and are reversed on client and server
I can ssh into the model A from my windows box as the proxyarp bit does the cleaver routing stuff

after a reboot they should just connect and re-connect whenever the lines are connected
Last edited by RaTTuS on Wed Jun 25, 2014 1:34 pm, edited 1 time in total.
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
DougieLawson
Posts: 33316
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Connect Model A to Model B via serial lines

Wed Jun 25, 2014 1:31 pm

RaTTuS wrote:u
on both machines edit
/boot/cmdline.txt
and remove the ttyAMA0 bits
so ...
Or do all of that cmdline/inittab stuff the easy way with https://github.com/lurch/rpi-serial-console
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vish
Posts: 6
Joined: Sun Mar 09, 2014 6:04 am
Location: Kerala, India

Re: Connect Model A to Model B via serial lines

Sun Feb 01, 2015 5:36 pm

I tried doing this between my B+s. But not working.

In the B+ which is connected to LAN, ifconfig return this

Code: Select all

ppp0      Link encap:Point-to-Point Protocol  
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
other rPi, ethernet is not working, so not able to diagnose.

Please help!
-vish

User avatar
DougieLawson
Posts: 33316
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Connect Model A to Model B via serial lines

Sun Feb 01, 2015 6:21 pm

interface ppp0 is NOT the LAN interface, the LAN interface is eth0 (or wlan0).

Is the stuff in /boot on your SDCard too old to drive the USB/ethernet SMSC9514 chip?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

mshannon
Posts: 8
Joined: Thu Oct 17, 2013 4:14 pm

Re: Connect Model A to Model B via serial lines

Mon Aug 31, 2015 7:16 pm

I've been using a USB serial converter to connect my RPI2 B+ to my RPI A+ , both are runing Rapicams out in the field via Power over Internet adapters to the B+. This worked OK but I wanted more speed so I could transfer image data from the A+ back to my PC.

I've tried Model A to Model B via serial lines as stated here (indoors not in the field) and followed the instructions as from "updated for sanity Wed Jun 25, 2014 1:29 pm" above but could not get it to work. The only changes I made were:

a) My router will only allow an ip range 192.168.0.2 to 192.168.0.254 so in the /etc/ppp/options.ttyAMA0 file I used 192.168.0.40:192.168.0.41 for A+ and 192.168.0.41:192.168.0.40 for B+.

b) The Pi's did not have a PPP directory in /etc/ so I created one and gave me Group and Pi access.

I tried a sh log in to both 192.168.0.40 and 192.168.0.41 also tried to ping them both but no joy.

I did a "sudo apt-get update && sudo apt-get upgrade -y" and "sudo apt-get dist-upgrade", then double checked all the file changes and the wiring as in the instructions. I then did this on an RPI B+ instead of the RPI2. Still no joy.

Can anyone give me advice of what to do next?

User avatar
RaTTuS
Posts: 10001
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Connect Model A to Model B via serial lines

Tue Sep 01, 2015 7:54 am

mshannon wrote:I'v...
b) The Pi's did not have a PPP directory in /etc/ so I created one and gave me Group and Pi access.
...?
it probably means something is not installed
I'm not in a position to try ATM
but
1) get this working in a lab first
2) try installing pppd umm
remove the fiels you have created in ppp
sudo apt-get install ipppd #? possibly
then see if they exist
...

I'll see if I can re- do these instructions with later version of raspbian [but it will not be this week]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 14 guests