diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..b30f521 --- /dev/null +++ b/.cproject @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/.project b/.project new file mode 100644 index 0000000..460394b --- /dev/null +++ b/.project @@ -0,0 +1,20 @@ + + + Weather_ESP + + + + + + org.eclipse.cdt.core.cBuilder + clean,full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + com.espressif.idf.core.idfNature + + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bda6977 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(app-template) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..17fb21c --- /dev/null +++ b/LICENSE @@ -0,0 +1,5 @@ +Code in this repository is in the Public Domain (or CC0 licensed, at your option.) + +Unless required by applicable law or agreed to in writing, this +software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. diff --git a/README.md b/README.md index 6106b8d..27ddf0d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ -# Weather_ESP +ESP-IDF template app +==================== -Repo for ESP32 Weather Station Development \ No newline at end of file +This is a template application to be used with [Espressif IoT Development Framework](https://github.com/espressif/esp-idf). + +Please check [ESP-IDF docs](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for getting started instructions. + +*Code in this repository is in the Public Domain (or CC0 licensed, at your option.) +Unless required by applicable law or agreed to in writing, this +software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied.* diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000..e6c20ac --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,8 @@ +# Edit following two lines to set component requirements (see docs) +set(COMPONENT_REQUIRES ) +set(COMPONENT_PRIV_REQUIRES ) + +set(COMPONENT_SRCS "main.c") +set(COMPONENT_ADD_INCLUDEDIRS "") + +register_component() diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild new file mode 100644 index 0000000..7e23439 --- /dev/null +++ b/main/Kconfig.projbuild @@ -0,0 +1,14 @@ +# put here your custom config value +menu "Example Configuration" +config ESP_WIFI_SSID + string "WiFi SSID" + default "myssid" + help + SSID (network name) for the example to connect to. + +config ESP_WIFI_PASSWORD + string "WiFi Password" + default "mypassword" + help + WiFi password (WPA or WPA2) for the example to use. +endmenu diff --git a/main/main.c b/main/main.c new file mode 100644 index 0000000..24bafb4 --- /dev/null +++ b/main/main.c @@ -0,0 +1,42 @@ +#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_4, GPIO_MODE_OUTPUT); + int level = 0; + while (true) { + gpio_set_level(GPIO_NUM_4, level); + level = !level; + vTaskDelay(300 / portTICK_PERIOD_MS); + } +} +