ESP-Nodes/rainmaker.md

86 lines
4.8 KiB
Markdown
Raw Normal View History

2024-08-11 00:39:50 -04:00
---
layout: tutorial
---
2024-08-11 01:17:36 -04:00
# ESP RAINMAKER TUTORIAL
2024-08-11 01:40:18 -04:00
This tutorial walks you through the most important steps required for provisioning device powered by ESP32-WROOM, ESP32-S2 or ESP32-C3 module.
2024-08-11 01:17:36 -04:00
2024-08-11 02:00:50 -04:00
__Minimum Requirements:__ </br>
2024-08-11 01:52:40 -04:00
ESP32-WROOM, either a Module or DevKit</br>
Wi-Fi Access Point, preferrably with dedicated vLAN for IoT devices</br>
Smart phone with RainMaker installed
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
### I. ESP-IDF: Create a New Project
2024-08-11 01:17:36 -04:00
2024-08-11 02:00:50 -04:00
The first step is to create a new project with ESP-IDF Rainmaker extention using Visual Studio Code.
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_001.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 02:03:57 -04:00
Specify the project name, directory path and ESP32 module that will be used (i.e. ESP32-WROOM, ESP32-S2 or ESP32-C3). In addition, you may specify the Serial port where ESP32 Module is connected to; the serial port can be changed latter, if neccessary.
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_002.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 02:03:57 -04:00
On the next screen, select the ESP Rainmaker extention and choose the example code to start with. For this tutorial, an example code for __Switch__ was selected. Click "Create project using template switch".
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_003.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
### II. Modify the Template Code
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
Once project is created, make the following changes to the **app_main.cpp** source file.
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
Change the TAG variable to reflect your device name as follows:
2024-08-11 01:17:36 -04:00
```C++
static const char *TAG = "ESP32-Nodes app main";
```
```C++
esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP RainMaker Device", "Switch");
```
```C++
switch_device = esp_rmaker_device_create("ESP32-Nodes Switch", ESP_RMAKER_DEVICE_SWITCH, NULL);
```
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_004.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
### III. Modify Configuration
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
ESP-IDF **menuconfig** contains settings that define hardware configuration. For example, GPIO used to control power relay, etc. To set configuration values, navigate to the ESP-IDF: SDK Configuration Editor (menuconfig). Some of the default values are pre-defined by the RainMaker Switch template; however, the specific number of GPIO used to turn LED Lights on or off needs to be entered.
2024-08-11 01:17:36 -04:00
2024-08-11 02:13:15 -04:00
To do so, click on Example Configuration section, and change **Output GPIO** value to _4_, which corresponds to the GPIO connected to the LED lights control pin.
2024-08-11 01:17:36 -04:00
Set **Claiming Type** to _Assisted_, and **Provisioning Transport Method** to _BLE_.
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_005.png" width="70%"/>
2024-08-11 01:17:36 -04:00
Click _Save_ and then build the project by running the command _ESP-IDF: Build Project_.
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_006.png" width="70%"/>
2024-08-11 01:17:36 -04:00
Building the project can take some time.
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_007.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_008.png" width="70%"/>
2024-08-11 01:17:36 -04:00
### Adding RainMaker Device
Once project is successfully built, and ESP32-WROOM module is flashed, reboot your device and open Serial Monitor in order to access provisioning QR code. At this point you can start adding your device to your RainMaker dashboard. On your smartphone, launch the _ESP RainMaker_ app and click _Add device_. You'll be asked to scan the QR code. If provisioning is successful, _ESP RainMaker_ app will take you to the nest steps.
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_009.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="ESP-IDF. Create a New Project" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Espressif-Rainmaker_010.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="Alexa Account Linking to RainMaker" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Screenshot_20240716-213521~2.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="RainMaker Provisioning. Adding Wi-Fi" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Screenshot_20240716-223344~2.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="RainMaker Provisioning" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Screenshot_20240716-223358~2.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="RainMaker. ESP32 Node Switch Setting" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Screenshot_20240716-230310~2.png" width="70%"/>
2024-08-11 01:17:36 -04:00
2024-08-11 01:38:52 -04:00
<img alt="RainMaker. ESP32 Node Switch" src="https://alexandrebobkov.github.io/ESP-Nodes/assets/Screenshot_20240716-230318~2.png" width="70%"/>
2024-08-11 01:17:36 -04:00