What is ESP IDF ?
Posted: Fri Feb 15, 2019 3:36 pm
Hello !
For the past 2 weeks I've been trying to learn to code on ESP32 using Arduino IDE. I still have no idea what I'm doing.
My main source of guides was from here.
The code was... simpler.
But then I come across this forum and its sub-forums, namely this one: ESP32 IDF and notice that the code is a little different. It doesn't seem as simple as the one I used in Arduino IDE. Its syntax has a lot of underscores _ and a lot of it starts with esp/ESP. And when I put it in the Arduino IDE of course it didn't compile (probably because I needed to include some libraries for it to work).
I found Kolban's Book on ESP32 and thank you Mr. Neil Kolban for gathering and putting all of that information in one place.
The thing is that it has the same syntax as the one on this sub-forum, not the one I used in Arduino IDE and I have no idea how to apply what this man wrote in his book.
I don't know why the code looks similar, but is different and doesn't compile. How am I supposed to code ? Should I use Arduino IDE or code another way ? What is the other way ? What does IDF stand for ? Google says that it stands for Israel Defense Forces and it's nice that I learned something new but it wasn't the thing I wanted to learn.
I posted this here in hope that somebody will make me understand what's going on. In the mean time, I will do some research on my own, but I think that my safest bet was asking at the source: here.
Currently reading this : https://docs.espressif.com/projects/esp ... t-started/
As a ... side note, this is the project I am trying to do:
For the past 2 weeks I've been trying to learn to code on ESP32 using Arduino IDE. I still have no idea what I'm doing.
My main source of guides was from here.
The code was... simpler.
Code: Select all
#include "SPIFFS.h"
#include "WiFi.h"
#include "WiFiClient.h"
#include "WiFiAP.h"
#include "ESPAsyncWebServer.h"
const char* ssid1 = "ESP32_Test";
const char* password1 = "123456789";
IPAddress local_IP(192,168,1,2);
IPAddress subnet(255,255,255,0);
AsyncWebServer server(80);
void setup() {
Serial.begin(115200);
delay(2000);
if(!SPIFFS.begin(true)) {
Serial.println("An Error has occured while mounting SPIFFS");
return;
}
Serial.print("Setting soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(local_IP, local_IP, subnet) ? "Ready" : "Failed!");
//sau
// WiFi.softAPConfig(local_IP, local_IP, subnet);
Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP(ssid1, password1) ? "Ready" : "WiFi.softAP failed ! (Password must be at least 8 characters long )");
//sau
// if(!WiFi.softAP(ssid1, password1)) {
// Serial.println("WiFi.softAP failed ! (Password must be at least 8 characters long )");
// return;
// }
Serial.println();
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP());
server.on("/login", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(SPIFFS, "/index.html", "text/html");
});
server.on("/login.css", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(SPIFFS, "/login.css", "text/css");
});
server.on("/back-image.jpg", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(SPIFFS, "/back-image.jpg", "image/jpeg");
});
server.on("/logo-metrici.png", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(SPIFFS, "/logo.png", "image/png");
});
server.begin();
Serial.println("index.html: ");
Serial.print(SPIFFS.exists("/index.html"));
Serial.println();
Serial.println("login.css: ");
Serial.print(SPIFFS.exists("/login.css"));
Serial.println();
Serial.println("back-image.jpg: ");
Serial.print(SPIFFS.exists("/back-image.jpg"));
Serial.println();
Serial.println("logo.png: ");
Serial.print(SPIFFS.exists("/logo.png"));
}
void loop() {
}
Code: Select all
void wifiSetup_StopAP(void)
{
wifi_mode_t currentMode;
esp_wifi_get_mode(¤tMode);
if(currentMode == WIFI_MODE_AP )
{
esp_wifi_stop();
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
}
else if (currentMode == WIFI_MODE_APSTA)
{
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
}
}
The thing is that it has the same syntax as the one on this sub-forum, not the one I used in Arduino IDE and I have no idea how to apply what this man wrote in his book.
I don't know why the code looks similar, but is different and doesn't compile. How am I supposed to code ? Should I use Arduino IDE or code another way ? What is the other way ? What does IDF stand for ? Google says that it stands for Israel Defense Forces and it's nice that I learned something new but it wasn't the thing I wanted to learn.
I posted this here in hope that somebody will make me understand what's going on. In the mean time, I will do some research on my own, but I think that my safest bet was asking at the source: here.
Currently reading this : https://docs.espressif.com/projects/esp ... t-started/
As a ... side note, this is the project I am trying to do:
I am looking to make my little ESP32 do the following:
1 - boot ;
2 - read two (2) lines from a file (SSID and Password), if it has values in that file start in Station Mode and serve a webpage ;
2.1 - if the file doesn't exist or it's empty start in Acces Point Mode with "ESP32AP" name and "password123" as password and serve another webpage containing two (2) inputs: SSID and Password and a "Connect" Button
2.2 - when clicking on Button it will save the credentials in the above mentioned file, and restart