Page 1 of 1

Help to understand the development using ESP-IDF..

Posted: Wed Nov 06, 2024 2:11 pm
by acsoprana
Hello everyone, I'm using vscode and ESP-IDF to develop my thread network using the OT_CLI, OT_RCP and ESP_THREAD_BR examples. So far the network is working.

Now I need to develop some code that works with the configuration made using OT_CLI on an esp32-h2. It's very different from doing something in relation to an esp32-wrom for me, who's a beginner.

Can someone help me understand how code creation works using ESP-IDF (OT_CLI)? I want to start using the thread network starting with basic things, etc. Something simple for me to understand, a code that "blinks an LED". I know it's already ready in the ot_cli menucofig, but I need to understand how to program it. I also need to know how to reference an external library. If anyone can help me with something simple, I'll be happy.

In the attached image, I put a basic printf("hello, world!!!\n") to display on the terminal in the code "esp_ot_cli.c" and it worked. However, I need to understand how external library calls work to incorporate them into the code.

Help me,

Re: Help to understand the development using ESP-IDF..

Posted: Wed Nov 06, 2024 5:36 pm
by aliarifat794
The OpenThread CLI (OT_CLI) is a command-line interface that lets you configure and interact with the OpenThread stack directly on your ESP32.To create an LED blinking example with ESP-IDF in the OpenThread context, you need to set up a task or function that interacts with a GPIO pin. You have to add this code to your app_main function or create a separate task for blinking:

Code: Select all

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

// Define the LED pin (adjust the GPIO number as needed)
#define BLINK_GPIO GPIO_NUM_2

void blink_task(void *pvParameter) {
    gpio_pad_select_gpio(BLINK_GPIO);
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);

    while (1) {
        // Toggle the LED on
        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(500 / portTICK_PERIOD_MS);  // Delay 500 ms

        // Toggle the LED off
        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(500 / portTICK_PERIOD_MS);  // Delay 500 ms
    }
}

void app_main(void) {
    // Initialize any OpenThread-related components if needed

    // Start the blink task
    xTaskCreate(&blink_task, "blink_task", 1024, NULL, 5, NULL);
}

Re: Help to understand the development using ESP-IDF..

Posted: Thu Nov 07, 2024 1:08 pm
by acsoprana
Hello aliarifat794, thanks for your collaboration. I'm going to test the code and see what I can understand about how it works on the thread network and try to implement something that makes some value go to a spreadsheet in Google Sheets. It won't be easy. I did it on the ESP32WROM and it worked perfectly. But on an ESP32H2 it's going to be a challenge.

I'm accepting collaboration for this. When I get it, I'll post the solution and the project.

Re: Help to understand the development using ESP-IDF..

Posted: Thu Nov 07, 2024 7:14 pm
by acsoprana
Guys, can someone help me include an external library in the ESP-IDF API? I'm trying to use the DHT22 temperature and humidity sensor in esp32-h2 to get the external temperature and humidity. I followed a project made in ESP32-Wrom as shown in the link https://randomnerdtutorials.com/esp32-d ... duino-ide/ I replicated it on the same hardware and used the same libraries and in the Arduino IDE and it worked perfectly. Now I want to replicate this using an Esp32-h2 but I still can't understand how to include external libraries in VSCODE.

I've already tried to create a "lib" folder inside the project containing the "*.h" files from the repositories making the calls using includes directly but it doesn't work.

If you can help me I'd be grateful.

Re: Help to understand the development using ESP-IDF..

Posted: Sun Nov 10, 2024 8:02 pm
by acsoprana
Guys, I'm here to share what I've managed to do so far with my ESP32-H2:

I started this topic asking for help to start understanding how a thread network works and implement devices. So far, everything is fine. My thread network is operational with the implemented example from Espressif. Finally, with the help of colleagues, the forum, and internet searches, I managed to adapt libraries and implement the DHT11 and DHT22 sensors. The images below show how they work. As soon as I manage to implement sending this data to a spreadsheet or database, I'll come back to update you. I hope that at the end of my project, I'll post my GitHub here with the codes and step-by-step instructions for implementation.

What I still want to implement in this small project:
- acquire date and time via NTP server;
- check the network status by simply pinging an external IP;
- send temperature and humidity data to a Google spreadsheet or database.

To give an example, I have already implemented all of this on other platforms (Arduino and esp32s3), but the challenge is to do it on a thread network as I mentioned previously.

If anyone is willing to help, I would appreciate it.

Re: Help to understand the development using ESP-IDF..

Posted: Sun Nov 10, 2024 8:03 pm
by acsoprana
Here is another image of the project... Temperature and humidity data from the DHT22.