# ESP-IDF

The Espressif documentation is great to [get started](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/). We advise you to read it if you are not familiar with the ESP-IDF. If you've got any issue setting up the example, the solution can probably be found in the ESP-IDF documentation.

Below is a summary.

## Install ESP-IDF

{% tabs %}
{% tab title="Unix" %}

```
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh
. export.sh
idf.py set-target esp32
```

{% endtab %}
{% endtabs %}

Sourcing `export.sh` will set important environment variables that will be used when compiling the example. Make sure to use the same terminal window afterwards.

## Compile the example

Go to `examples/esp32` and run:

```
idf.py build
```

## Flash onto the Device

From `examples/esp32`, run:

```
idf.py [-p PORT] flash
```

## Monitor

Print the logs:

```
$ idf.py [-p PORT] monitor

[...]

I (4676) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:260a:c4ff:fe00:3a50, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (6176) esp_netif_handlers: example_connect: sta ip: 192.168.1.26, mask: 255.255.255.0, gw: 192.168.1.254
I (6176) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.1.26
I (6186) example_connect: Connected to example_connect: sta
I (6186) example_connect: - IPv4 address: 192.168.1.26
I (6196) example_connect: - IPv6 address: fe80:0000:0000:0000:260a:c4ff:fe00:3a50, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (6206) vertices_example: Connected to AP, begin http example
I (6216) vertices_example: 💳 Alice's account E3PGTXKDOODVQ3E2ZB5PMJF2W3YOKIPUPLFDTESSP6562QE4GTLAKO4VXY
I (6226) http_esp: HTTP init: https://api.testnet.algoexplorer.io
I (9006) http_esp: HTTP GET Status = 200, content_length = 5
I (9276) http_esp: HTTP GET Status = 200, content_length = 232
I (9286) vertices_example: 🏎 Running on testnet-v1.0 v.2.5.0
🟢 [/Users/cyril/Documents/work/vertices/c-vertices-sdk/src/account.c:42] 👛 Added account to wallet: #0
I (9486) http_esp: HTTP GET Status = 200, content_length = 27
I (9496) vertices_example: 🤑 10.974142 Algos on Alice's account (E3PGTXKDOODVQ3E2ZB5PMJF2W3YOKIPUPLFDTESSP6562QE4GTLAKO4VXY)
🟢 [/Users/cyril/Documents/work/vertices/c-vertices-sdk/src/account.c:42] 👛 Added account to wallet: #1
I (9736) http_esp: HTTP GET Status = 200, content_length = 27
I (10536) http_esp: HTTP POST Status = 200, content_length = 64
🟢 [/Users/cyril/Documents/work/vertices/c-vertices-sdk/src/algorand/algorand_transaction.c:307] 🧾 Transaction executed, ID: HRSIHDSQIZWXELQIORV2OX72TXQM2PZ7BMGVBK6WCZMEUZH4CWRQ
W (10556) vertices_example: Unhandled event: 2
I (10566) vertices_example: 💸 Alice sent 0.000100 algo to Bob
🟢 [/Users/cyril/Documents/work/vertices/c-vertices-sdk/src/account.c:89] 👛 Deleted account from wallet: #0
🟢 [/Users/cyril/Documents/work/vertices/c-vertices-sdk/src/account.c:89] 👛 Deleted account from wallet: #1

```
