A large range of Internet of Things (IoT) applications use small embedded devices, combining a resource-constrained microcontroller (MCU) with a radio for wireless communication and, possibly, some sensor and actuators. Computational and memory limitations restrict the approach of creating different layers of abstractions used for conventional operating systems and libraries. The event-driven execution nature of these systems provides opportunities to save battery power, but at the cost of increasing programming complexity. A reactive programming language facilitates the development of event-driven systems in which tasks are associated with incoming events. The Terra system combines the use of ready-made, safe, components with a reactive scripting language, Céu-T. In this paper we present details of the Terra virtual machine, discussing its design for resource constrained devices. We describe how the virtual machine supports the synchronous reactive programming model of Céu-T, which triggers the execution of pending trails in response to external events, and how it implements the integration of the scripting language with specialized sets of components.