Page 1 of 1
ESP32 - IDF - HTTP request
Posted: Mon Aug 02, 2021 9:15 am
by kurtwerbrouck
Hello
I used the example in the doc for creating a HTTP request for openweathermap.
When i used the the http request in the setup() and in the loop(), all seems to be running OK
When i used only the http request in the loop() (delete the http request part in the setup), the esp32 keeps on rebooting.
any ideas what is wrong?
Re: ESP32 - IDF - HTTP request
Posted: Mon Aug 02, 2021 1:25 pm
by mbratch
Your code has a very peculiar structure. You've included "Arduino.h" and are using `setup` and `loop`, which tells me you're intending to use the Arduino framework. In fact, you're checking wifi status by calling the `Wifi` Arduino library. But then you're using ESP-IDF to do your Http server work. I assume you're looking at an ESP-IDF example for http client, not an Arduino library example. Why not use the Arduino library for an http client?
Re: ESP32 - IDF - HTTP request
Posted: Mon Aug 02, 2021 1:36 pm
by kurtwerbrouck
hello mbratch
I assume you're looking at an ESP-IDF example for http client
, Yes indeed
i used the wifi arduino in other programs, but i am converting them all to the idf API, with the help of the APi reference.
now i am trying to use the idf HTTP, I will try this evening with removing the wifi.h.
the mqtt and I2C api examples did work very well, and easier to understand
.
I am trying to convert my arduino sketch that uses a ds1307 display - bme280 sensor - http request openweather - http request sma solar converter and upload all data via mqtt to raspoberry node-red.
Kurt
Re: ESP32 - IDF - HTTP request
Posted: Mon Aug 02, 2021 3:27 pm
by mbratch
If you want to use ESP-IDF framework, then you should start with the correct program structure. ESP-IDF doesn't use `setup` and `loop`. It uses `app_main`. Currently, your code is an odd mix of both worlds. Perhaps the best thing to do is start with the complete ESP-IDF example code, get that working, then put in the changes you need for your specific application. The `app_main` is, in the ESP-IDF world, a FreeRTOS task itself. It would do all the initialization you need (as `setup` would have done), then could either have its own loop, or kick off a separate FreeRTOS task to perform base-level functions while event handlers do what they do. (Note that although `app_main` is a FreeRTOS task, in the latest ESP-IDF it is allowed to just exit, unlike a typical FreeRTOS task.)
Re: ESP32 - IDF - HTTP request
Posted: Sun Aug 15, 2021 5:28 am
by fasani
I also find odd to mix both arduino-ESP32 and IDF but I know some projects do. Here there is a demo of parsing open weather that compiles in IDF and uses arduino “as a component”
https://github.com/vroland/epdiy/tree/m ... es/weather