Surprisingly it is easy!!!
In this article we will learn how to connect two raspberry pi zeros together.
In this example we will use one Raspberry Zero W & the other Raspberry Zero 2 W
you need to power only the Raspberry Zero W & the cable will power Raspberry Zero 2 W, of course you can provide a separate power source especially if you want to connect sensors and other hardware on the other board.
Same configuration can be implemented between two Raspberry Zero W.
Steps :
For you need to enable Ethernet over USB.
sudo nano /boot/config.txt
as in the above picture at the end of the file just add
dtoverlay=dwc2
Now you need to edit cmdline.txt. Look for rootwait and add modules-load=dwc2,g_ether after it immediately.
Now we will assign IPs to both boards. One of the boards will be the gateway. In our case it could be any board. but if you are using a RPI-4 where you can connect many boards together then the main board should be the gateway.
sudo nano /etc/dhcpcd.config
You need to edit the file by adding the following to the end
for the router:
interface usb0
static ip_address=192.168.11.1 # should be equal to router as this is the router
static routers=192.168.11.1
static domain_name_Servers=192.168.11.1
metric 400 # determines priority of using this net compared to wifi and others
for other boards:
interface usb0
static ip_address=192.168.11.123 # can be any ip within the subnet domain.
static routers=192.168.11.1
static domain_name_Servers=192.168.11.1
metric 400 # determines priority of using this net compared to wifi and others
After Restarting
Both boards you can see the usb0 section with the static IP
It is very easy and very useful. As serial communication will allows only one app to communication. But connecting via Ethernet means there is a many-to-many communication between applications on both boards in a reliable fashion.
Thank you....
No comments:
Post a Comment