A major challenge in designing Internet of Things (IoT) systems is to meet various non-functional requirements such as lifetime, reliability, throughput, delay, and so forth. Furthermore, IoT systems tend to have competing requirements, which exacerbate these design challenges. We analyze this problem in detail and propose a model-driven approach to optimize an IoT application regarding to its non-functional requirements. Our approach defines optimizing as finding the best set of adjustable application parameters, which satisfies a given objective function. The relevant parameters are extracted during a simulation process. We apply a source code transformation that updates the source code with the generated adjustable parameter values and executes the compiler to create a new binary image of the application. Our experiment results demonstrate that non-functional requirements such as power consumption and reliability can be improved substantially during the optimization process.