---
title: "Step 2: Turning on Your First LED with an ESP32"
description: "This guide assumes that you have successfully flashed a controller. Follow either the [Windows](https://inamata.io/docs/flashing-a-controller-esp32-on-windows/) or the [Linux guide](https://inamata.io/docs/flashing-a-controller-on-linux/). At the end of this tutorial you will have registered a controller (an ESP32), set up a peripheral (an LED) and turned…"
url: "https://inamata.io/docs/turning-on-your-first-led/"
updated: "2024-01-07"
category: Getting Started
---

# Step 2: Turning on Your First LED with an ESP32

This guide assumes that you have successfully flashed a controller. Follow either the [Windows](https://inamata.io/docs/flashing-a-controller-esp32-on-windows/) or the [Linux guide](https://inamata.io/docs/flashing-a-controller-on-linux/).

At the end of this tutorial you will have registered a controller (an ESP32), set up a peripheral (an LED) and turned it on.

## Requirements

In order to complete this tutorial you will need the following. The hardware is readily available on [Amazon (list)](https://amzn.eu/bk1a78u) and other online retailers.

- 1x ESP32
- 1x MicroUSB cable (prefer shorter cables)
- 1x Computer (Windows or Linux)
- 1x Breadboard
- 1x LED
- (Optional) 220 ohm Resistor
- (Optional) Jumper cable

## Guide

### Connecting the Hardware

First of all, connect the hardware as shown in the diagram below. This connects the LED with a pin of the ESP32 that can set its voltage to high (3.3V) and the other side to a ground pin. In our tutorial we will be using pin 32 as the output pin. Take care of the LED's polarity. The flat side and the shorter leg show the negative side. This should be connected to the ESP32's ground (GND) pin. To check if your setup works, temporarily connect the plus side (rounded edge and longer leg) to the 3,3V pin of your ESP32, if your variant has it.

![](https://inamata.io/wp-content/uploads/2023/10/led_tutorial-300x230.png)

### Create an Inamata Account

If you have not signed up already, create an Inamata account by going to the [registration page](https://auth.inamata.io/realms/inamata/protocol/openid-connect/registrations?client_id=web-app&response_type=code&redirect_uri=https://app.inamata.io). Enter your details, confirm your email address (check your junk folder) and you're good to go. Otherwise, you can always register by pressing the *Register* link at the bottom of the sign in page.

![](https://inamata.io/wp-content/uploads/2023/10/unknown_001.png)

### Register a Controller (ESP32)

If you have already registered a controller ([Windows](https://inamata.io/docs/flashing-a-controller-esp32-on-windows/) / [Linux](https://inamata.io/docs/flashing-a-controller-on-linux/)), skip to the next step (Add a Data Point Type). Otherwise, [log into the app](https://app.inamata.io/) and then click *Add Controller* to open the add controller overlay. Follow the instructions to flash the controller with the Flasher app. This is separately described for [Windows](https://inamata.io/?post_type=docs&p=4290&preview=true) and [Linux](https://inamata.io/docs/flashing-a-controller-on-linux/) users. The app, for Windows and Linux, will flash the current firmware and save an authentication token on the device to allow it to automatically and securely connect to the Inamata server. If you have not already, connect your ESP32 to your computer with a micro USB cable.

![](https://inamata.io/wp-content/uploads/2023/10/unknown_002.png)

### Add a Data Point Type

 

![](https://inamata.io/wp-content/uploads/2023/10/Add_data_point_type_button.png)

Press the blue add button at the top left the devices section and select data point type. Give it a name, such as *LED state*, and a unit, such as *boolean* or *on/off*. Optionally, set the minimum and maximum value to 0 and 1. This is a soft limit and will help you when controlling your peripherals. Click *Add* to save it.

 

![](https://inamata.io/wp-content/uploads/2023/10/Screenshot-from-2023-10-28-10-45-25-e1698485400579.png)

You can view all data point types by going to the [data points page](https://app.inamata.io/en/devices/data-points) in the devices section.

![](https://inamata.io/wp-content/uploads/2023/10/data_point_page.png)

### Add a Peripheral (Red LED)

Go to the [peripherals page](https://app.inamata.io/en/devices/peripherals) via the sidebar and click add peripheral. In the first step, select the controller you want to add a peripheral to. This should have the same name you gave it in the Flasher app. Next, give it a name like *Red LED*. For peripheral type, select digital output as we'll be setting one of the controller's output pins to high to turn on the LED. Select a pin that can output a digital signal ([ESP32 pin out reference](https://randomnerdtutorials.com/esp32-pinout-reference-gpios/)). We recommend any between 16 and 33 but we will be using 32 in the following example. Press *Add* to add it to the controller.

The peripheral will show up in the peripheral table. Its state should change from *Adding* to *Added* once the command has been acknowledged by the controller.

 

![](https://inamata.io/wp-content/uploads/2023/10/Screenshot-from-2023-10-28-10-59-30.png)

 

### Turn the LED On

![](https://inamata.io/wp-content/uploads/2023/10/start_controller_task_button-1.png)

Go to the [tasks section](https://app.inamata.io/en/tasks/overview) and press the blue add button to start a controller task. In the overlay, select the controller that you registered earlier and then skip the template selection. For the task type select *Set Output*. This will allow us to change the state of the peripheral. Select the peripheral you added earlier as well as the data type. Finally set the value to 1 and press *start*.

![](https://inamata.io/wp-content/uploads/2023/10/Screenshot-from-2023-10-28-11-07-54.png)

The task should appear in the controller task table. Its state should go from *starting* to *stopped* and in the mean time your LED should turn on.

![](https://inamata.io/wp-content/uploads/2023/10/controller_task_table-1.png)

### Next Steps

You have successfully turned on the LED. For your next step, why don't you check out the [Creating your first control plan](https://inamata.io/docs/creating-your-first-control-plan/) guide where you can automate tasks and program the controllers visually.
