2019年6月3日月曜日

ESP32-CAM 農業用カメラを作る 12shutter

いよいよESP32-CAMを使って撮影した画像を
SDカードに保存する。

いろいろNETを彷徨っているとこんなサンプルを発見

https://github.com/v12345vtm/CameraWebserver2SD/blob/master/CameraWebserver2SD/CameraWebserver2SD.ino

通常のサンプルはいろいろエラーが出て、動かすのに苦労があるのだが
このサンプルはいきなりOKだった。

WiFiの設定とNTPサーバーを国内のものに変更する

const char* ssid = "XXXXX";
const char* password = "PASS";
const char* ntpServer = "ntp.nict.jp"; //internet time server

RESETすると、シリアルポートに以下のメッセージ


ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6400
entry 0x400806a8
[D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled

v12345vtm

[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 2 - STA_START
.[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:379] _eventCallback(): STA IP: 192.168.200.109, MASK: 255.255.255.0, GW: 192.168.200.254
.
WiFi connected
Sunday, June 02 2019 16:57:14
 internet time ok

SD_MMC Card Type: SDHC
SD_MMC Card Size: 7600MB
Listing directory: /
  FILE: /.dropbox.device  SIZE: 56
Creating Dir: /mydir
Dir created
Listing directory: /
  DIR : /mydir
  FILE: /.dropbox.device  SIZE: 56
Removing Dir: /mydir
Dir removed
Listing directory: /
  FILE: /.dropbox.device  SIZE: 56
Writing file: /hello.txt
File written
Appending to file: /hello.txt
Message appended
Reading file: /hello.txt
Read from file: Hello World!
Deleting file: /foo.txt
[E][vfs_api.cpp:135] remove(): /foo.txt does not exists or is directory
Delete failed
Renaming file /hello.txt to /foo.txt
File renamed
Reading file: /foo.txt
Read from file: Hello World!
[E][vfs_api.cpp:64] open(): /sdcard/test.txt does not exist
1048576 bytes written for 2274 ms
Total space: 7582MB
Used space: 762MB
Starting web server on port: '80'
Starting stream server on port: '9601'
Camera Ready! Use 'http://192.168.200.109' to connect , de stream zit op een andere poortkanaal 9601
stream Ready! Use 'http://192.168.200.109:9601/stream
image Ready! Use 'http://192.168.200.109/capture


画像が欲しいので、
http://192.168.200.109/capture
にアクセスすると以下のメッセージが表示され、ブラウザに
1600x1200の画像が表示された。

lijn493
lijn496 pixformatjpg for httpd send
fb lengte=
106073
Writing file: /capture.jpg
succes to open file for SDwriting552
Writing file: /info.txt
File written
0
JPG: 106073B 978ms



SDカードの内容はこんな感じ


Textファイルはテスト的に作成されたものの様。

ここまで出来ていると、もう先が見えてきた。
偉大な先人に感謝。

まだスケッチ内容を理解していないが、

  • WiFi関連の削除
  • 定期的にCaptuerを実行
  • 余計なTextファイルを作らない
  • FTPによる画像ファイルの送信

を追加する事になる。


ところでNTP設定は何のために使っているんだろう



0 件のコメント:

コメントを投稿