In the present study, the economic model predictive control (EMPC) scheme is presented for the time of use tariff application of photovoltaic and diesel generator backup system, which is connected to the gridâconnected microgrid. Through the use of the closedâloop control system, the prior openâloop optimal control is enhanced. Minimizing the grid energy and fuel costs by evaluating the fuel level restrictions in the diesel tank is the main goal of this study. To accommodate the restrictions among controllable variables, this control method fulfils the load requirements. To gain the benefits of feedback and predictions, optimal power scheduling is modelled as a control problem. Furthermore, Blockchain technology is applied to secure interchanged information in the grid to avoid manipulating data by attackers. Specifically, the analysis is divided into two scenarios. The first one takes place in the alternative style when a blackout happens between [7 am and 6 pm] h and the other occurs in a grid energy mode when the network is available over 24Â h. Energy performance, cost savings, and daily revenue have all been improved by EMPC. As a result, the daily energy savings are up to 52%, whereas diesel energy does not go over 85%.