hippo5329 / micro_ros_arduino_examples_platformio

This is a port of examples from micro_ros_arduino to platformio.
0 stars 0 forks source link

How to use ESP32 with ROS2 and platformio. #1

Open drinkBr opened 3 months ago

drinkBr commented 3 months ago

I used LED_BUILTIN, which is 2 in most esp32 modules, including wroom. Wroom has two LEDs on board. The red led is power. The blue led is 2. You should see blue led lights up.

I know that the ESP32 has red and blue LEDs. What I want to do is to light up an LED that I have newly connected. I believe that LED_BUILTIN refers to the blue LED built into the ESP32, is that correct?

hippo5329 commented 3 months ago

You may change

#ifdef LED_BUILTIN
#define LED_PIN LED_BUILTIN
#else
#define LED_PIN 13
#endif

into the pin you connect the LED, say, 4.

#define LED_PIN 4

However, I would suggest you install vscode on your windows and develop remotely to your rpi. I wrote a wiki on this.

https://github.com/hippo5329/micro_ros_arduino_examples_platformio/wiki#development-on-windows-or-linux-desktop-and-use-vscode-remote-development-ssh-to-rpi45

I believe this is the better way for your project. You may fork my repos to create your forks. You will learn the github/vscode/platformio workflow. I know there will be a lot to learn on this. It will pay off and give you good results.

You may start with the Blink example. It is the "hello world" for micro-controller. It should be run when we get a new board.

https://github.com/hippo5329/Blink-platformio

In summary, this is my suggestion,

  1. install vscode to windows. use ssh to connect your rpi4.
  2. fork the Blink, use vscode on windows to clone build and upload on rp4 to esp32.

vscode on windows --> rpi4 --> esp32

  1. After the blue led 2 on esp32 blink. change the LED pin to your new LED and try out. you may commit your change and push it to github. I can review your code and give you suggestion.

Once you get familiar with this work flow, you will work better then ever. enjoy.

Let me know if you need more details.

hippo5329 commented 3 months ago

You should run "ssh-keygen -t ed25519" on both your windows and rpi4. And add the SSH public key of both to your github. You will use use "SSH" url to clone your forks instead of "HTTPS" when you clone the other people's repos.

You will install platformio and gitlens extensions to your rpi4 though vscode ssh on windows. Vscode on windows is your command center. You can open terminals in vscode on windows to run and launch ros2 on rpi4. A browser (mostly to github.com) and vscode will server your development work.

hippo5329 commented 3 months ago

I used LED_BUILTIN, which is 2 in most esp32 modules, including wroom. Wroom has two LEDs on board. The red led is power. The blue led is 2. You should see blue led lights up.

I know that the ESP32 has red and blue LEDs. What I want to do is to light up an LED that I have newly connected. I believe that LED_BUILTIN refers to the blue LED built into the ESP32, is that correct?

Correct. LED_BUILTIN is 2 on esp32.