• Small update

    Nikola02/11/2024 at 21:37 0 comments

    I made some small changes/additions to the board.

    First I had to add a USB hub. Unfortunately the Raspi could not recognize all three M5 modules at once.
    Second, I made a simple HAT for the Raspi. The Raspi now has 6 GPIOs ( 2x I2C and 2xPWM) connected to the M5 modules. The Atom Hub SwitchD modules are connected to the I2C via the extra Grove port on the SwitchD. The M5StickC Plus has PWM0 and PWM1 connected to the Grove port via a low pass filter.
    With this setup I am now able to simulate some sensors with the Raspi. This means I can now build a closed loop test setup where everything is controlled by the Raspi.

    I also made a pull request to add the ATOM Lite to the Zephyr OS repo: https://github.com/zephyrproject-rtos/zephyr/pull/68190

    And many thanks to Benjamin Cabé who prepared a large part of this board support package!

  • The right CAN bus overlay for the ATOM Light

    Nikola12/11/2023 at 21:02 0 comments

    The CAN bus modules are only connected to two ATOM HUB SwitchDs. The "intelligence" in one SwitchD is an ATOM Lite. It contains the same ESP32-PICO as the M5StickC Plus, but the gpio pins are used differently.

    As many of you may know, Zephyr OS needs to know what target it is built for and in what setting. So not only the MCU, but also the used data buses and some peripherals.
    Unfortunately, the ATOM Lite is currently not available as a target

    but the M5StickC Plus can be used.

    To build the

    example, the following command can be used

    $ west build -b m5stickc_plus samples/modules/canopennode -- -DCONF_FILE="prj_no_storage.conf"

    The only thing that needs to be added to the build is the overlay file that enables the CAN module and sets the RX/TX pins.
    How to use a device tree overlay in Zephyr can be found here


    NOTE: The CAN bus is called the TWAI (Two-Wire Automotive Interface) on the ESP32.

    To enable the TWAI in the ATOM Lite, the following lines are required in the overlay file:

    &twai {
            status = "okay";
            pinctrl-0 = <&twai_default>;
            pinctrl-names = "default";
            bus-speed = <125000>;
            can-transceiver {
                max-bitrate = <1000000>;
        &pinctrl {
            twai_default: twai_default {
                group1 {
                    pinmux = <TWAI_RX_GPIO32>,

    Maybe when I start using the ATOM Lite more with Zephyr, I will try to create a target for it and commit it to source. Like I did with the nRF52840 MDK USB dongle


  • Zephyr OS on EPS32 & Flash remotely

    Nikola12/03/2023 at 21:19 0 comments

    Zephyr OS on ESP32
    As mentioned in the description, all three modules of the M5Stack are ESP32s. I already had my Zephyr toolchain set up for ARM, but I had never used Zephyr on an ESP32 before. I found this Youtube channel very helpful:

    TIP: If you write your Zephyr code outside the usual zephyr folder, do not forget to source the zephyr-env.sh file before building the project!

    $ source ../../zephyrproject/zephyr/zephyr-env.sh
    $ west build -b esp32

    Remote flash
    As mentioned in the description, I want everything to be available remotely. But to flash Zephyr OS, I would need the toolchain on the Raspberry Pi. The Raspi runs Raspberry Pi OS. I learned from the internet that it is not easy/possible to set up the Zephyr OS toolchain for this operating system. It is recommended to use Ubuntu on the Raspi for this use case. Unfortunately, I had already set up my Raspi as an edge router for OpenThread with the Raspberry Pi OS and did not want to do that again. So I found a Linux tool called usbip. With this tool it is possible to mount a USB port over the network. Everything I need to do is written here: https://developer.ridgerun.com/wiki/index.php/How_to_setup_and_use_USB/IP