Repository for interfacing ESP32 DevKit v1 with MPU6050 IMU sensor and publishing IMU readings to ROS over Wi-Fi. This is part of my internship project of Tower Robogame at AIRLab, PoliMi
- ROS must be installed in laptop (or PC)
- Arduino IDE must be installed in laptop (or PC)
- Arduino rosserial must be installed (see this link)
- ESP32 boards software must be installed in Arduino IDE through the Boards Manager
- Download MPU6050_tockn library and save in
<installation_location>/Arduino/librariespath
| ESP32 DevKit v1 | MPU6050 IMU sensor |
|---|---|
| 3V3 | VCC |
| GND | GND |
| D21 | SDA |
| D22 | SCL |
Note : If you are using external power supply (to VIN pin), then remember to have common ground for all 3 (ESP, IMU and power supply).
- Open a terminal and do
roscoreto start the ROS master. - Do
ifconfigin another terminal and find your IP address (it is also the IP address of the ROS master) - Configure your Wi-Fi SSID, password and the ROS master IP address in the
imu_esp_ros.inofile - Upload the
imu_esp_ros.inofile to the ESP32 board through Arduino IDE - Open another terminal and run
rosrun rosserial_python serial_node.py tcp. This should allow the ESP32 to publish and subscribe to topics on the PC ROS master. - Open another terminal and run
rostopic echo /imu_datato check the output orrqt_plotto visualize the IMU data.
Note : In case the ESP32 does not connect when you do rosrun rosserial_python serial_node.py tcp, then press the EN button on the ESP32.
Note : If you are using an Arduino without Wi-Fi but connected through USB, just use rosrun rosserial_python serial_node.py /dev/ttyUSB* where you should replace the * by a number that you can find if you use ls /dev/ttyUSB. Sometimes, the command could be ls /dev/ttyACM.