Dashcam with Wi-Fi streaming.
Based on ESP32 CameraWebServer
example in Arduino.
Inspired by (some ideas or/and code are taken from):
jameszah's ESP32-CAM-Video-Recorder-junior,
s60sc's ESP32-CAM_MJPEG2SD,
gemi254's ESP32-CAM_MJPEG2SD.
ESP32-DASHCAM is made for ESP32-CAM development board.
Features:
- Cyclically records video with fix length
avi_length
to memory card (built-in slot); - Autodeletion of the oldest file in case of memory lack;
- Video streaming;
- Wi-Fi Manager;
- Customizable framesize and quality via web interface are saved in EEPROM;
- Support of usual tactile and touch buttons to start/stop rec;
- Autostart video rec after booting.
Files
At booting, new folder for video files is created with name folder_num
equal to the number of dashcam boot.
This number is stored in EEPROM and is updated every boot.
Video files name are generated by concatenating devname
, folder_num
and file_num
.
Wi-Fi
To use streaming feature, you and dashcam should be in one network. Dashcam can:
- Connect to your Wi-Fi point: if credentials are not saved in memory or dashcam cannot connect to saved Wi-Fi point, it will creat access point with name "
ESP_SSID
_Manager" and password hardcoded inESP_SSID
andESP_PWD
, after connecting to which you can choose your network via captive portal (the library WiFiManager by tzapu does all the work of Wi-Fi Manager); - Create Access Point: after Wi-Fi Manager timeout (
WIFIMGR_TIMEOUT
), ESP32-DASHCAM creates it's own network with access point "ESP_SSID
_AP" and passwordESP_PWD
.
Autodeletion
Before creating new video file, ESP32-DASHCAM checks if there is enough free space. If there is no free space and it happened for the first time after booting, ESP32-DASHCAM searches the oldest folder. Then, every time the space should be freed, the oldest file is deleted in this oldest folder until it becomes empty. All job is done assuming files have strict structure:
/
├──folder_num1
│ ├──devname.folder_num1.file_num1
│ ├──devname.folder_num1.file_num2
│ │...
│
├──folder_num2
│ ├──devname.folder_num2.file_num1
│ ├──devname.folder_num2.file_num2
│ │...
...
So, the oldest folder is in root, with the least number as name. The oldest file is in the oldest folder and has the least number in name.
Button
You can use usual tactile or touch button. Your choice should be set in BTN_IS_TOUCH
definition.
Tested on cheapest Chinese clone of Ai Thinker module with folowing setup and libs:
- Arduino IDE 1.8.10 - 2.0 (beta)
- "esp32 by Espressif Systems" board version 1.0.4. Link for board manager: https://dl.espressif.com/dl/package_esp32_index.json
Lib | Version |
---|---|
1) DNSServer | 1.1.0 |
2) EEPROM | 1.0.3 |
3) FS | 1.0 |
4) GyverButton | 2.14 |
5) SD_MMC | 1.0 |
6) WebServer | 1.0 |
7) WiFi | 1.0 |
8) WiFiManager | 2.0.4-beta |
Newer versions of esp32 board conflicts with WiFi library.
- When you change
quality
orframesize
via web interface, all changes are applied immediately to observe changes in steaming. But video file will contain frames with different characteristics. One way: apply changes right before new video file, so it will be impossible to see changes in streaming immediately. Right way: stop video rec, start new file. Dashcam is supposed to be used as a dashcam on my motorcycle: every frame count! No time to stop/start video!)) To be honest, it just doesn't bother me: I'll set the dashcam once and will forget about it. - Rewrite
delete_oldest()
for the case offolder_num
overflow. - Take care of EEPROM write cycles quantity. Could be resolved jointly with the previous issue.