Turn on an LED on an ESP32 from a laptop1 server and a laptop2 client
sudo chmod 777 /dev/ttyUSB0 Upload the following program to the ESP32. Don't forget to connect the ESP32 to the same Wi-Fi network as your PCs.
- src/Code_ESP32/esp_led.py
Afterward, you can disconnect the ESP32 and test it with a separate 5V power supply.
Open a new terminal and source, in this case: esp32_ws/src/
create:
- ros2 pkg create --build-type ament_python py_srvcliESP --dependencies rclpy example_interfaces
- src/py_srvcliESP/py_srvcliESP/serviesp.py
- src/py_srvcliESP/py_srvcliESP/cliesp.py
- colcon build
- source install/setup.bash
SERVER: ros2 run py_srvcliESP minimal_service
CLIENT ros2 run py_srvcliESP minimal_client 1
If the argument is 1, it turns on the LED on the ESP32; if the argument is 0, the LED turns off.