Agriculture is one of the essential commodities to increase food production and economic growth in the world. Food demand is rising day by day as a result of population growth. Existing farming techniques are not suited for increasing food production. To overcome this issue, we use Internet of Things (IoT), which is one of the emerging technologies in the agriculture field. Generally, the IoT devices consist of low power, low processing and low memory capacity. So, energy plays a significant role in extending the lifespan of the network in the Agricultural Internet of Things (AIoT). To increase the lifetime of the network, this paper proposes an Energy-aware Grid-based Data Aggregation Scheme in Routing (EGDAS-RPL) protocol for AIoT. It has three processes, namely grid formation, grid head (GH) selection and grid head parent selection. First, EGDAS-RPL forms the equal-sized grid on the square network. Second, it probabilistically selects the GH node within the grid. Finally, it considers the metric expected transmission count (ETX) to select the optimal GH parent for data transfer. The simulation is conducted using the COOJA simulator. The performance of the proposed EGDAS-RPL protocol is compared to RPL and E2HRC-RPL, which reduces the packet loss ratio and end-to-end delay. Thus, EGDAS-RPL protocol increases the lifespan of the network. © 2020 Elsevier Inc.