microros-h7-pio
platformio based stm32h7 for micro-ros communication with custom transport layer (LAN/ethernet) using w5500 module.

micro-ROS + PlatformIO: Custom Message Integration
Build a micro-ROS system on your microcontroller using PlatformIO.
Define and publish custom ROS 2 messages like IMU orientation data (roll, pitch, yaw).
Reliable. Modular. Real-time ready.
Requirements
Ubuntu (20.04 or later)
ROS 2 (Humble)
PlatformIO Core
micro-ROS
MCU board (e.g., STM32 + WIZnet W5500 for Ethernet)
1. PlatformIO Setup
Install PlatformIO:pip install platformio
Clone your micro-ROS project and build:
git clone <your-micro-ros-repo>
cd <your-micro-ros-repo>
pio lib install
pio run
pio run --target upload
Select the correct environment in platformio.ini
.
2. Setup micro-ROS Agent
Install ROS 2 and source environment:
sudo apt install ros-humble-desktop
source /opt/ros/humble/setup.bash
Clone and build the agent workspace:
mkdir -p ~/uros_ws/src
cd ~/uros_ws/src
git clone -b humble https://github.com/micro-ROS/micro_ros_setup.git
cd ~/uros_ws
rosdep update
rosdep install --from-paths src --ignore-src -y
colcon build
source install/local_setup.bash
Create and run the agent:
ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.sh
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 --agent-ip 192.168.x.x
3. Create a Custom Message (ROS 2)
Create a new package:
cd ~/your_ros2_ws/src
ros2 pkg create custom_msgs --build-type ament_cmake --dependencies rosidl_default_generators std_msgs
Define your message:custom_msgs/msg/ImuInfo.msg
std_msgs/Header header
float64 roll
float64 pitch
float64 yaw
Edit CMakeLists.txt
:
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/ImuInfo.msg"
DEPENDENCIES std_msgs
)
Edit package.xml
:
<build_depend>rosidl_default_generators</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
Build it:colcon build --packages-select custom_msgs
4. Import Custom Message into PlatformIO
Copy the built custom_msgs
folder into:.pio/libdeps/<env>/micro_ros_platformio/extra_packages/
Update extra_packages.repos
:
custom_msgs:
type: local
path: custom_msgs
version: humble
Then copy the entire extra_packages/
folder into your PlatformIO project root.
Rebuild:pio run
5. Use Your Message in Code
#include <custom_msgs/msg/imu_info.h>
rcl_publisher_t euler_pub;
custom_msgs__msg__ImuInfo euler_msg;
euler_msg.roll = roll_value;
euler_msg.pitch = pitch_value;
euler_msg.yaw = yaw_value;
RCLC_PUBLISH(&euler_pub, &euler_msg);
Find the struct definition at:.pio/libdeps/<env>/.../imu_info__struct.h
6. Test & Visualize
In your ROS 2 terminal:
ros2 topic list
ros2 topic echo /imu/data
rqt_plot /imu/data/orientation/x:y:z
rviz2
Key Points
PlatformIO + micro-ROS integration
Custom message publishing over UDP
Real-time ROS 2 communication
Visualize with RViz or rqt_plot
Leverages WIZnet's reliable Ethernet stack
Simple. Modular. Real-time.
Perfect for robotics, drones, and smart sensors.