Skip to content

EMendezJ/ESP8266-ROSNOETIC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HOW TO CONNECT NODE-MCU WITH ROS!!!

This tutorial focuses on the setup for connecting ESP8266 and ROS NOETIC

Preliminary Information

Nodemcu

NodeMCU is a low-cost open-source IoT platform. It initially included firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems and hardware which was based on the ESP-12 module.Ref

ROS

The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms. Why? Because creating a truly robust, general-purpose robot software is hard.Ref

Rosserial

ROS Serial is a point-to-point version of ROS communications over serial, primarily for integrating low-cost microcontrollers (Arduino) into ROS.Ref

Environment

I have used the Arduino IDE to embed the rosserial to Arduino based nodemcu. I have worked on ubuntu 22.04.05 LTS and ran a Docker container with ubuntu 20.04 LTS.

Docker installation

HOW TO RUN

Clone the repository

git clone https://github.com/EMendezJ/ESP8266-ROSNOETIC.git

Build the Image

cd /ESP8266-ROSNOETIC

docker build -f Dockerfile -t ros_noetic .

Create the container

REMEMBER TO SET THE PORT TO YOUR CORRESPONDING USB PORT, KNOWN ISSUES FOR MULTIPLE USB DEVICES CONNECTED AT THE SE TIME

docker run -it \
    --name esp_noetic \
    --network host \
    --device=/dev/ttyUSB0:/dev/ttyUSB0 \
    --privileged \
    -v ~/ros_ws:/root/ros_ws \
    ros_noetic

Remember to docker run the container when exiting first time, it will stop the container.

ARDUINO IDE SET UP

Inside Arduino IDE install the rosserial library Screenshot from 2025-10-09 15-59-01 Screenshot from 2025-10-09 16-01-56

Library Correction

By default rosserial will assume that user wants to connect via TCP to the NODE-MCU, this can be easily corrected within code and inside the library files. Inside ros.h file we will need to specify only serial port usage (see example). Navigate to your libraries folder generated by arduino and inside Rosserial_Arduino_Library find the ros.h file.

Original File

Screenshot from 2025-10-09 15-15-36

File Correction

Screenshot from 2025-10-09 15-16-03

Verify Usage

Board Set Up

Inside Arduino IDE navigate to Sketch -> Examples -> Rosserial Arduino Library -> HelloWorld

Screenshot from 2025-10-09 16-13-06

Add #include <ArduinoHardware.h> to the file and upload it to the board.

Screenshot from 2025-10-09 16-16-15

ROS Set Up

Evaluation of correct functioning requires 3 terminal tabs attached to the Docker container esp_noetic

Terminal 1

docker start esp_noetic

docker exec -it esp_noetic bash

roscore

Terminal 2

docker exec -it esp_noetic bash

cd /opt/ros/noetic/lib/rosserial_arduino
rosrun rosserial_python serial_node.py

Terminal 3

docker exec -it esp_noetic bash

rostopic echo /chatter 

EXPECTED OUTPUTS

T1

Screenshot from 2025-10-09 16-24-18

T2

Screenshot from 2025-10-09 16-23-37

T3

Screenshot from 2025-10-09 16-25-07

References

https://github.com/mcagriaksoy/ros_nodemcu_rosserial_sensor ros-drivers/rosserial#398 (comment) https://wiki.ros.org/rosserial

About

Short tutorial for connecting ESP8266 and ROS NOETIC for IoT Class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published