To address the problems of poor recognition, low detection accuracy, a large number of model parameters and computation, complex network structure, and unfavorable portability to embedded devices in traditional tennis ball detection algorithms, this study proposes a lightweight tennis ball detection algorithm YOLOv5s-Z based on Robomater EP. The main work is as follows: Firstly, constructing lightweight G-Backbone and G-Neck network layers to reduce the number of parameters and computation of the network structure. Secondly, the convolutional coordinate attention is incorporated in G-Backbnone to embed the location information into the channel attention, which makes the network obtain the location information in a larger area through multiple convolutions and enhances the expression ability of the mobile network learning features. In addition, the Concat module in the original feature fusion is modified into a weighted bi-directional feature pyramid W-BiFPN with settable learning weights to improve the feature fusion capability and achieve efficient weighted feature fusion and bi-directional cross-scale connectivity. The EIOU loss is introduced to split the influence factor of aspect ratio and calculate the length and width of the target frame and anchor frame respectively, combined with Focal-EIOU Loss to solve the problem of imbalance between difficult and easy samples. The activation function Meta-ACON is introduced to achieve an adaptive selection of whether to activate the neurons and improve the detection accuracy. Finally, the experimental results show that compared with the original algorithm, the YOLOv5s-Z algorithm reduces the number of parameters and computation by 42$\%$ and 44$\%$, the model size by 39$\%$, and 2$\%$ improvement in average accuracy mean value, which verifies the effectiveness of the improved algorithm and the light weight of the model to meet the deployment requirements of embedded devices, and adapts Robomaster EP for accurate detection and real-time recognition of tennis balls.