LoginSignup
1
0

More than 1 year has passed since last update.

M5Camera単体でWifi設定できるようにしてみた

Last updated at Posted at 2021-08-14

以下のページを参考に試してみた
https://tech-blog.cerevo.com/archives/4952/
https://firtel.blogspot.com/2019/06/esp32-cam-wifi-manager.html

cd ${arduino_core_directory}/libraries
git clone https://github.com/me-no-dev/AsyncTCP
git clone https://github.com/me-no-dev/ESPAsyncWebServer
git clone https://github.com/alanswx/ESPAsyncWiFiManager
#include "esp_camera.h"
#include <WiFi.h>
#include <ESPmDNS.h>//追加
#include <ESPAsyncWebServer.h>//追加
#include <ESPAsyncWiFiManager.h>//追加
AsyncWebServer server(80);//追加
DNSServer dns;//追加

//
// WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
//            Ensure ESP32 Wrover Module or other board with PSRAM is selected
//            Partial images will be transmitted if image exceeds buffer size
//

// Select camera model
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM  //コメントアウト
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM // コメント外す
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM

#include "camera_pins.h"

//const char* ssid = "*********"; //コメントアウト
//const char* password = "*********"; //コメントアウト

void startCameraServer();

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println();

  AsyncWiFiManager wifiManager(&server,&dns);//追加
  wifiManager.autoConnect("ESP32-CAM");//追加
  //WiFi.begin(ssid, password);//コメントアウト
  WiFi.begin();//追加
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  MDNS.begin("cam");//追加

リセットしたい時に

  WiFi.mode(WIFI_STA);
  WiFi.disconnect(true,true);

void setup() {の直後におく

※ただし、これはあくまで書き込みリセット用。この部分をコメントアウトして再度書き込まないといけないっぽい
もしコメントアウトして再書き込みしなかった場合、写真が撮れず、シリアルモニタに以下のエラーが出る

E (56332) httpd: httpd_server_init: error in bind (112)

コメントアウトして再書き込みする以外に楽な方法あったら教えてください

スマホ等でESP32-CAMに接続するとログイン画面が出てくる(出てこなかったら http://192.168.4.1 にアクセス)。
設定後に
http://cam.local/
にアクセスすると以下のような見覚えのある画面が出てくる

スクリーンショット 2021-08-14 15.20.48.png

URLが固定されるんで結構嬉しい。

あとは煮るなり焼くなり。
参考になりそう:https://www.hiroto.tech/moin.cgi/Embedded/M5Stack/M5Camera


画像サイズ設定:http://cam.local/control?var=framesize&val=10
画像取得:http://cam.local/capture

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