With the IoT trend, wireless sensors are gaining growing interest. This is due to the possibility of installing them in locations inaccessible to wired sensors. Although great success has already been achieved in this area, energy limitation remains a major obstacle for further advances. As such, it is important to optimize sampling to a sufficient rate to catch important information without excessive energy consumption. One way to achieve sufficient sampling is by using an algorithm for adaptive sampling named dynamic sampling rate algorithm (DSRA); however, this algorithm requires an expert to set and tune its parameters, which might not always be readily available. This study aims to further develop this algorithm to be machine learning based to tune these parameters. To achieve this goal, the algorithm was modified and an optimization strategy that considers a predetermined error threshold was developed. Then the algorithm was implemented using simulated and real data with a set of predetermined errors thresholds to observe its performance. The results showed that the developed algorithm exhibited adaptive sampling behavior, and it could collect data efficiently depending on the predetermined error threshold. Based on the results, it is possible to conclude that the developed algorithm endows sensors with adaptive sampling capabilities based on the signal rate of change.