<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tuomas Louekari on Medium]]></title>
        <description><![CDATA[Stories by Tuomas Louekari on Medium]]></description>
        <link>https://medium.com/@ninjapiraatti?source=rss-11949ac61a1d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C1azh97SdzmppF67nLAuyg.jpeg</url>
            <title>Stories by Tuomas Louekari on Medium</title>
            <link>https://medium.com/@ninjapiraatti?source=rss-11949ac61a1d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 19:28:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ninjapiraatti/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an omniwheel platform with Rust and ESP32C6]]></title>
            <link>https://medium.com/@ninjapiraatti/building-an-omniwheel-platform-with-rust-and-esp32-c6-cf625e38615a?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf625e38615a</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[robotics]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 15:45:20 GMT</pubDate>
            <atom:updated>2026-07-04T15:48:17.233Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*tZ8KhQEySCyudYMSR_1HzQ.gif" /></figure><p>I’ve been messing around with ESP32s now for a bit, and wanted to build a fun project that would have at least a few problems to solve. This one turned out to be just that and more. This text is not really a tutorial but rather highlights some challenges you might come across in similar projects. The code can be found <a href="https://github.com/ninjapiraatti/rude-honker">here</a>.</p><p>The setup (so far) is two ESP32C6s talking to each other via ESP-NOW. One is the controller with nothing but a joystick module plugged into it. The other one is more involved, controlling two TB6612FNGs that drive the four motors needed for the omniwheel functionality.</p><p><strong>TB6612FNG and pulse width modulation</strong></p><p>Perhaps the trickiest part of the entire project was to get a total of four signals for the two TB6612FNGs. I couldn’t for the life of me understand how to implement that in Rust. The nitty-gritty of how pulse width modulation for motors works in ESP-HAL can be found <a href="https://docs.rs/esp-hal/latest/esp_hal/mcpwm/index.html">here</a>. I was stuck with the assumption that each operator gives you one pulse, but once I found the with_pins() method, I was able to provide each TB6612FNG with two signals, therefore controlling two motors each.</p><p><strong>Power</strong></p><p>The four motors (or rather the two TB6612FNGs) are powered by four rechargeable 1.2V AA batteries, and the ESP32C6 by a single 4.2V 18650 battery. It’s always been a struggle to find the right combination of batteries for ESP32s, but the 18650 has now worked reliably in a couple of projects. I just hooked it up directly to the 3.3V pin.</p><p><strong>Conclusion and what’s next</strong></p><p>As per usual, working with a relatively young ecosystem that is embedded Rust and the mystery that is electronics, it took a while to get anything working. This was also the first project where Claude Code was actually useful instead of going around in circles.</p><p>Next, I will build something that goes on top of the platform, possibly a robot arm.</p><p>If you see anything weird in the code or any other aspect of the project, let me know!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf625e38615a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust on ESP32: TB6612FNG and making a DC motor run]]></title>
            <link>https://medium.com/@ninjapiraatti/rust-on-esp32-tb6612fng-and-making-a-dc-motor-run-ccc80653761a?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccc80653761a</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[esp32]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Mon, 21 Apr 2025 05:59:57 GMT</pubDate>
            <atom:updated>2025-04-21T05:59:57.960Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OJb9IsLPr_YpQ8RQcPKu_A.jpeg" /></figure><p>At the time of writing this, <a href="https://github.com/esp-rs/esp-hal">esp-hal </a>has been updated to 1.0.0-beta.0. Most of my previous projects have been based on that, and I wanted to try it out.</p><p>Some time ago I tested TB6612FNG, a motor driver that is said to be better than the more common L298N, which often ships with hobby kits and shitty stepper motors. The chip performed fine, but the esp-hal update broke the code I was running on it.</p><p>So I decided to build a little sandbox for ESP32C6 that would run some motors, maybe flash its internal RGB led and so on, using the new esp-hal.</p><p>I found a <a href="https://crates.io/crates/tb6612fng">driver</a> for the TB6612FNG, but there was only an example for STM. It took me a day to write a working example for ESP32:</p><pre>#![no_std]<br>#![no_main]<br><br>use esp_hal::clock::CpuClock;<br>use esp_hal::main;<br>use esp_hal::timer::timg::TimerGroup;<br>use esp_println::println;<br>use esp_hal::{<br>    delay::Delay,<br>    gpio::{Level, Output, OutputConfig},<br>    mcpwm::{operator::PwmPinConfig, PeripheralClockConfig, McPwm, timer::PwmWorkingMode},<br>    time::Rate,<br>};<br>use tb6612fng::{DriveCommand, Motor};<br><br>#[panic_handler]<br>fn panic(_: &amp;core::panic::PanicInfo) -&gt; ! {<br>    loop {}<br>}<br><br>extern crate alloc;<br><br>#[main]<br>fn main() -&gt; ! {<br>    // generator version: 0.3.1<br><br>    let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());<br>    let peripherals = esp_hal::init(config);<br><br>    let mut test_pin = Output::new(peripherals.GPIO7, Level::Low, OutputConfig::default());<br>    //let mut led_pin_a = Output::new(peripherals.GPIO8, Level::Low, OutputConfig::default());<br><br>    // Motor stuff<br>    let motor_a_pin1 = Output::new(peripherals.GPIO5, Level::Low, OutputConfig::default());<br>    let motor_a_pin2 = Output::new(peripherals.GPIO6, Level::Low, OutputConfig::default());<br>    let mut stdby_pin = Output::new(peripherals.GPIO0, Level::Low, OutputConfig::default());<br><br>    let clock_cfg = PeripheralClockConfig::with_frequency(Rate::from_mhz(40)).unwrap();<br>    let motor_a_pwm_pin = peripherals.GPIO4;<br>    let mut mcpwm = McPwm::new(peripherals.MCPWM0, clock_cfg);<br>    mcpwm.operator0.set_timer(&amp;mcpwm.timer0);<br>    let motor_a_pwm = mcpwm.operator0.with_pin_a(motor_a_pwm_pin, PwmPinConfig::UP_ACTIVE_HIGH);<br>    let mut motor_a = Motor::new(motor_a_pin1, motor_a_pin2, motor_a_pwm).unwrap();<br><br>    let timer_clock_cfg = clock_cfg<br>        .timer_clock_with_frequency(99, PwmWorkingMode::Increase, Rate::from_khz(20))<br>        .unwrap();<br>    mcpwm.timer0.start(timer_clock_cfg);<br>    stdby_pin.set_high();<br><br>    // From the template<br>    esp_alloc::heap_allocator!(size: 72 * 1024);<br><br>    let timg0 = TimerGroup::new(peripherals.TIMG0);<br>    let _init = esp_wifi::init(<br>        timg0.timer0,<br>        esp_hal::rng::Rng::new(peripherals.RNG),<br>        peripherals.RADIO_CLK,<br>    )<br>    .unwrap();<br><br>    let delay = Delay::new();<br><br>    loop {<br>        test_pin.set_high();<br>        <br>        motor_a.drive(DriveCommand::Forward(100)).expect(&quot;could set drive speed&quot;);<br>        println!(&quot;Debug: {:?}&quot;, motor_a.current_drive_command());<br>        delay.delay_millis(2500);<br><br>        motor_a.drive(DriveCommand::Backward(100)).expect(&quot;could set drive speed&quot;);<br>        println!(&quot;Debug: {:?}&quot;, motor_a.current_drive_command());<br>        delay.delay_millis(2500);<br>    }<br><br>    // for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0-beta.0/examples/src/bin<br>}</pre><p>Prior to this, I didn’t even know that the speed of the motor was controlled by <a href="https://en.wikipedia.org/wiki/Pulse-width_modulation">Pulse-width modulation</a>, and I really had no idea what to output to the PWM pin. To be fair, there’s still a lot in the code above I don’t understand. For example, what really is McPwm? Any comments on the code are much appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccc80653761a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust on ESP32, part 3: Writing a simple driver for an old soviet switch]]></title>
            <link>https://medium.com/@ninjapiraatti/rust-on-esp32-part-3-writing-a-simple-driver-for-an-old-soviet-switch-b5cafec79051?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5cafec79051</guid>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Wed, 12 Jun 2024 06:54:54 GMT</pubDate>
            <atom:updated>2024-06-12T06:59:27.296Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cemt13Q9qByjefb4fXdcnQ.jpeg" /><figcaption>I found this thing in a Latvian flea market. It’s a peculiar switch with one toggle position (top in this picture) and two positions (bottom) that return to neutral acting more like buttons.</figcaption></figure><p>First of all, I’d like to point out that many of the concepts and practices related to this project are still out of my comfort zone so regard this article as more of a hobbyist’s ramblings rather than a tutorial.</p><p>Let’s start with the repo, it can be found <a href="https://github.com/ninjapiraatti/old-soviet-switch">here</a>. The code is divided into lib.rs (the driver itself) and main.rs, acting as an example of the usage. The entire little project leans heavily to <a href="https://github.com/apollolabsdev/ESP32C3/blob/main/no_std_examples/gpio-interrupt/src/main.rs">this</a> example and the Embedded Rust Book chapter on <a href="https://docs.rust-embedded.org/book/concurrency/index.html">concurrency</a>.</p><p>As for the hardware, if you build something similar, make sure that the pins you’re using are interrupt enabled. Refer to the pinout of your board. In the case of ESP32C3, all GPIO pins can be used for interrupts.</p><p>Perhaps the most important new concepts in this project were mutex and critical section. Mutex is basically an object that prevents multiple threads accessing the same shared resource. In this case, this resource is the OLD_SOVIET_SWITCH in the top of the example. Critical section, in turn, is a section of code during which the interrupt won’t fire.</p><p>Another interesting problem was to determine which parts of the code belong to the driver and which to the example. At first, I tried to have the static item inside the driver, but that would mean that I could never have more than one instance of the switch. This is how I ended up dividing the code:</p><p>lib.rs:</p><pre>#![no_std]<br>#![no_main]<br><br>use esp32c3_hal::{<br>    gpio::{<br>        Event, InputPin,<br>    },<br>    interrupt,<br>    peripherals::{self},<br>};<br>use esp_backtrace as _;<br><br>pub struct OldSovietSwitch&lt;T1, T2, T3&gt;<br>where<br>    T1: InputPin,<br>    T2: InputPin,<br>    T3: InputPin,<br>{<br>    pub pin1_main: T1,<br>    pub pin2_bottom_left: T2,<br>    pub pin3_bottom_right: T3,<br>}<br><br>pub struct OldSovietSwitchState {<br>    pub pin1_main_high: bool,<br>    pub pin2_bottom_left_high: bool,<br>    pub pin3_bottom_right_high: bool,<br>}<br><br>impl &lt;T1, T2, T3&gt; OldSovietSwitch&lt;T1, T2, T3&gt;<br>    where<br>    T1: InputPin,<br>    T2: InputPin,<br>    T3: InputPin,<br>{<br>    pub fn new(<br>        pin1_main: T1,<br>        pin2_bottom_left: T2,<br>        pin3_bottom_right: T3,<br>    ) -&gt; Self {<br>        let mut instance = Self {<br>            pin1_main,<br>            pin2_bottom_left,<br>            pin3_bottom_right,<br>        };<br><br>        instance.setup();<br>        instance<br>    }<br><br>    pub fn setup(&amp;mut self) {<br>        self.pin1_main.listen(Event::FallingEdge);<br>        self.pin2_bottom_left.listen(Event::FallingEdge);<br>        self.pin3_bottom_right.listen(Event::FallingEdge);<br>        interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority3).unwrap();<br>    }<br>    pub fn read_state(&amp;mut self) -&gt; OldSovietSwitchState {<br>        self.pin1_main.clear_interrupt();<br>        self.pin2_bottom_left.clear_interrupt();<br>        self.pin3_bottom_right.clear_interrupt();<br>        OldSovietSwitchState {<br>            pin1_main_high: self.pin1_main.is_input_high(),<br>            pin2_bottom_left_high: self.pin2_bottom_left.is_input_high(),<br>            pin3_bottom_right_high: self.pin3_bottom_right.is_input_high(), <br>        }<br>    }<br>}</pre><p>main.rs:</p><pre>#![no_std]<br>#![no_main]<br><br>use core::cell::RefCell;<br>use critical_section::Mutex;<br>use esp32c3_hal::{<br>    clock::ClockControl,<br>    gpio::{Gpio4, Gpio5, Gpio6, Input, PullDown, IO},<br>    peripherals::Peripherals,<br>    prelude::*,<br>    Delay,<br>};<br>use esp_backtrace as _;<br>use esp_println::println;<br>use old_soviet_switch::*;<br><br>static OLD_SOVIET_SWITCH: Mutex&lt;RefCell&lt;Option&lt;OldSovietSwitch&lt;<br>Gpio6&lt;Input&lt;PullDown&gt;&gt;,<br>Gpio5&lt;Input&lt;PullDown&gt;&gt;,<br>Gpio4&lt;Input&lt;PullDown&gt;&gt;<br>&gt;&gt;&gt;&gt; = Mutex::new(RefCell::new(None));<br><br>#[entry]<br>fn main() -&gt; ! {<br>    let peripherals = Peripherals::take();<br>    let system = peripherals.SYSTEM.split();<br>    let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);<br>    let main_switch = io.pins.gpio6.into_pull_down_input();<br>    let bottom_left = io.pins.gpio5.into_pull_down_input();<br>    let bottom_right = io.pins.gpio4.into_pull_down_input();<br><br>    let clocks = ClockControl::max(system.clock_control).freeze();<br>    let mut delay = Delay::new(&amp;clocks);<br>    let ivan = OldSovietSwitch::new(<br>        main_switch,<br>        bottom_left,<br>        bottom_right,<br>    );<br>    critical_section::with(|cs| OLD_SOVIET_SWITCH.borrow_ref_mut(cs).replace(ivan));<br><br>    println!(&quot;Old soviet switch says hi.&quot;);<br>    loop {<br>        delay.delay_ms(500u32);<br>        println!(&quot;Loop..&quot;);<br>    }<br>}<br><br>#[interrupt]<br><br>fn GPIO() {<br>    critical_section::with(|cs| {<br>        let switch_states = OLD_SOVIET_SWITCH.borrow_ref_mut(cs).as_mut().unwrap().read_state();<br>        println!(&quot;1 High: {:?}&quot;, switch_states.pin1_main_high);<br>        println!(&quot;2 High: {:?}&quot;, switch_states.pin2_bottom_left_high);<br>        println!(&quot;3 High: {:?}&quot;, switch_states.pin3_bottom_right_high);<br>    });<br>}</pre><p>The switch is simple enough that I could’ve achieved the same result by simply listening to the pins without the driver. However, this example could easily be expanded to accommodate a more complex physical device, and then the need for abstraction would be obvious.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5cafec79051" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust on ESP32, part 2: Flashing ESP32C3 with a simple example]]></title>
            <link>https://medium.com/@ninjapiraatti/rust-on-esp32-part-2-flashing-esp32c3-with-a-simple-example-526f88e549bc?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/526f88e549bc</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Sun, 17 Dec 2023 11:57:24 GMT</pubDate>
            <atom:updated>2024-06-12T06:58:42.199Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*LVqoc7EZ3mZr-RTib_uCHw.gif" /></figure><p>In the <a href="https://medium.com/@ninjapiraatti/rust-on-esp32-part-1-simulate-esp32c3-in-vscode-2df81604f1e3">previous post</a>, we were able to simulate an ESP32C3 in VsCode. Let’s try and take it a bit further by first writing some simple code and then actually flashing the board.</p><p>The code is very little more than the ESP template with few lines added for the rotary encoder:</p><pre>#![no_std]<br>#![no_main]<br><br>extern crate alloc;<br>use core::cell::RefCell;<br>use critical_section::Mutex;<br>use core::mem::MaybeUninit;<br>use esp_backtrace as _;<br>use esp_println::println;<br>use hal::{<br>    clock::ClockControl,<br>    gpio::{<br>        Event,<br>        Gpio4,<br>        Gpio6,<br>        Input,<br>        Output,<br>        PullDown,<br>        IO,<br>        PushPull<br>    },<br>    peripherals::{self, Peripherals},<br>    interrupt,<br>    prelude::*,<br>    Delay<br>};<br><br>use esp_wifi::{initialize, EspWifiInitFor};<br><br>use hal::{systimer::SystemTimer, Rng};<br>#[global_allocator]<br>static ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();<br>static BUTTON: Mutex&lt;RefCell&lt;Option&lt;Gpio6&lt;Input&lt;PullDown&gt;&gt;&gt;&gt;&gt; = Mutex::new(RefCell::new(None));<br>static LED: Mutex&lt;RefCell&lt;Option&lt;Gpio4&lt;Output&lt;PushPull&gt;&gt;&gt;&gt;&gt; = Mutex::new(RefCell::new(None));<br><br>fn init_heap() {<br>    const HEAP_SIZE: usize = 32 * 1024;<br>    static mut HEAP: MaybeUninit&lt;[u8; HEAP_SIZE]&gt; = MaybeUninit::uninit();<br><br>    unsafe {<br>        ALLOCATOR.init(HEAP.as_mut_ptr() as *mut u8, HEAP_SIZE);<br>    }<br>}<br>#[entry]<br>fn main() -&gt; ! {<br>    init_heap();<br>    let peripherals = Peripherals::take();<br>    let system = peripherals.SYSTEM.split();<br>    let clocks = ClockControl::max(system.clock_control).freeze();<br>    let mut delay = Delay::new(&amp;clocks);<br><br>    // setup logger<br>    // To change the log_level change the env section in .cargo/config.toml<br>    // or remove it and set ESP_LOGLEVEL manually before running cargo run<br>    // this requires a clean rebuild because of https://github.com/rust-lang/cargo/issues/10358<br>    esp_println::logger::init_logger_from_env();<br>    log::info!(&quot;Logger is setup&quot;);<br>    println!(&quot;Hello world!&quot;);<br><br>    let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);<br>    let mut rotary_input = io.pins.gpio6.into_pull_down_input();<br>    let mut led = io.pins.gpio4.into_push_pull_output();<br>    led.set_high().unwrap();<br>    rotary_input.listen(Event::FallingEdge);<br><br>    critical_section::with(|cs| BUTTON.borrow_ref_mut(cs).replace(rotary_input));<br>    critical_section::with(|cs| LED.borrow_ref_mut(cs).replace(led));<br><br>    interrupt::enable(peripherals::Interrupt::GPIO, interrupt::Priority::Priority3).unwrap();<br><br>    let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;<br>    let _init = initialize(<br>        EspWifiInitFor::Wifi,<br>        timer,<br>        Rng::new(peripherals.RNG),<br>        system.radio_clock_control,<br>        &amp;clocks,<br>    )<br>    .unwrap();<br>    loop {<br>        delay.delay_ms(1500u32);<br>    }<br>}<br><br>#[interrupt]<br>fn GPIO() {<br>    critical_section::with(|cs| {<br>        println!(&quot;GPIO interrupt&quot;);<br>        BUTTON<br>            .borrow_ref_mut(cs)<br>            .as_mut()<br>            .unwrap()<br>            .clear_interrupt();<br>        if let Some(led) = LED.borrow_ref_mut(cs).as_mut() {<br>            if led.is_set_high().unwrap() {<br>                led.set_low().unwrap();<br>            } else {<br>                led.set_high().unwrap();<br>            }<br>        }<br>    });<br>}</pre><p>One thing worth pointing out is that even though the loop does nothing, the GPIO function is still called on interrupt. Unlike many boards, in ESP32C3 any GPIO pin can be used to listen for interrupts.</p><p>This is what I built. It’s a simple thing that toggles a led with the rotary encoder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q6lJwcUT7NNRr-JYGxq5mw.png" /></figure><p>Flashing should be as simple as running cargo run from your project directory.</p><p>One hurdle I had to tackle with this specific board was that it couldn’t be flashed with the existing USB serial drivers because of the CH340 converter chip. If for some reason the flashing won’t work, have a look at the chips on your board and look for “CH340”. If you have this chip, there’s a good chance that <a href="https://kig.medium.com/how-to-use-cheap-chinese-arduinos-and-other-boards-that-come-with-with-ch340g-ch341g-serial-usb-c0995aeca5d3">this article</a> will help you.</p><p>In the <a href="https://medium.com/@ninjapiraatti/rust-on-esp32-part-3-writing-a-simple-driver-for-an-old-soviet-switch-b5cafec79051">final part</a>, I will explore writing a driver for an old soviet switch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=526f88e549bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust on ESP32, part 1: Simulate ESP32C6 in VSCode]]></title>
            <link>https://medium.com/@ninjapiraatti/rust-on-esp32-part-1-simulate-esp32c3-in-vscode-2df81604f1e3?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2df81604f1e3</guid>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Sat, 28 Oct 2023 07:22:13 GMT</pubDate>
            <atom:updated>2026-01-30T12:49:21.521Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cQ1OiN3zOvPLzE5v9TgQ3w.jpeg" /><figcaption>When an eel bites your thigh and you bleed out and die, that’s a moraaayy</figcaption></figure><p>Hox! Article updated 30th of January 2026.</p><p>Let’s get the disclaimers out of the way first. I’m not exactly a seasoned embedded developer, so I’m probably making mistakes along the way. If you see any, please let me know! Also, this entire process and much more is written in <a href="https://docs.espressif.com/projects/rust/book/">The Rust on ESP Book</a>.</p><p>I found running Rust on any MCUs a little tricky, to say the least, but then I stumbled into <a href="https://github.com/esp-rs/esp-generate">esp-generate</a> by <a href="https://github.com/SergioGasquez">Sergio Gasquez</a>. That, together with <a href="https://docs.wokwi.com/vscode/getting-started">Wokwi VSCode extension</a> made it incredibly easy to get up and running. Let’s get started!</p><p>I chose ESP32C6 for this project because I like the philosophy of RISC-V’s open-source ISA, but this should work on any ESPs listed on the esp-generate.</p><p>First, you need to install some prerequisites:</p><p><a href="https://github.com/esp-rs/esp-generate">esp-generate</a> (for actually using the esp-template):<br>cargo install esp-generate<br><a href="https://docs.wokwi.com/vscode/getting-started">Wokwi for VS Code</a> (follow that link for instructions)</p><p>Next, let’s create a starter project with the esp-template:<br>esp-generate</p><p>This will prompt you for the project details like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yh9eL7K5R12ASaI7tuUWyg.png" /></figure><p>You’ll find Wokwi under the Options. Check unstable-hal and alloc for Wi-Fi and BLE. After this, build your project from its folder as usual:<br>cargo build</p><p>You should now be able to run the simulator in your VSCode. Open the command palette (shift+cmd+p for Mac) and choose Wokwi: Start Simulator.</p><p>For me, the executable name differs from the one in wokwi.toml so if you get an error for firmware binary target, just edit wokwi.toml to correct the filename. My binary had dashes, but Wokwi used underscores.</p><p>If you’re looking at something like this, great success:</p><figure><img alt="Wokwi simulator" src="https://cdn-images-1.medium.com/max/1024/1*aFp_vpXqr_32lL464F9w3g.jpeg" /></figure><p>Then just go wild with it! I highly recommend <a href="https://wokwi.com/">Wokwi</a> for examples, community, and more. They even have the option to flash devices directly, but that’s another story entirely. In <a href="https://medium.com/@ninjapiraatti/rust-on-esp32-part-2-flashing-esp32c3-with-a-simple-example-526f88e549bc">part 2</a>, we’ll flash the board from the command line.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2df81604f1e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The journey from Piscine to a full-time coding job]]></title>
            <link>https://medium.com/@ninjapiraatti/the-journey-from-piscine-to-a-full-time-coding-job-3afc948a46ae?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3afc948a46ae</guid>
            <category><![CDATA[ecole-42]]></category>
            <category><![CDATA[hive-helsinki]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 07:51:26 GMT</pubDate>
            <atom:updated>2022-11-06T07:54:00.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RAO24gQEsjXaI9DRyezTcg.jpeg" /><figcaption>Like the tee? get it from kujukai.com</figcaption></figure><p>Hi! I’m Tuomas, a geriatric millennial who likes to build things. This piece is targeted at fellow Hive Helsinki students but if you’re entering a career in software development you might find it useful regardless. This is how things worked out for me so your mileage may vary.</p><p>Cast aside your ego the best you can, refine your sense of boundaries and self-awareness, help people, and be freaking curious. That’s all, you don’t need to read further.</p><h3>Piscine</h3><p>Piscine was quite the rollercoaster and I think it’s likely designed to test your stamina and people skills more than technical aptitude. You will ride the highs of figuring out recursion and the lows of failing multiple days in a row. As they say, don’t panic. Power through the best you can and get to know the people around you when you have the energy. You’re not competing against them — you will be working and having fun with them for years to come.</p><p>Don’t expect to have a whole lot of social life during the Piscine. I averaged 12 hours a day, weekends included and most of the students I’ve talked with reported similar numbers. Wear comfortable shoes (or none at all), take breaks when your brain starts to melt and get as much sleep as possible.</p><p>If you want to make the Piscine a little bit easier, learn the basics of Git, Vim/Emacs, and shell. I would advise against learning a whole lot of C besides the very very basics because the tools you’d normally use will be off-limits in 42.</p><h3>Hive Helsinki</h3><p>42 curriculum is no joke. In a year, you will be building shit that right now seems completely impossible. It’s a lot of work but the rewards are worth it. I’d like to stress that you don’t need to be some kind of genius or have years of experience in coding. It’s far more important to be curious and find ways to learn the ropes — this is where your fellow students will play a big role. The peer-to-peer learning model gives you so much more when you talk code with many different people and understand their way of tackling the same problem. It’s also more fun and educational to ace a project in a team than on your own. So help, be helped, and have fun!</p><p>In retrospect, it would’ve been useful to better learn how to learn. Many 42 projects require quite a bit of planning and research and you might spend too much time banging your head against the wall if you just start churning out code like in Piscine. Having a little bit of patience is not only the faster way but also the way to grow your understanding of the underlying concepts and to improve your confidence in your own code.</p><p>At this point, it is worthwhile to understand the importance of testing and to start building tests routinely. For a long time, I saw them as a necessary evil blocking me from getting stuff done. Instead of making the same mistake, read up on test-driven development and even if it doesn’t immediately speak to your soul, try it out. There’s a really good chapter on it in Clean Code by Rober Cecil Martin, you can find it in the campus library.</p><p>Explore as much as you can during your studies. The curriculum alone might land you a job but you will have a better overall understanding of software development if you dabble in Docker, cloud infrastructure, web development, and other languages besides C.</p><h3>Internship</h3><p>When you’re approaching the internship, there are many steps to improve your odds. First of all, update your GitHub to reflect your skills. Pick some good projects for the featured repositories section, update your bio, and improve the readmes of the relevant projects. The importance of a readable, coherent, and relevant GitHub profile can hardly be overestimated.</p><p>Another very good opportunity for demonstrating skills is a CV website. I did the PDF version as well of course, but I made sure to include a link to the CV website when applying for a position. With a CV website, you can express technical skills in a very tangible way while also giving the recruiter your basic info and history.</p><p>A cover letter is very important. It also goes hand in hand with the idea of applying only to companies that interest you. If you’re writing a cover letter and can’t express why you’re interested in working for the company, it might be a good reason not to apply in the first place. A well-written cover letter showing your interest in the company and demonstrating what value you can bring can go a long way in getting an interview.</p><p>Whatever the level of your preparation, the actual work is to just apply to interesting companies. I think quality over quantity is a good philosophy here. Do fewer but better applications: read about the company, think about how you would fit, and provide examples of your skills and motivation.</p><p>Good employers are not primarily looking for hard skills. They are important, yes, but it is critical to have the right attitude toward the work. By this, I don’t mean the willingness to crunch or some false positivity, but the genuine curiosity about whatever you’re about to start. So apply to companies that really interest you and whose values align with yours as much as possible but don’t be overly picky — you have to start somewhere.</p><p>Once you’re actually doing the internship, make the most of it. It’s a great opportunity to learn in a relatively stress-free environment so go to town. Ask the poor senior developer to explain everything. Most likely they will gladly answer time after time.</p><p>Chances are, you will get a job offer following your internship. At this point, I think the most important question is do you like to work with your team? If the answer is yes, consider also the direction the role would take you professionally. Is the tech something you’d like to learn more about? Will the job shape you towards a specialist or a well-versed consultant?</p><p>To sum it up, follow your curiosity. If it’s not yet very refined, try out different things as much as possible.</p><h3>Entering the IT career</h3><p>By now you probably have an idea of what kind of company would be a good fit for you. “Any” is also a good answer now but not a few years later. Scope out companies that seem good, ask around about their reputation, and apply.</p><p>Ask tough questions in interviews. Good companies have little trouble answering them and they like you more for asking. Congratulations, you have a coding job!</p><p>This is where you start to get actual responsibilities and it becomes increasingly important to take care of yourself and give a lot of thought to what you really want to do and how much. If you’re ancient like me, you might not want to crunch until you drop working for a startup or a gaming company.</p><p>Coding is just another job and at the same time, a little bit more. On a good day, it’s 42 all over again. On a bad day, it’s 42 all over again but you get paid.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3afc948a46ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming Arduino with Rust on Mac]]></title>
            <link>https://medium.com/@ninjapiraatti/programming-arduino-with-rust-on-mac-7c7536f3973d?source=rss-11949ac61a1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c7536f3973d</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[arduino]]></category>
            <dc:creator><![CDATA[Tuomas Louekari]]></dc:creator>
            <pubDate>Sat, 19 Feb 2022 13:06:31 GMT</pubDate>
            <atom:updated>2023-02-25T07:48:02.738Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtVPXEJua4gAiG6Hr8uXMA.jpeg" /><figcaption>Like the mug? Check out kujukai.com.</figcaption></figure><blockquote>Update 25.2.2023: If you can use ESP32 in your project instead of Arduino, you can make use of <a href="https://wokwi.com/">wokwi.com</a>, where you can simulate and flash your board effortlessly.</blockquote><p>This is a step-by-step guide on how to setup Rust on macOS (M1) to program your Arduino board with it. I used Arduino Nano but this is applicable to other boards too.</p><p>I will skip the theory entirely but here are some good reads for background:<br><a href="https://docs.rust-embedded.org/book/">The Embedded Rust Book</a><br><a href="https://chipwired.com/programming-arduino-with-rust/">The blog post where I started</a><br>..and also <a href="https://github.com/ninjapiraatti/congenital-optimist">Link to my repo</a></p><p>After a bunch of failed attempts, I stumbled upon avr-hal. Before I did though, I had already installed avr-gcc and avrdude:</p><pre>brew install avr-gcc<br>brew install avrdude</pre><p>After that, I installed ravedude and cargo-generate like so:</p><pre>cargo +stable install ravedude<br>cargo +stable install cargo-generate</pre><p>I followed the next step in avr-hal’s instructions and started a new project from avr-hal-template:</p><pre>cargo generate — git <a href="https://github.com/Rahix/avr-hal-template.git">https://github.com/Rahix/avr-hal-template.git</a></pre><p>Almost done! The last step I needed to do was to modify the config.toml under the project’s .cargo folder. I may have missed some automatic step but I needed to tell the exact location of my Arduino chip connected in USB. For me, the line in config.toml looked like this:</p><pre>runner = “ravedude nano -P /dev/tty.usbserial-140 — open-console — baudrate 57600”</pre><p>If you don’t know which one of the devices is your chip, you can run</p><pre>ls -lha /dev/tty/*</pre><p>And compare results when the device is plugged and unplugged.</p><p>After these steps, I was able to run Rust on my Arduino Nano simply with cargo run because the avr-hal-template takes care of most things. It’s worth noting that the template forces the project to run the nightly build (see rust-toolchain.toml).</p><p>Hopefully this will help you get started! Please let me know if I missed a step, it was a bit messy setup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c7536f3973d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>