一、产品介绍
1、esp32-cam拍照模块
安信可基于乐鑫esp32出品的esp32-cam,支持图片和视频流,价格便宜到只要40几块钱。
跟m5stacm的cam版本结构原理一样。
通过摄像头的库接口捕获frame数据形成图片。
2、sim800L数据传输模块
sim800l是芯讯通出品的2g通讯模组。淘宝带转接板的多的是,才20几块。
二、拍照测试
1、搭建编译环境
https://github.com/donny681/ESP32_CAMERA_QR/wiki
下载安信可的lubuntu系统加载接口。
觉得不方便可以自行配置xshell和winscp配合操作;
默认esp库在此,也可以自行git clone最新版,需要执行add_path.sh才能顺利编译固件。
2、下载示例代码
切换root账户
ai-thinker@aithinker:~$
ai-thinker@aithinker:~$ su
密码:
root@aithinker:/home/ai-thinker#
下载代码
root@aithinker:/home/ai-thinker# ls
1 esp esp_demo share system 公共的 模板 视频 图片 文档 下载 音乐 桌面
root@aithinker:/home/ai-thinker# git clone https://github.com/donny681/ESP32_CAMERA_QR.git
正克隆到 'ESP32_CAMERA_QR'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 648 (delta 1), reused 6 (delta 1), pack-reused 633
接收对象中: 100% (648/648), 2.30 MiB | 1.03 MiB/s, 完成.
处理 delta 中: 100% (106/106), 完成.
root@aithinker:/home/ai-thinker# cd ESP32_CAMERA_QR/
root@aithinker:/home/ai-thinker/ESP32_CAMERA_QR# git submodule update --init
root@aithinker:/home/ai-thinker/ESP32_CAMERA_QR#
3、配置及生成固件
root@aithinker:/home/ai-thinker/ESP32_CAMERA_QR# make menuconfig
configuration written to /home/ai-thinker/ESP32_CAMERA_QR/sdkconfig
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
GENCONFIG
root@aithinker:/home/ai-thinker/ESP32_CAMERA_QR#
配置需要连接的wifi
改成自己的wifi连接方式。
开始编译固件
root@aithinker:/home/ai-thinker/ESP32_CAMERA_QR# make
WARNING: Toolchain version is not supported: 1.22.0-73-ge28a011
Expected to see version: 1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
WARNING: Toolchain version is not supported: 1.22.0-73-ge28a011
Expected to see version: 1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
CC build/bootloader/bootloader_support/src/bootloader_flash.o
CC build/bootloader/bootloader_support/src/efuse.o
CC build/bootloader/bootloader_support/src/secure_boot.o
CC build/bootloader/bootloader_support/src/bootloader_clock.o
LD build/esp32-cam-demo.elf
esptool.py v2.5.1
To flash all build output, run 'make flash' or:
python /home/ai-thinker/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 /home/ai-thinker/ESP32_CAMERA_QR/build/bootloader/bootloader.bin 0x10000 /home/ai-thinker/ESP32_CAMERA_QR/build/esp32-cam-demo.bin 0x8000 /home/ai-thinker/ESP32_CAMERA_QR/build/partitions_singleapp.bin
最后呈现的是可以刷入固件的命令,以及固件位置。
4、刷固件
可以用linux环境的命令行刷入,也可以更方便的用在win方式刷入。
我们采用esp tools
https://www.espressif.com/en/support/download/other-tools?keys=&field_type_tid%5B%5D=13
刷入文件及刷入地址
0x1000 bootloader.bin
0x10000 esp32-cam-demo.bin
0x8000 partitions_singleapp.bin
刷固件步骤;
板子供电,数据线接usb-ttl,刷入需要下拉,如图,用根杜邦线把绿框内的两个直接连接即可(很重要),运行时拔掉。
选择com口,然后点板子上reset即可自动刷入。
5、测试效果
用串口工具连接esp32-cam
[0;32mI (30) boot: ESP-IDF v3.0.7 2nd stage bootloader�[0m
�[0
[07:38:26.378] ;32mI (30) boot: compile time 15:33:25�[0m
�[0;32mI (30) boot: Enabling RNG early entropy source...�[0m
�[0;32mI (35) boot: SPI Speed : 40MHz�[0m
�[0;32mI (39) boot: SPI Mode : DIO�[0m
�[0;32mI (43) boot: SPI Flash Size : 4MB�[0m
�[0;32mI (47) boot: Partition Table:�[0m
�[0;32mI (51) boot: ## Label Usage Type ST Offset Length�[0m
�[0;32mI (58) boot: 0 nvs WiFi data 01 02 00009000 00006000�[0m
�[0;32mI (65) boot: 1 phy_init RF data 01 01 0000f000 00001000�[0m
�[0;32mI (73) boot: 2 factory factory app 00 00 00010000 00100000�[0m
�[0;32mI (80) boot: End of partition table�[0m
�[0;32mI (85) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x13d90 ( 81296) map�[0m
[07:38:26.409] �[0;32mI (122) esp_image: segment 1: paddr=0x00023db8 vaddr=0x3ffb0000 size=0x02ce0 ( 11488) load�[0m
�[0;32mI (127) esp_image: segment 2: paddr=0x00026aa0 vaddr=0x40080000 size=0x00400 ( 1024) load�[0m
�[0;32mI (129) esp_image: segment 3: paddr=0x00026ea8 vaddr=0x40080400 size=0x09168 ( 37224) load�[0m
�[0;32mI (153) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x63ad4 (408276) map�[0m
[07:38:26.584] �[0;32mI (296) esp_image: segment 5: paddr=0x00093af4 vaddr=0x40089568 size=0x01fd8 ( 8152) load�[0m
�[0;32mI (300) esp_image: segment 6: paddr=0x00095ad4 vaddr=0x400c0000 size=0x00000 ( 0) load�[0m
�[0;32mI (310) boot: Loaded app from partition at offset 0x10000�[0m
�[0;32mI (310) boot: Disabling RNG early entropy source...�[0m
�[0;32mI (315) cpu_start: Pro cpu up.�[0m
�[0;32mI (318) cpu_start: Starting app cpu, entry point is 0x40080fa4�[0m
�[0;32mI (0) cpu_start: App cpu up.�[0m
�[0;32mI (329) heap_init: Initializing. RAM available for dynamic allocation:�[0m
�[0;32mI (336) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM�[0m
�[0;32mI (342) heap_init: At 3FFB8148 len 00027EB8 (159 KiB): DRAM�[0m
�[0;32mI (348) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM�[0m
�[0;32mI (354) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM�[0m
�[0;32mI (361) heap_init: At 4008B540 len 00014AC0 (82 KiB): IRAM�[0m
�[0;32mI (367) cpu_start: Pro cpu start user code�[0m
[07:38:26.679] �[0;32mI (161) cpu_start: Starting scheduler on PRO CPU.�[0m
�[0;32mI (0) cpu_start: Starting scheduler on APP CPU.�[0m
[07:38:26.698] �[0;32mI (206) I2S: DMA Malloc info, datalen=blocksize=256, dma_buf_count=8�[0m
�[0;32mI (206) I2S: PLL_D2: Req RATE: 78125, real rate: 78125.000, BITS: 16, CLKM: 8, BCK: 8, MCLK: 20000000.000, SCLK: 2500000.000000, diva: 64, divb: 0�[0m
�[0;32mI (216) camera_xclk: PIN_CTRL before:3ff,78125�[0m
�[0;32mI (216) camera_xclk: PIN_CTRL after:7fff�[0m
[07:38:30.779] �[0;32mI (4286) camera_demo: Detected OV2640 camera, using JPEG format�[0m
[07:38:30.997] �[0;32mI (4506) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE�[0m
�[0;32mI (4506) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE�[0m
[07:38:31.089] �[0;32mI (4556) phy: phy_version: 3663, 1d88daa, Aug 6 2018, 10:31:06, 0, 0�[0m
�[0;32mI (4566) camera_demo: Connecting to "HI-WOOYA_471D"�[0m
[07:38:36.039] �[0;32mI (9506) event: sta ip: 192.168.1.126, mask: 255.255.255.0, gw: 192.168.1.182�[0m
�[0;32mI (9506) camera_demo: Connected�[0m
�[0;32mI (9506) camera_demo: Open http://192.168.1.126/jpg for single image/jpg image�[0m
�[0;32mI (9516) camera_demo: Open http://192.168.1.126/jpg_stream for multipart/x-mixed-replace stream of JPEGs�[0m
�[0;32mI (9526) camera_demo: Free heap: 77972�[0m
�[0;32mI (9526) camera_demo: Camera demo ready�[0m
给出ip地址和访问url;
http://192.168.1.126/jpg
http://192.168.1.126/jpg_stream
请求图片会出现,实际也是esp32捕捉ov2640的数据生成一个frame,视频原理也如此;100多毫秒响应一张图片。
[07:40:09.827] �[0;32mI (103296) camera: Frame 0 done in 94 ms�[0m
[07:40:15.027] �[0;32mI (108496) camera: Frame 1 done in 132 ms�[0m
�[0;33mW (108496) http_server: Expected response size: 28000, actual: 0�[0m
[07:44:22.283] �[0;32mI (355756) camera: Frame 105 done in 83 ms�[0m
[07:44:22.441] �[0;32mI (355916) camera: Frame 106 done in 103 ms�[0m
[07:44:22.603] �[0;32mI (356076) camera: Frame 107 done in 94 ms�[0m
[07:44:22.766] �[0;32mI (356236) camera: Frame 108 done in 105 ms�[0m
[07:44:22.924] �[0;32mI (356396) camera: Frame 109 done in 115 ms�[0m
[07:44:23.083] �[0;32mI (356556) camera: Frame 110 done in 118 ms�[0m
[07:44:23.240] �[0;32mI (356716) camera: Frame 111 done in 114 ms�[0m
[07:44:23.403] �[0;32mI (356876) camera: Frame 112 done in 107 ms�[0m
[07:44:23.563] �[0;32mI (357036) camera: Frame 113 done in 124 ms�[0m
[07:44:23.720] �[0;32mI (357196) camera: Frame 114 done in 118 ms�[0m
[07:44:23.879] �[0;32mI (357356) camera: Frame 115 done in 118 ms�[0m
[07:44:24.039] �[0;32mI (357516) camera: Frame 116 done in 120 ms�[0m
[07:44:24.200] �[0;32mI (357676) camera: Frame 117 done in 119 ms�[0m
[07:44:24.359] �[0;32mI (357836) camera: Frame 118 done in 121 ms�[0m
[07:44:24.519] �[0;32mI (357996) camera: Frame 119 done in 116 ms�[0m
[07:44:24.680] �[0;32mI (358156) camera: Frame 120 done in 113 ms�[0m
[07:44:24.839] �[0;32mI (358316) camera: Frame 121 done in 119 ms
电压电流不足够有水波纹产生,解决电压电流稳定即可。
三、esp32cam开发参考
https://github.com/espressif/esp32-camera
安信可官网代码;
m5stack中文
https://github.com/1zlab/1ZLAB_ESP32_Wifi_Camera
如何固定ip地址;
https://qiita.com/dinosauria123/items/c8ce027f1c23dc916609
四、esp32cam 通讯模块参考。
可以把sim800l当modem功能。
https://www.esp32.com/viewtopic.php?f=17&t=1496&sid=2eaa519a30be6d4c6d5567132ef9320a
https://github.com/loboris/ESP32-PPPOS-EXAMPLE
通过pppos拨号上网。
https://debugdump.com/t_2005.html
五、其他思路
esp32 mqtt
https://github.com/tuanpmt/esp32-mqtt
可以通过esp32cam定时抓拍图片,然后通过sim800L拨号连接,通过mqtt或者http把图片数据传给服务器。
此方案思路适合2g信号地区,在运营商大量裁撤2g基站情况下,建议采用nb_iot方案。