This paper focuses on very-short-term photovoltaic power forecasting based solely on power measurement. The approach proposed in the paper is tailored for real time operation of smart grids and microgrids, that deals with energy management and control of the various resources of the grid and, particularly, on those based on renewable energy sources. These resources are characterized by variable power production, thus constituting a challenge for the effectiveness of strategies and tools of management and control. This paper refers to photovoltaic power production and presents a new real time forecasting method which improves the classical persistence model. The proposed method is based on the idea of conveniently weighting information on past data by imposing continuity of the function, of its first derivative and of the second derivative so obtaining three estimates of the function in the forecast interval which are then opportunely weighted to provide the forecast. The effectiveness of the proposed approach is shown in the numerical application based on actual measured data. The accuracy of the proposed approach is also tested through comparisons with two models based on the persistence and auto regressive moving average models.