How to use GPIO14 of ESP-WROOM-32 with ESP-IDF

hiruma
Posts: 2
Joined: Sun Dec 02, 2018 12:21 am

How to use GPIO14 of ESP-WROOM-32 with ESP-IDF

Postby hiruma » Sun Dec 02, 2018 12:39 am

It will be first post.
I can't use GPIO14 of ESP-WROOM-32 with ESP-IDF.

I can use GPIO14 with arduino IDE as shown in the example below.
  1. void setup() {
  2.   pinMode(14, OUTPUT);
  3.   pinMode(25, OUTPUT);
  4.   pinMode(26, OUTPUT);
  5.   pinMode(27, OUTPUT);
  6. }
  7.  
  8. void loop() {
  9.   digitalWrite(14, HIGH);
  10.   digitalWrite(25, LOW);
  11.   digitalWrite(26, HIGH);
  12.   digitalWrite(27, LOW);
  13. }
But I can't use GPIO14 with ESP-IDF.
The program was downloaded from the URL:https://github.com/espressif/esp-idf-template.git ,and I changed "GPIO_NUM_4" to "GPIO_NUM_14".
The result is that a LED of GPIO 14 is lit dark,but GPIO25 is used normally.
  1. #include "freertos/FreeRTOS.h"
  2. #include "esp_wifi.h"
  3. #include "esp_system.h"
  4. #include "esp_event.h"
  5. #include "esp_event_loop.h"
  6. #include "nvs_flash.h"
  7. #include "driver/gpio.h"
  8.  
  9. esp_err_t event_handler(void *ctx, system_event_t *event)
  10. {
  11.     return ESP_OK;
  12. }
  13.  
  14. void app_main(void)
  15. {
  16.  
  17.     nvs_flash_init();
  18.     tcpip_adapter_init();
  19.     ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
  20.     wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  21.     ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
  22.     ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
  23.     ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
  24.     wifi_config_t sta_config = {
  25.         .sta = {
  26.             .ssid = CONFIG_ESP_WIFI_SSID,
  27.             .password = CONFIG_ESP_WIFI_PASSWORD,
  28.             .bssid_set = false
  29.         }
  30.     };
  31.     ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
  32.     ESP_ERROR_CHECK( esp_wifi_start() );
  33.     ESP_ERROR_CHECK( esp_wifi_connect() );
  34.  
  35.     gpio_set_direction(GPIO_NUM_14, GPIO_MODE_OUTPUT);
  36.     gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT);
  37.     gpio_set_direction(GPIO_NUM_26, GPIO_MODE_OUTPUT);
  38.     gpio_set_direction(GPIO_NUM_27, GPIO_MODE_OUTPUT);
  39.     gpio_set_level(GPIO_NUM_14, 1);
  40.     gpio_set_level(GPIO_NUM_26, 1);
  41.     gpio_set_level(GPIO_NUM_27, 1);
  42.     int level = 0;
  43.     while (true) {
  44.         gpio_set_level(GPIO_NUM_25, level);
  45.         level = !level;
  46.         vTaskDelay(300 / portTICK_PERIOD_MS);
  47.     }
  48. }
Who knows the reason for this phenomenon and solutions?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: How to use GPIO14 of ESP-WROOM-32 with ESP-IDF

Postby WiFive » Sun Dec 02, 2018 2:21 am

Code: Select all

gpio_reset_pin(14);

hiruma
Posts: 2
Joined: Sun Dec 02, 2018 12:21 am

Re: How to use GPIO14 of ESP-WROOM-32 with ESP-IDF

Postby hiruma » Sun Dec 02, 2018 7:37 am

Thank you very much, Mr./Ms. WiFive.
I can use GPIO14.

Who is online

Users browsing this forum: Bing [Bot] and 161 guests