1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

esp-idf: http_request の使い方

Last updated at Posted at 2023-01-30

esp-idf/examples/protocols/http_request のプログラムを改造します。
M5Stack Core2 で動作確認をしました。
次のサイトにアクセスする例です。

http://httpbin.org/get

プログラム

プログラムのコピー

cd ~/esp
cp -r esp-idf/examples/protocols/http_request .

http_request/sdkconfig を作成

idf.py build

変更する場所

http_request/sdkconfig
(省略)
CONFIG_EXAMPLE_WIFI_SSID="****"
CONFIG_EXAMPLE_WIFI_PASSWORD="****"
(省略)
http_request/main/http_request_example_main.c
(省略)
#define WEB_SERVER "httpbin.org"
#define WEB_PORT "80"
#define WEB_PATH "/get"
(省略)

コンパイル、実行

idf.py -p /dev/ttyUSB0 flash

実行結果

HTTP/1.1 200 OK
Date: Mon, 30 Jan 2023 07:44:44 GMT
Content-Type: application/json
Content-Length: 239
Connection: close
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
  "args": {}, 
  "headers": {
    "Host": "httpbin.org", 
    "User-Agent": "esp-idf/1.0 esp32", 
    "X-Amzn-Trace-Id": "Root=1-63d7756c-3c33c51147890fc74b272b72"
  }, 
  "origin": "219.126.136.17", 
  "url": "http://httpbin.org/get"
}

確認したバージョン

$ idf.py --version
ESP-IDF v5.4-dev-3201-g46acfdce96
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?