The paper proposes using a predictive model to optimize the use of electricity in the V2G (vehicle to grid) service. The novelty of the mechanism as a kind of model predictive control (MPC) is that it seeks an effective way of managing electric energy in an Electric Vehicle (EV). Additionally, it proposes a new method of predicting the electricity consumption which allows the battery of an electric vehicle to reconcile two sides: both the system's and the user's demand will be met at the same time. The model allows for very precise determination of the vehicle's demand for the energy related to the progressive movement, taking into account the parameters characteristic of a given vehicle model, its suspension structure and aerodynamics. In addition, the machine learning algorithm was proposed for the prediction model as a hybrid (offline and online) of supervised learning. As the first part of the research, by using Matlab/Simulink/dSpace software, a prediction of EV energy consumption was created on a selected route at different times of the day (offline data matrix). At the same time, the simulated route was travelled by a BMW i3 EV (online data matrix). Based on the developed machine learning algorithm the results of the electric energy consumption were compared. The research confirms that if the correct mechanism for prediction of energy consumption by the EV is used, it is possible to define the amount of energy needed for a V2G service. The measurement error was obtained at 0.5%. The added value is setting up the EV energy security of customers after the V2G service and a correct WIN-WIN relation between the Low Voltage grid and EV customers' needs.