Software Defined Networking (SDN) provides a new perspective for the Internet of Things (IoT), since, with the separation of the control from the data planes, it is viable to optimise the traditional networks operation management. In particular, the SDN Controller has a global vision of the network of sensors/actuators domain, allowing real-time network nodes and data flows reconfiguration. As a consequence, devices, usually facing limited communications and computing resources, are relieved of the route selection task in a distributed and, thus, suboptimal way. This paper proposes a SDN-IoT architecture, specifically focusing on the Controller design, which dynamically optimises in real time the end-to-end flows delivery. In particular, the dynamic routing policy adaptation is based on the real-time estimation of the network status and it allows jointly minimising the end-to-end latency and energy consumption and, consequently, to improve the network life time. The performance of the proposed approach is analysed in terms of the average latency, energy consumption and overhead, pointing out a better behaviour in comparison with the existing distributed approaches.