Top Related Projects
Main development repository for TinyOS (an OS for embedded, wireless devices).
RIOT - The friendly OS for IoT
Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.
Quick Overview
Contiki-NG is an open-source operating system for networked, memory-constrained systems with a focus on low-power Internet of Things (IoT) devices. It provides a full IP network stack and standardized low-power wireless communication, making it ideal for developing IoT applications on resource-limited hardware.
Pros
- Lightweight and efficient, suitable for resource-constrained devices
- Supports various low-power wireless standards (e.g., 6LoWPAN, RPL, CoAP)
- Active community and regular updates
- Extensive documentation and examples
Cons
- Steep learning curve for beginners
- Limited hardware support compared to some other embedded OSes
- Can be challenging to debug on target hardware
- Some features may require additional libraries or modules
Code Examples
- Basic "Hello World" example:
#include "contiki.h"
#include "sys/log.h"
PROCESS(hello_world_process, "Hello World Process");
AUTOSTART_PROCESSES(&hello_world_process);
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
LOG_INFO("Hello, World!\n");
PROCESS_END();
}
This example demonstrates a simple Contiki-NG process that prints "Hello, World!" to the console.
- LED blink example:
#include "contiki.h"
#include "dev/leds.h"
PROCESS(led_blink_process, "LED Blink Process");
AUTOSTART_PROCESSES(&led_blink_process);
PROCESS_THREAD(led_blink_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
leds_toggle(LEDS_GREEN);
}
PROCESS_END();
}
This example shows how to blink an LED using Contiki-NG's event timer and LED API.
- UDP client example:
#include "contiki.h"
#include "net/routing/routing.h"
#include "net/netstack.h"
#include "net/ipv6/simple-udp.h"
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
static struct simple_udp_connection udp_conn;
PROCESS(udp_client_process, "UDP client");
AUTOSTART_PROCESSES(&udp_client_process);
PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic_timer;
static char str[32];
uip_ipaddr_t dest_ipaddr;
PROCESS_BEGIN();
simple_udp_register(&udp_conn, UDP_CLIENT_PORT, NULL, UDP_SERVER_PORT, NULL);
etimer_set(&periodic_timer, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
etimer_reset(&periodic_timer);
if(NETSTACK_ROUTING.node_is_reachable() && NETSTACK_ROUTING.get_root_ipaddr(&dest_ipaddr)) {
snprintf(str, sizeof(str), "Hello %d", count);
simple_udp_sendto(&udp_conn, str, strlen(str), &dest_ipaddr);
}
}
PROCESS_END();
}
This example demonstrates a UDP client that sends periodic messages to a server using Contiki-NG's networking stack.
Getting Started
-
Clone the Contiki-NG repository:
git clone https://github.com/contiki-ng/contiki-ng.git
-
Set up the development environment:
- Install the required tools (compiler, debugger, etc.) for your target platform
- Set the
CONTIKI
environment variable to point to
Competitor Comparisons
Main development repository for TinyOS (an OS for embedded, wireless devices).
Pros of TinyOS-main
- Highly modular architecture, allowing for easy customization and component reuse
- Extensive documentation and community support
- Efficient power management capabilities
Cons of TinyOS-main
- Steeper learning curve due to the use of nesC programming language
- Less active development compared to Contiki-NG
- Limited support for newer hardware platforms
Code Comparison
TinyOS-main (nesC):
module BlinkC {
uses interface Timer<TMilli> as Timer0;
uses interface Leds;
}
implementation {
event void Timer0.fired() {
call Leds.led0Toggle();
}
}
Contiki-NG (C):
#include "contiki.h"
#include "dev/leds.h"
PROCESS(blink_process, "Blink");
AUTOSTART_PROCESSES(&blink_process);
PROCESS_THREAD(blink_process, ev, data) {
static struct etimer et;
PROCESS_BEGIN();
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
leds_toggle(LEDS_GREEN);
etimer_reset(&et);
}
PROCESS_END();
}
RIOT - The friendly OS for IoT
Pros of RIOT
- More extensive hardware support, including a wider range of microcontrollers and boards
- Better support for standard networking protocols like IPv6 and 6LoWPAN
- Modular architecture allowing for easier customization and feature selection
Cons of RIOT
- Larger memory footprint, which may be a concern for extremely resource-constrained devices
- Steeper learning curve due to its more complex architecture and feature set
- Less focus on power efficiency compared to Contiki-NG
Code Comparison
RIOT example (main.c):
#include "thread.h"
#include "msg.h"
int main(void)
{
msg_t msg;
msg_receive(&msg);
return 0;
}
Contiki-NG example (main.c):
#include "contiki.h"
#include "sys/etimer.h"
PROCESS(example_process, "Example Process");
AUTOSTART_PROCESSES(&example_process);
PROCESS_THREAD(example_process, ev, data)
{
PROCESS_BEGIN();
etimer_set(&timer, CLOCK_SECOND);
PROCESS_END();
}
Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
Pros of Zephyr
- Broader hardware support and device drivers
- More extensive documentation and community resources
- Advanced features like real-time capabilities and power management
Cons of Zephyr
- Steeper learning curve due to more complex architecture
- Larger memory footprint, which may be challenging for resource-constrained devices
Code Comparison
Zephyr example (main.c):
#include <zephyr/kernel.h>
void main(void)
{
printk("Hello World! %s\n", CONFIG_BOARD);
}
Contiki-NG example (hello-world.c):
#include "contiki.h"
#include "sys/log.h"
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
LOG_INFO("Hello, world\n");
PROCESS_END();
}
The code examples demonstrate the different approaches to application structure and initialization in Zephyr and Contiki-NG. Zephyr uses a more traditional main() function, while Contiki-NG employs a process-based model with PROCESS macros.
'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.
Pros of FreeRTOS
- Wider industry adoption and support
- More comprehensive documentation and learning resources
- Better suited for real-time applications with strict timing requirements
Cons of FreeRTOS
- Larger memory footprint
- Less focus on IoT and wireless networking features
- Steeper learning curve for beginners
Code Comparison
FreeRTOS task creation:
void vTaskFunction(void *pvParameters) {
for (;;) {
// Task code here
}
}
xTaskCreate(vTaskFunction, "TaskName", STACK_SIZE, NULL, TASK_PRIORITY, NULL);
Contiki-NG process creation:
PROCESS(example_process, "Example Process");
AUTOSTART_PROCESSES(&example_process);
PROCESS_THREAD(example_process, ev, data) {
PROCESS_BEGIN();
// Process code here
PROCESS_END();
}
FreeRTOS focuses on traditional RTOS task management, while Contiki-NG uses a unique process-based approach tailored for IoT devices. Contiki-NG's code structure is more event-driven and suited for low-power operations, whereas FreeRTOS provides a more familiar multitasking environment for developers coming from traditional embedded systems backgrounds.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Contiki-NG: The OS for Next Generation IoT Devices
Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions.
Unless explicitly stated otherwise, Contiki-NG sources are distributed under the terms of the 3-clause BSD license. This license gives everyone the right to use and distribute the code, either in binary or source code format, as long as the copyright license is retained in the source code.
Contiki-NG started as a fork of the Contiki OS and retains some of its original features.
Find out more:
- GitHub repository: https://github.com/contiki-ng/contiki-ng
- Documentation: https://docs.contiki-ng.org/
- List of releases and changes: https://github.com/contiki-ng/contiki-ng/releases
- Web site: http://contiki-ng.org
Engage with the community:
- Discussions on GitHub: https://github.com/contiki-ng/contiki-ng/discussions
- Contiki-NG tag on Stack Overflow: https://stackoverflow.com/questions/tagged/contiki-ng
- Gitter: https://gitter.im/contiki-ng
- Twitter: https://twitter.com/contiki_ng
Top Related Projects
Main development repository for TinyOS (an OS for embedded, wireless devices).
RIOT - The friendly OS for IoT
Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot