How to use GPIO14 of ESP-WROOM-32 with ESP-IDF
Posted: 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.
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.
Who knows the reason for this phenomenon and solutions?
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.
- void setup() {
- pinMode(14, OUTPUT);
- pinMode(25, OUTPUT);
- pinMode(26, OUTPUT);
- pinMode(27, OUTPUT);
- }
- void loop() {
- digitalWrite(14, HIGH);
- digitalWrite(25, LOW);
- digitalWrite(26, HIGH);
- digitalWrite(27, LOW);
- }
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.
- #include "freertos/FreeRTOS.h"
- #include "esp_wifi.h"
- #include "esp_system.h"
- #include "esp_event.h"
- #include "esp_event_loop.h"
- #include "nvs_flash.h"
- #include "driver/gpio.h"
- esp_err_t event_handler(void *ctx, system_event_t *event)
- {
- return ESP_OK;
- }
- void app_main(void)
- {
- nvs_flash_init();
- tcpip_adapter_init();
- ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
- ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
- ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
- wifi_config_t sta_config = {
- .sta = {
- .ssid = CONFIG_ESP_WIFI_SSID,
- .password = CONFIG_ESP_WIFI_PASSWORD,
- .bssid_set = false
- }
- };
- ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
- ESP_ERROR_CHECK( esp_wifi_start() );
- ESP_ERROR_CHECK( esp_wifi_connect() );
- gpio_set_direction(GPIO_NUM_14, GPIO_MODE_OUTPUT);
- gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT);
- gpio_set_direction(GPIO_NUM_26, GPIO_MODE_OUTPUT);
- gpio_set_direction(GPIO_NUM_27, GPIO_MODE_OUTPUT);
- gpio_set_level(GPIO_NUM_14, 1);
- gpio_set_level(GPIO_NUM_26, 1);
- gpio_set_level(GPIO_NUM_27, 1);
- int level = 0;
- while (true) {
- gpio_set_level(GPIO_NUM_25, level);
- level = !level;
- vTaskDelay(300 / portTICK_PERIOD_MS);
- }
- }