The Internet of Things (IoT) has experienced rapid growth, taking advantage of advanced data processing. While complex event processing (CEP) engines have positioned themselves as a good solution for cloud and fog data processing, there are no CEP solutions designed to run on microcontrollers (MCUs) at the edge. This paper presents MicroCEP, a software architecture for MCUs that enables real-time filtering and correlation of sensor data, both locally obtained and received through message queues at the edge. MicroCEP provides (i) a lightweight CEP architecture for MCUs, (ii) a pattern language to specify complex event patterns, (iii) a REST API for dynamic threshold updates, and (iv) a methodology for designing and deploying MicroCEP-based systems. The solution facilitates the detection of situations of interest and the triggering of actions directly from the MCUs, enabling autonomous decision-making close to the sensors. A proof of concept implementation using RISC-V MCUs provides evidence that MicroCEP can deliver CEP capabilities at the edge on resource.constrained devices.