Sébastien TIMONER
Expert in web development and team management, I specialize in creating and optimizing high-performance digital solutions. With extensive expertise in modern technologies like React.js, Node.js, TypeScript, Symfony, and Zephyr OS for IoT, I ensure the success of complex SaaS and IoT projects, from design to production, for companies across various sectors, at offroadLabs.
At offroadLabs, I offer custom development services that combine technical expertise with a collaborative approach. Whether creating an innovative SaaS solution, developing IoT systems with Zephyr OS, modernizing an existing application, or supporting the upskilling of a team, I am committed to delivering robust and high-performance solutions tailored to the specific needs of each project.
I am available for projects in the Aix-en-Provence area or fully remote.
In a world where IoT and web are increasingly converging, the ability to create real-time monitoring interfaces is becoming crucial. Through this practical tutorial, we will explore creating a complete traffic light monitoring system, combining the power of Zephyr OS for IoT with modern web technologies. This project will serve as a concrete example to understand the challenges and solutions of real-time IoT monitoring.
Note: As a Zephyr OS expert, I am available to support you in your IoT development projects. Feel free to contact me by email or on LinkedIn or via GitHub for any questions about Zephyr OS or to discuss your embedded development needs.
The complete source code for this project is available on GitHub.
Project Overview
IoT Part: Traffic Light Controller
Backend: Servers and Communication
Frontend: Monitoring Interface
Infrastructure and Deployment
Going Further
Real-time monitoring of IoT devices presents unique challenges, from state management to bidirectional communication. Our connected traffic lights project perfectly illustrates these issues: how to ensure reliable synchronization between physical devices and a web interface while maintaining optimal performance?
This educational project aims to:
Our system is built around four main components:
Important note about simulation: In this project, we simulate the IoT device in a Docker container for educational purposes. The controller simply logs state changes. In a real deployment, this controller would be installed on an actual IoT device (like a Raspberry Pi Pico) and would physically control traffic lights via its GPIO.
The Raspberry Pi Pico is an excellent choice for implementing this project in real conditions because:
To move from our simulation to a real deployment, you would need to:
Our traffic light monitoring system relies on a modern distributed architecture, designed to ensure reliable real-time communication between IoT devices and the user interface.
IoT Level
Backend Level
Frontend Level
cpp
typescript
typescript
This project has been designed to cover several essential aspects of modern IoT and web development:
In the following sections, we'll explore in detail each component of the system, starting with the IoT controller based on Zephyr OS.
Zephyr OS is an open-source real-time operating system (RTOS), particularly suited for embedded and IoT systems. In our project, it offers several key advantages:
Our traffic light controller is implemented in modern C++, using Zephyr OS features for efficient state management and communication.
cpp
cpp
Communication with the backend server is handled by a dedicated class using Zephyr's HTTP API.
cpp
cpp
The algorithm implemented in main.cpp
manages the traffic light cycle in a safe and coordinated manner. We opted for a simple and demonstrative implementation that could be enhanced for more complex use cases.
System Initialization
cpp
Main Cycle
State Change Management
cpp
Asynchronous Communication
k_msgq
Safety and Robustness
This basic implementation could be enhanced with:
Customizable Scenarios
Advanced Traffic Management
Dynamic Configuration
To implement these improvements, we would need to:
This simple version remains perfectly suited to demonstrate basic IoT and real-time communication concepts.
The prj.conf file configures Zephyr OS features for our project. This configuration enables:
These options are essential for our IoT controller to communicate over the network and send traffic light state changes to the central server.
conf
Unlike traditional operating systems like Linux that include many default modules and drivers, Zephyr OS uses a minimalist and highly configurable approach. During compilation, only strictly necessary components are included in the final image:
Difference from Traditional OS
Zephyr Approach Advantages
Granular Configuration
This "from scratch" approach allows obtaining a highly optimized and secure system, perfectly adapted to IoT constraints:
The project uses CMake for compilation:
cmake
This IoT implementation illustrates several advanced concepts:
Event-Driven Programming
Resource Management
Robustness
In the next section, we'll see how the backend handles communication with these IoT controllers and distributes updates to web clients.
Our backend consists of several services working together to ensure smooth communication between IoT controllers and the web interface.
The API Gateway is the entry point for IoT controllers. Implemented with Bun for its exceptional performance, it handles HTTP requests and maintains state consistency.
typescript
The WebSocket server ensures real-time distribution of updates to connected web clients.
typescript
Redis plays a central role in our architecture, serving both as a message broker and state store.
yaml
typescript
Our backend implements several essential communication patterns:
Pub/Sub Pattern
Gateway Pattern
Observer Pattern
Several measures are in place to ensure security and performance:
Security
Performance
Reliability
In the next section, we'll explore the user interface developed with Next.js that allows visualization and interaction with our traffic light system.
Our system's user interface is built with Next.js 15, following modern development best practices and a hexagonal architecture.
Our application follows a hexagonal architecture (ports and adapters) to maintain a clear separation of concerns:
typescript
The adapter handles communication with the backend via WebSocket:
typescript
typescript
typescript
typescript
Performance
Accessibility
Maintainability
In the next section, we'll cover the infrastructure and deployment of our application.
Our system uses Docker to ensure consistent and reproducible deployment across all environments.
yaml
shell
dockerfile
shell
json
Secret Management
Monitoring
Security
In the final section, we'll discuss testing strategies and monitoring of our application.
To make this project more robust and production-ready, several improvement areas can be explored:
To ensure system reliability, we should implement:
For effective production monitoring, we should add:
Performance
Reliability
Security
The system could be enhanced with:
Advanced Interface
Scenario Management
Scalability
For projects requiring energy autonomy (isolated sites, areas without mains power), several optimizations would be necessary:
Power Modes
cpp
Energy Saving Strategies
cpp
Solar Power
Battery Monitoring
cpp
For successful deployment, it is recommended to:
This project demonstrates the successful integration of IoT and modern web technologies to create a real-time monitoring system. Key takeaways include:
Distributed Architecture
Modern Technologies
Best Practices
This project can serve as a foundation for developing more complex IoT applications by adapting the architecture and patterns used according to your specific needs.
To get the most out of this tutorial and develop your own IoT projects, here are some practical exercise suggestions:
Simplified Version
IoT Simulation
Add WebSockets
Integrate Redis
Here are some ideas to create your own version:
Other Use Cases
Alternative Technologies
To deepen your understanding of each aspect:
Official Documentation
Example Repositories
Communities