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?
ESP32 - IDF - HTTP request
-
- Posts: 10
- Joined: Tue Feb 16, 2021 2:37 pm
ESP32 - IDF - HTTP request
- Attachments
-
- ESP-32-IDF-HTTP-REQUEST-2.txt
- (4.37 KiB) Downloaded 338 times
Re: ESP32 - IDF - HTTP request
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?
-
- Posts: 10
- Joined: Tue Feb 16, 2021 2:37 pm
Re: ESP32 - IDF - HTTP request
hello mbratch
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
, Yes indeedI assume you're looking at an ESP-IDF example for http client
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
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
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
https://github.com/vroland/epdiy/tree/m ... es/weather
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design
Who is online
Users browsing this forum: No registered users and 147 guests