# Adding ESP32 Support to Arduino IDE

## Here's how to program the ESP32 using the Arduino IDE.

### Step 1: Connect your ESP32 to your computer

You'll need a USB micro B cable to connect your ESP32 to your computer. Once connected, the `power LED` will light up on the board. If your computer doesn't automatically recognize the ESP32, you may need to install the CP2102 driver from [this link](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers).

### Step 2: Open Arduino IDE

Ensure you are using **Arduino IDE version 1.8.5 or later**. Here's how to set up ESP32 in the IDE:

1. Go to **File > Preferences** in the Arduino IDE.
2. In the **"Additional Boards Manager URLs"** field, paste the following URL:\
   `https://dl.espressif.com/dl/package_esp32_index.json`\
   Then, click **OK**.

   ![Preferences](https://github.com/debjyotiC/IOT_class/blob/master/images/arduino-ide-preferences-esp32.jpg)
3. Next, go to **Tools > Board > Board Manager**.
4. In the search bar, type "esp32" and select the **"esp32 by Espressif Systems"** option. Click **Install**.

   ![Board Manager](https://github.com/debjyotiC/IOT_class/blob/master/images/arduino-board-manager-esp32.jpg)

### Step 3: Make a LED Blink using ESP32

Now that your IDE is ready, let's upload a simple blink program.

Just like NodeMCU, the ESP32 has multiple GPIO pins. Refer to the ESP32 pinout below for pin naming conventions:

![ESP32 Pinout](https://randomnerdtutorials.com/wp-content/uploads/2018/08/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs.jpg)

For this example, we'll use GPIO23 to blink an LED. Connect the LED to GPIO23 and upload the following code:

```cpp
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 23 as an output.
  pinMode(23, OUTPUT);
}
 
// the loop function runs over and over again forever
void loop() {
  digitalWrite(23, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(23, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
```
