The evolution of the Internet of Things (IoT) allows the development of new services and applications but triggers as well a full set of new issues to be solved. Among them, there are the problems related to the integration of the WSNs in the IoT realm including those related to data access. In this paper, we address more precisely the in-network data storage and data retrieval performed in a WSN integrated in the IoT realm. In order to develop an adequate data storage scheme for this scenario, we first design a system that integrates the Virtual Broking Coding (VBC) data storage scheme in the IoT realm. Then, we propose an algorithm called Dynamic Adaptive Virtual Broking Coding (DA-VBC) that adapts dynamically the packet redundancy level adopted in VBC to the optimal redundancy level, regarding the actual condition of the network, in order to ensure a reliable data storage and data retrieval. To do so, we model the choice of the optimal redundancy level as a Markov Decision Process (MDP) problem. Using the optimal policy found by the MDP, DA-VBC always performs with the minimum costbenefit for the network which means allowing more packet to be retrieved without overload the energy consumption. The simulation results confirm that the dynamic adaptation of the redundancy level improves the reliability of the data storage scheme while achieving an energy consumption comparable to the solution that does not use any redundancy. Besides, they show that the optimization of the cost-benefit metric is far more efficient than optimizing only one metric (for instance the cost or the packet delivery ratio), or using a fixed redundancy level.