EasyManua.ls Logo

Freenove 4WD Smart Car Board for Raspberry Pi User Manual

Default Icon
132 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #96 background imageLoading...
Page #96 background image
Need support? support.freenove.com
92
Chapter 7 Smart video car
Server
The server works on the Raspberry Pi and can transmit camera data, ultrasonic data, etc. to the client, and it
can also receive commands from the client.
In the Server folder, there is a server.py file which contains main server code.
get_interface_ip() is used to get IP address of the native Raspberry Pi wlan0, without manually modifying the
code to set IP parameters.
StartTcpServer() is used to start the TCP service. The channel of port 5000 is mainly used to send and receive
commands between the client and the server. The channel of port 8000 is used for the server to transmit the
collected camera data to the client.
StopTcpServer() is used to stop the TCP service.
sendvideo() is used to sends the camera data.
Part of server code is as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def get_interface_ip(self):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s',
"wlan0"[:15]))[20:24])
def StartTcpServer(self):
HOST=str(self.get_interface_ip())
self.server_socket1 = socket.socket()
self.server_socket1.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEPORT,1)
self.server_socket1.bind((HOST, 5000))
self.server_socket1.listen(1)
self.server_socket = socket.socket()
self.server_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEPORT,1)
self.server_socket.bind((HOST, 8000))
self.server_socket.listen(1)
print('Server address: '+HOST)
def StopTcpServer(self):
try:
self.connection.close()
self.connection1.close()
except Exception , e:
print "No client connection"
def sendvideo(self):
try:
self.connection,self.client_address = self.server_socket.accept()
self.connection=self.connection.makefile('rb')
except:
pass
Question and Answer IconNeed help?

Do you have a question about the Freenove 4WD Smart Car Board for Raspberry Pi and is the answer not in the manual?

Freenove 4WD Smart Car Board for Raspberry Pi Specifications

General IconGeneral
Drive Type4WD
Motor TypeDC Gear Motor
Wireless CommunicationWi-Fi
Motor Channels4
Servo Channels2
Servo Voltage5V
CompatibilityRaspberry Pi
Power Supply6V-12V
Programming LanguagePython
SensorsUltrasonic Sensor
Input Voltage7V-12V
Onboard InterfacesGPIO, I2C, UART

Summary

Welcome and Introduction

About Battery Information

Refers to a separate document for battery details.

Get Support and Offer Input

Provides contact information for technical assistance and feedback.

Safety and Precautions

Lists essential safety guidelines for product usage and handling.

About Freenove

Company Overview and Copyright

Describes the company's mission and intellectual property notices.

Parts List

Smart Car Board Components

Details the main control board of the 4WD Smart Car.

Machinery and Transmission Parts

Lists screws, nuts, motors, wheels, and related hardware for assembly.

Electronic Parts, Tools, and Self-Prepared Items

Lists sensors, tools, and components the user must provide.

Preface

Raspberry Pi Introduction

Explains the role and features of the Raspberry Pi in the project.

GPIO Pinout and Usage

BCM GPIO Numbering

Details the Broadcom SOC channel numbering for GPIO pins.

Physical and WiringPi GPIO Numbering

Explains alternative GPIO numbering schemes: physical and WiringPi.

Chapter 0: Raspberry Pi Preparation

System Installation and Components

Guide to installing the Raspberry Pi OS and required hardware.

Remote Access Setup

Instructions for configuring VNC and remote desktop access.

Chapter 1: Software Installation and Testing

Code Setup and Library Installation

Downloading project code and installing necessary Python libraries.

Interface Configuration

Enabling I2C and VNC interfaces on the Raspberry Pi.

Library Installation Program

Running the script to install all required software libraries.

Chapter 2: Assemble Smart Car

Mechanical Assembly Steps

Step-by-step guide to building the car's chassis and attaching components.

Module Installation Guide

Instructions for installing sensors like line tracking and camera modules.

Chapter 3: Module Testing

Motor and Sensor Testing

Verifying the functionality of motors, ADC, and line tracking sensors.

LED, Buzzer, Servo, and Camera Testing

Testing LEDs, buzzer, servos, ultrasonic, and camera modules.

Chapter 4: Light Tracing Car

Light Tracing Functionality

Explains how the car uses photoresistors to detect and follow light.

Chapter 5: Ultrasonic Obstacle Avoidance Car

Obstacle Avoidance Functionality

Details how the car uses ultrasonic sensors for navigation.

Chapter 6: Infrared Line Tracking Car

Line Tracking Functionality

Explains how the car follows a line using infrared sensors.

Chapter 7: Smart Video Car

Server and Client Setup

Instructions for setting up the server on Raspberry Pi and the client.

Remote Access Clients

Guides for running clients on Windows, macOS, and Raspberry Pi.

Troubleshooting Common Issues

Car Malfunctions and Solutions

Diagnosing and resolving common problems with the car's operation.

Mobile App Control

Android and iOS App Guide

Instructions on downloading and using the mobile application for control.

Free Innovation and Custom Programming

Writing Your Own Programs

Guidance on developing custom code for the smart car.