This is an example project which allows to send array messages from an mh-z19b sensor to ros2 The code can be modified according to application.
Sample video pending ...
This example uses a CO2 sensor connected to esp32 board. The serial reading from CO2 sensor are sent over ROS2 via micro-ros. The values are in ppm according to the datasheet. In ROS2, these values are published to mhz_19b topic to demonstrate the output for this example. The value is an array. First value is counter and second value is co2 ppm value.
- Follow the tutorial here to setup the micro-ros environment.
- Clone this repository and copy the folder 'mhz19b_microros' inside your workspace such that folder structure is as [YOUR WORKSPACE]/firmware/freertos_apps/apps/mhz19b_microros
- Open terminal can follow these commands:
- ros2 run micro_ros_setup configure_firmware.sh mhz19b_microros -t udp -i [LOCAL MACHINE IP ADDRESS] -p 8888
- ros2 run micro_ros_setup build_firmware.sh
- ros2 run micro_ros_setup flash_firmware.sh
- Once the flashing is successful, run
- ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888
- Open new terminal window, and check ros topic
- ros2 topic echo /mhz_19b
ESP32 | mhz_19b Sensor |
---|---|
G12 | RX |
G13 | TX |
5V | VCC |
GND | GND |
ESP32 | ROS2 Topic |
---|---|
Counter | data[0] |
CO2 PPM | data[1] |