With this setup, my goal is to explore the potential of software components such as Zephyr OS, Micropython, OPENPLC, and Linux in combination with industrial buses like CAN or Modbus. My primary requirement is remote accessibility, which is achieved using the Raspberry Pi 4 as the central component.
The Raspi is connected to my home Wi-Fi network, and it serves as the control hub.
- Flashing the two connected ESP32 devices (M5StickC Plus and ATOM HUB SwitchD)
- Accessing the BeagleBone Black through SSH
- Communicating with my OpenThread Network
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.
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
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: https://www.youtube.com/@thepullupresistor
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!
$cd MY_PROJECT_FOLDER$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