Video recording with an ESP32 + PIR sensor

I’m using Visual Studio 2019 + Visual Micro plug in. There were missing definitions connected with sd card, I willl try Arduino IDE. Thanks for giving me pointers, I shall experiment with write speed. My card is Panasonic HC 4GB.

EDIT it is only speed 4, ordered 8GB speed 10, will see how it goes

1 Like

@red_car Do you have this chip on the board?

Yes... PSRAM chip. I understand some ESP32-CAMs come without... so essentially a very small buffer for storing the frames.

yes, I measured mine and it is possible to store 43 frames at 800x600

Be interested if you can actually set MAX_FRAMES that high. I seem to remember I had problems initialising the camera when the value was too high... not sure how the memory gets allocated, but it was throwing errors that seemed to indicate insufficient memory.

Ultimately if your card is too slow, you'll still fill the buffer... it'll just take longer.

Yes, if you try high number the memory allocator fails, understandable, but 4MB buffer is not bad, you can have 10 frames at max resolution. it seems the easiest way to use circular buffer but strange thing is, I tried another card that said speed 10 vs card with speed 4 and I don’t see any significant difference in speed. Mind you I’m experimenting with capturing at 24fps, 15fps would probably be more than enough

@red_car Just curious if you had this problem before. I have 3 cards, 1 of which often fails to initialise in 1 line mode but has no probem in 4 line mode. All I can think right now if that maybe the card is dodgy, but it is Panasonic and it is brand new.

@killzone_kid Not something that I've had an issue with. I only had a couple of cards... both worked in 1-bit and 4-bit mode. Maybe something manufacturer specific?

Is ESP32 a good choice for video recording? Isn't Raspberry pi a better option for this?

I guess it depends what you need.

A Raspberry Pi is a significantly more sophisticated device than an ESP32, but if you're cracking nuts you don't need a sledge hammer :slight_smile:

Please do propose your setup, I'm interested to compare options

I came across this little WaveShare board called ESP32 One Mini, apart from camera, SD slot, mic, battery plug and 40 pin connector it has 8mb of PSRAM instead of 4. Looooooooooong buffer!

1 Like

The setup that I am thinking consists of a Raspberry PI 4 with official power adapter, an RPI camera V2 and a PIR sensor.
Here you can see such a setup: Realtime Video Streaming from Raspberry Pi (Zero, 3, 4) with Pi Camera using RPI Cam Web Interface - YouTube
If you want to study more about other camera options in hand, here is a good write-up about camera PCBs: Introduction to Camera PCB - PCB Tracks

Valid option but big and expensive.

@red_car Purchased a few cards of speed Class 10 and oh boy, returning all back

I have:

Samsung 32GB Class 10 - the fastests, what you would expect from class 10
Panasonic 4GB Class 4 - quite slow
SanDisk 4GB Class 2 - faster than Panasonic! (maybe Panasocic is a knock off)

I bought...
UMOX 8GB Class 10 - absolute rubbish, much slower than Panasonic
Gigastone 8GB Class 10 - exactly the same rubbish as UMOX

These were £4-£5 per card from Amazon, returning this rubbish and getting a well known name

Yeah... I suspect a lot of the cheap ones are fake.

Do you still get Buffer full messages with the Samsung one?

Well I kinda started from the basics and just finished the capture and writing to file in separate threads. the writing always dragged behind, how much depends on how fast is the card and resolution. also with 40 length circular buffer it takes awhile for the capturing pointer to catch up with the writing pointer. Samsung is the fastest and I can record for 10 minutes and it will be like only 20 frames behind writing (no skipping) pretty good but tomo I have SanDisk that is guaranteed to write at least 10MB/s is coming (you can get 90 if you want but quite expensive) so I have a good feeling. Now I’m writing just a bunch of jpegs one after another into the same file, next step will look into movie format and write something I could play back. Your code is good inspiration I look it up often.

Sounds like you are making good progress.

One other thing I noticed was the the JPEG size can vary quite a bit depending on what you are videoing. I guess the compression works better with some images than others. At one point I thought I had it all working perfectly (no skipping), then I moved the camera to a different location (brighter, and more action occurring) and started to get skipped frames again.

I guess if you can get a super quick card then you won't have any issues.

Oh yes, SanDisk class 10 is mega fast! But, I have also ordered what would be equivalent of Class 30 to compare. Recording 25fps 800x600 with no issues at the moment

1 Like

WaveShare ESP32 One Mini is a bit of a disappointment, so much potential at first glance but then it looks like everything starts interfering with everything. Card slot is connected to SPI all good until you init camera. If you want to use external card reader and connect as MMC to HS1 it will interfere with PSRAM and flash, connecting to HS2 will interfere with camera even in 1 line mode. Last thing Im going to try is maybe I can write straight into the card without using PSRAM, if card is fast enough. Otherwise shame on you WaveShare

Found this little board, it has everything (no mic) MMC SD card reader, 4MB PSRAM, and battery solution plus plenty of pins. Very similar pin layout to ESP32 CAM. Delivery is half the price of the board I think I’m going to stick with ESP32 cam and charge board for LiPo

@red_car Hey, in case you are interested in no hustle battery solution, you can get a charge board for D1 Mini and do a little modification to it