The devices in the Internet of things (IoT) gain capability of sustainable operation when they harvest energy from ambient sources. Fluctuation in the harvested energy may cause the energy‐harvesting IoT devices to suffer from frequent energy shortage, which may bring in intolerable packet delay or packet discarding. It is important to design a low‐delay packet delivery scheme that adapts to variation in the harvested energy. In this paper, we present the timely data delivery (TDD) scheme for the IoT devices. Using Markov chain, we develop a probability model for the TDD scheme, which leads to the expected number of packets delivered in an operation cycle, the expected numbers of packets waiting in the data buffer in an operation cycle and an energy‐harvesting cycle, and the expected packet delay. Additionally, we formulate the optimization problem that minimizes the packet delay in the TDD scheme, and the solution to the optimization problem yields the optimal parameters for the IoT devices to determine when to harvest energy and when to deliver data under the TDD scheme. The simulation results show that the proposed TDD scheme outperforms the existing schemes in terms of packet delay.