{"id":6632,"date":"2026-11-04T02:58:59","date_gmt":"2026-11-04T05:58:59","guid":{"rendered":"https:\/\/tucumandevelopers.com\/index.php\/2026\/11\/04\/zephyr-rtos-explained-a-simple-start-on-the-esp32-s3\/"},"modified":"2026-11-04T02:58:59","modified_gmt":"2026-11-04T05:58:59","slug":"zephyr-rtos-explained-a-simple-start-on-the-esp32-s3","status":"publish","type":"post","link":"https:\/\/tucumandevelopers.com\/index.php\/2026\/11\/04\/zephyr-rtos-explained-a-simple-start-on-the-esp32-s3\/","title":{"rendered":"Zephyr RTOS Explained: A Simple Start on the ESP32-S3"},"content":{"rendered":"<div>\n<div><\/div>\n<p>A few things to notice. There is no <code>main()<\/code> loop doing the work. <code>K_THREAD_DEFINE<\/code> creates each thread when the system starts. <code>K_MSGQ_DEFINE<\/code> sets up the queue with room for 10 messages, each the size of an <code>int<\/code>.<\/p>\n<p>The producer uses <code>K_NO_WAIT<\/code>, so if the queue is ever full it does not get stuck. It just prints a note and moves on. The consumer uses <code>K_FOREVER<\/code>, so it sleeps until there is something to read. While it sleeps, it uses no CPU at all.<\/p>\n<p>Neither thread needs to know when the other runs. That is the whole point of an RTOS.<\/p>\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbu3mvmznmdymfqanh7rl.png\"><\/a><\/p>\n<h2> <a name=\"devicetree-in-a-few-words\" href=\"#devicetree-in-a-few-words\"> <\/a> Devicetree in a few words <\/h2>\n<p>On Arduino you often write something like <code>pinMode(5, OUTPUT)<\/code> right in your code. If you move to another board where the LED is on pin 12, you have to change the code.<\/p>\n<p>Zephyr puts hardware details in a separate file called a Devicetree. It says things like &#8220;this board has an LED on this pin&#8221; or &#8220;there is a sensor on this I2C bus at this address&#8221;. Your C code asks for &#8220;the LED&#8221; by name, and the build fills in the real pin. To change the wiring, you change a small overlay file, not your program. A second file type, Kconfig, turns features like logging or the shell on and off.<\/p>\n<h2> <a name=\"what-you-can-build\" href=\"#what-you-can-build\"> <\/a> What you can build <\/h2>\n<p>Once you know these pieces, the ESP32-S3 can do quite a lot under Zephyr. For example:<\/p>\n<ul>\n<li>Blinking LEDs and dimming them with PWM<\/li>\n<li>Reading a sensor over I2C<\/li>\n<li>Saving a value, like a boot count, in flash with NVS so it survives a reset<\/li>\n<li>A command shell over UART where you type commands to your board<\/li>\n<li>Driving a stepper motor through an A4988 or TMC2209 driver<\/li>\n<li>Joining a Wi-Fi network and downloading a firmware update over the air (OTA)<\/li>\n<\/ul>\n<h2> <a name=\"try-it-yourself\" href=\"#try-it-yourself\"> <\/a> Try it yourself <\/h2>\n<ol>\n<li>Change the producer to sleep for 100 ms and the consumer to sleep 1 second after each print. Watch the &#8220;queue full&#8221; message show up, and think about why.<\/li>\n<li>Add a second producer thread that sends negative numbers. Does the consumer still get every message in order of arrival?<\/li>\n<li>Replace the int with a small struct holding a number and a timestamp from <code>k_uptime_get()<\/code>, and print both in the consumer.<\/li>\n<\/ol>\n<h2> <a name=\"where-to-go-from-here\" href=\"#where-to-go-from-here\"> <\/a> Where to go from here <\/h2>\n<p>If you want to go further, we have a 24 week course, <a href=\"https:\/\/www.jupiuslearning.com\/courses\/zep-rtos-a\/\" target=\"_blank\" rel=\"noopener noreferrer\">Zephyr RTOS on ESP32-S3<\/a>. It starts with setting up Zephyr 4.1 and <code>west<\/code> on the ESP32-S3-DevKitC-1, works through threads, semaphores, message queues, timers and workqueues, and then moves on to Devicetree, GPIO, I2C, the shell, motor control, Wi-Fi and OTA, ending in a capstone project.<\/p>\n<p>One thing to know first: Zephyr code is plain C, with lots of pointers and structs. Strong C basics come first. If you have done some embedded work before, that helps too, but it is not a must.<\/p>\n<\/p><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Fuente: <a href=\"https:\/\/dev.to\/vadher_nikunj_47e8c86d866\/zephyr-rtos-explained-a-simple-start-on-the-esp32-s3-26dn\">Art\u00edculo original<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few things to notice. There is no main() loop doing the work. K_THREAD_DEFINE creates each thread when the system starts. K_MSGQ_DEFINE sets up the queue with room for 10 messages, each the size of an int. The producer uses K_NO_WAIT, so if the queue is ever full it does not get stuck. It just [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6631,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"webixso_pending_account_ids":""},"categories":[41],"tags":[],"class_list":["post-6632","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devto"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/posts\/6632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/comments?post=6632"}],"version-history":[{"count":0,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/posts\/6632\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/media\/6631"}],"wp:attachment":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/media?parent=6632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/categories?post=6632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/tags?post=6632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}