- About the Project
- Quick Overview of Each Module
- Getting Started With The Website
- Getting Started With ESP32
- BUILD
- Acknowledgments
- A Few Remarks
ESP32-CAM based, battery powered modules that allow you to: Capture images, record audio, gather sensory information and upload to your own password protected free website on Cloudflare. In addition to viewing you data, you can also send commands to your devices and perform OTA from your webpage.
- Wake up from deepsleep
- Turn the 4G/LTE modem and the nat_router (wifi range extender) on
- Login to 4G/LTE modem and unlock the SIM card (if PIN code is required)
- Call the Cloudflare pages API endpoint, get the current epoch and new commands
- Execute any new commands
- Disconnect from wifi, initialize esp-now and start listening to incoming esp-now packets and store any received file to spiffs.
- After 5 minutes of active listening, de-initialize the esp-now and reconnect to wifi and start uploading and deleting stored files.
- Go back to deepsleep
- Wake up from deepsleep
- Initialize the camera, take a picture and save it to spiffs
- If MJPG mode is enabled, the module will go to sleep if a certain boot-count is not reached (number of captured images)
- If a certian boot-count is reached, append all JPG files to a single MJPG file and delete JPG files
- Try connecting to wifi, if wifi is unavalible go to deepsleep
- If connected to wifi, call the Cloudflare pages API endpoint, get the current epoch and new commands
- Execute any new commands
- Upload all stored JPG/MJPG files with timestamp
- Go to deepsleep
- Wake up from deepsleep
- Record a audio save it to spiffs
- Send a Ping packet via esp-now to the APN
- If a Pong packet is received, start sending all the stored files to the APN
- Go to deepsleep
- Wake up from deepsleep
- Read the sensor data and store it in RTC memory
- Send a Ping packet via esp-now to the APN and save the RTC array as json in spiffs
- If a Pong packet is received, save the RTC array as a json in spiffs and try sending the stored files to the APN
- Go to deepsleep
- Wake up from deepsleep
- Initialize the camera, take a picture and save it to spiffs
- If a certian number of stored images is reached, try calling the Cloudflare pages API endpoint, get the current epoch and new commands, otherwise go to deepsleep
- Execute any new commands
- Upload all stored images with timestamp
- Go to deepsleep
- Wake up from deepsleep
- Perform a measurement
- After a certain number of measurements create the text for SMS
- Send the SMS to target number
- Wait 1 minute for any incoming commands
- Parse any incoming messages (only from allowed numbers) and excute the command
- Go to deepsleep
1 - Download this repository
2 - open esorex32/ES_CFpages/functions/shared/myconstants.js
3 - put your own timezone and TTL here. You can change the TTL for cloudlfare KV here, currently your uploaded images and files are stored on KV for 24 hours
4 - find const My_TZ in home/servapn.html home/servcam.html home/servvid.html home/servmic.html and change it to your timezone
5 - Sign up for a free account on Cloudflare
6 - Go to dash.cloudflare.com -> Compute (Workers) -> Workers & Pages and create a new Pages project (using direct upload)
7 - Back to dash.cloudflare.com find Storage & Datbases -> Workers KV and create a new KV instance here, name it mykvns
8 - Select your newly created pages project in cloudflare dashboard and go to Settings
9 - In Variables and Secrets create a new plain text variable. name it CFP_PASSWORD and for the value enter your desired password (without any quotes or double quotes symbol). This will be your login password for your website. Create another plain text variable and name it API_KEY. This key should be consistent across all devices (just put a long random string that is hard to guess)
10 - In Settings find Bindings and bind your KV namespace to your project with the same name mykvns
11 - In Settings find Runtime and modify the value of Fail open/closed to be Fail closed
12 - Install Node.js and run Node.js command prompt
13 - install wrangler
npm install -g wrangler
npm update -g wrangler
wrangler login
wrangler pages project list
14 - your cloudflare pages project should be listed here
15 - upload assets to cloudflare using wrangler
cd esorex32/ES_CFpages
wrangler pages deploy ./home --project-name YOUR-PROJECT-NAME --commit-dirty=true
1 - install vscode
2 - install PlatformIO extension for vscode
3 - In vscode : File -> open folder -> open esorex32/ES_ESP32 folder
3 - open platformio.ini
4 - the first environmet (env:esp32cam_base) is only supposed to act as a base for other environments and does not have a source file but all the other environments do have a source file
5 - open the PlatformIO
6 - you should see all the environments of this project here each env here corresponds to a device in this project
7 - Before building the desired env you need to configure it first
8 - The configuration parametrs can be found in src/common.h
9 - make sure to put the domain and API_KEY you defined earlier for CF pages in src/common.h
10 - For the CAM module there are two modes of operation (JPG and MJPG), you can configure this using CAM_mjpg_enabled
11 - For each environment, build and upload the filesystem before uploading the code
- You do not need a 4G/LTE modem to test this project, you should be able to test the CAM module with a single ESP32-CAM, just use your local wifi credentials
- For insctructions to build the modules, please refer to: https://github.com/mmrdni/esorex32-build/
- Starting point of this project: https://randomnerdtutorials.com/projects-esp32/
- Audio: https://github.com/pschatzmann/arduino-audio-tools
- The wifi range extender in APN is a complete copy of this project: https://github.com/martin-ger/esp32_nat_router
- The password protection for the website is a complete copy of this project: https://github.com/Charca/cloudflare-pages-auth https://dev.to/charca/password-protection-for-cloudflare-pages-8ma
- Login procedure for ZTE MF79U: https://zaage.it/projects/prometheus-exporter-for-zte-mc801a-hyperbox-5g/
- Google Gemini: https://gemini.google.com/
- Microsoft Copilot: https://copilot.microsoft.com
- Currently there is a limitation of 1000 writes/day applied to Cloudflare free tier (KV storage)
- It might take a few tries for the APN to unlock the ZTE modem (only if PIN code is set for the SIM card)
- For some ESP32 boards hard-reset is necessary for the OTA to take effect
- The default upload speed for SIM_CAM (2G/GPRS) is really low. try increasing the speed by modifying chunk size and chunk delay
- If you want to build the Sender_audio, disable the networking stack of audio-tools library . To do so, find .pio/libdeps/sender_audio/audio-tools/src/AudioToolsConfig.h and comment all the following lines (around line 300 and 333)
Since we use esp-now to send audio and not wifi, this part is not necessary but recommended
and
- There is a device specific string (APN_ZTE_AD) for each ZTE 4G/LTE modem (only changes after ZTE firmware update). To get this string, try logging in to your modem with your browser in developer mode (press F12), and enter the PIN code of your SIM card using the browser UI. Now search for AD in network requests. You only need this if PIN code is enable for your SIM card
.png)


![How Much Lego Is Too Much? [video]](https://www.youtube.com/img/desktop/supported_browsers/firefox.png)
