我的ESP32實做書籍:https://youyouyou.pixnet.net/blog/post/121105860
博客來網址:https://www.books.com.tw/products/0010901195
繼上篇:ESP32-CAM(ardunio)拍照auto take picture、串流stream及物件辨識object,能拍照並存檔,這次要介紹如何將照片上傳到特定的伺服器,本篇文章使用上傳方式是目前最常用的http post,相當多API都使用這類方式,當然另外有其他方式待以後在介紹。
要完成本篇文章,請依序完成以下主題
- ESP32-CAM環境建立與範例測試: Build a Video Stream Server by ESP32-CAM (arduino)影像伺服器及臉部辨識
- ESP32-CAM拍照及SDcard存檔:ESP32-CAM(ardunio)拍照auto take picture、串流stream及物件辨識object
完成以上測試後,就可以進行以下內容,以下內容主要分成一、ESP32-CAM端及二、伺服器接收端,ESP32-CAM拍照後,將檔案以HTTP POST方式上傳到伺服器,因此你必須準備一台電腦並安裝web服務,以下分別介紹
一、ESP32-CAM部份
ESP32-CAM主要進行拍照存檔並上傳,拍照可定時拍照,或像「ESP32-CAM(ardunio)拍照auto take picture、串流stream及物件辨識object」以人體感測進行拍照,本範例簡單起見,採用每30秒定時拍照。範例程式放在本篇最後方,請注意,須修改以下內容:
- 第66-67,請修改成自己的wifi設定的SSID與密碼
- 第68-69,請修改成自己的web server的IP(或DNS)與接收照片的html檔案的URL。
- loop(1211-1220)區塊中,目前以30s自動拍照,若有需要可以刪除第1213及1219的if區塊註解。
- 本文主要多了一隻副程式「wifisendfile」進行檔案上傳,wifisendfile需要三個參數,分別是檔案位置與名稱、上傳伺服器IP以及接收照片的HTML檔案位置。
二、伺服器接收端
伺服器的實做,有很多選擇,可以用linux+PHP或者windows+IIS+APS.net等等,由於本人比較熟悉.net平台,因此以下介紹如何利用asp.net來接收ARDUINO傳來的檔案。
- 首先電腦必須安裝IIS或IIS express,安裝流程可參閱: http://charlesbc.blogspot.com/2011/01/iis-express_16.html
- .net安裝開發環境,目前包括VS.net 2017或2019,都有社群免費版可以選擇,下載網址: https://visualstudio.microsoft.com/zh-hant/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=button+cta&utm_content=download+vs2019&rr=https%3A%2F%2Fdocs.microsoft.com%2Fzh-tw%2Fvisualstudio%2Finstall%2Finstall-visual-studio%3Fview%3Dvs-2019
安裝時,請至少選擇以下幾個模組,其餘您自行斟酌是否需要安裝,VS.net是一個宇宙最肥沒有之一的開發平台,安裝時請注意自己的硬碟空間
完成安裝後,啟動VS.net主程式,並開啟本地端IIS站,就可進行下一步。
- ASP檔案接收的程式部份,由於本人已經是old school了,就以最擅長的vb.net寫範例程式。
Private Sub default_Load(sender As Object, e As EventArgs) Handles Me.Load
'0檔案上傳處理
Dim aFile As HttpFileCollection = Request.Files
If aFile.Count > 0 Then
Dim relativePath As String = "files\"
Dim absolutePath As String = Server.MapPath("~/" + relativePath)
Dim displayFileName As String = Path.GetFileName(aFile(0).FileName)
Dim filename As String = Int(Now().Ticks) & ".jpg"
Dim realFileName As String = absolutePath & filename
aFile(0).SaveAs(realFileName)
End If
End Sub
4.檔案上傳後,會存在伺服器中,就可以用來做很多的功能,例如轉存到azure做智慧辨識、送到LINE裡面做通知等等。
不過呢,一次檔案的POST,需要大概5秒鐘時間,因此不適合用來做即時化的服務。

hola, excelente aporte, me gustaria saber como puedo hacer el mismo proceso pero usando .php.. y quisiera daber si se puede conectar a un SIM808 con Arduino nano, gracias por su atencion, saludos desde ECUADOR
yo desarrolle un gps tracker usando arduino nano y sim808, fuenciona genial de maravilla , desarrollo el app android y plataforma web en PHP y trabaja genial , ahora me gustaria conectar el esp32-cam y tomar foto y enviarla a mi base de datos, solo necesito el .php, he intentado hacerlo pero no tengo exito, con su amplia experiencia y conocimiento se podra logra este objetivo, gracias por su atencion, desde ECUADOR
I can't understand your language. English pls
*****
*****
*****
*****
*****
*****
您好 我嘗試著使用了您的程式碼 但是我這邊得到的一直是400 Bad Request 請問遇到這樣的問題您有解決的配套嗎?
我的作法是自建伺服器,其實可以參考別人用google drv會比較簡單
1.觸發的動作??可以根據移動嗎?? 2.辨識 要azure做智慧辨識 有其他方式辨識嗎???
1.可以,要自己寫frame分析 2.當然可以
你好,請教https://github.com/v12345vtm/CameraWebserver2SD,下載CameraWebserver2SD-master.zip,用arduino\匯入程式庫\加入zip程式庫... arduino介面結果,顯示指定的目錄/zip檔並未含有合法的程式庫 什麼原因,感謝!
你這個不是lib,他是完整的程式
因開啓CameraWebserver2SD.ino如下: C:\Program Files (x86)\Arduino\examples\CameraWebserver2SD-master\CameraWebserver2SD\CameraWebserver2SD.ino:19:20: fatal error: dl_lib.h: No such file or directory compilation terminated. "WiFi.h"找到多個程式庫 已使用: C:\Users\jimmy\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3\libraries\WiFi 未使用: C:\Program Files (x86)\Arduino\libraries\WiFi exit status 1 開發板 ESP32 Wrover Module 編譯錯誤。
你沒有這個:dl_lib.h: No such file or directory
您好,老師 請問我連線ESP32-CAM觀看即時影像,發現ESP32-CAM溫度一直上升,已經到了會燙手的地步,這是正常的嗎?
我也是 400 bad reqest, 用網頁傳是 ok, 但這個 code 就不行, 不知什麼原因. ========================================== HTTP/1.1 400 Bad Request Date: Sat, 08 Aug 2020 02:16:47 GMT Server: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.10 Content-Length: 226 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> </p> </body></html> closing connection
*****
*****
老師您好, 請問IIS express那個是單純的啟動localhost, 然後還要再建立一個" Windows Forms App(.NET) ",並將老師ASP檔案接收的程式放進去對嗎 ? 因為目前卡關,還望老師提點,謝謝 !!
糟糕都沒看到您的訊息。 看你的說明是對的