In this lesson, we will show you how to use OSOYOO wifi shield to exchange data between Arduino and Raspberry Pi through UDP protocol.
We will use our V2 Arduino Robot+OSOYOO ESP8266 Wifi Shield to send UDP control signal to remote Raspberry Pi Robot and control its movement.
Parts and Accessories:
1)OSOYOO Arduino Robot Car V2.0 (purchase link: https://osoyoo.com/2018/12/21/osoyoo-robot-car-kit-tutorial-introduction/)
2)OSOYOO Raspberry Pi Robot Car (https://osoyoo.com/2018/05/15/raspberry-pi-robot-car-diy-learning-kit/)
Circuit Connection diagram:
Arduino to WifiShield
Raspberry Pi to Model X
|Raspberry Pi||Model X|
|Pin 11(GPIO 17)||IN1|
|Pin 12(GPIO 18)||IN2|
|Pin 13(GPIO 27)||IN3|
|Pin 15(GPIO 22)||IN4|
GPIO pin map:
Step A. Install Raspberry Pi Software:
Open Raspberry Pi terminal and run following command to download and run the udpreceive.py python file.
After running the python code, you will see IP address of your raspberry pi as follows:
(‘My Raspberry Pi LAN ip is ‘, ‘192.168.0.22’)
remember this IP address, we need use it to replace
Step B. Arduino software:
1)If you don’t have WifiEsp-master library, please download WiFiEsp-master library from following link:
https://osoyoo.com/driver/WiFiEsp-master.zip. If you have installed this library, please skip this step.
2)Download Arduino sketch file UdpSend.ino from https://osoyoo.com/driver/arduino-udp/UdpSend.ino
Open above file with Arduino IDE, replace line 16 with your wifi SSID, line 17 with your Wifi password and Line 20 with your raspberry pi IP address which showed in Step A.
Running the car
1)Disconnect your car from wired power. Put your Raspberry Pi robot car on the ground, turn on the battery , then use Windows Putty or MacBook ssh command to connect pi’s IP address. Type following command again to start the updreceive.py program:
2)Load your UdpSend.ino sketch code to Arduino, then open Serial Monitor
then in the text field, type following 5 letters to control Robot Movement
A : make car move forward
B : make car move backward
L : make car left turn
R : make car right turn
E ; end the Udp conversation with pi
DownLoad Url osoyoo.com