Intro
I discovered the ESP32 family when I made a monitoring system for my boat.I played with the ESP8266, and after considering the ESP32, I finally decided to use a ESP32-CAM for this project.
The idea is rather simple: when I'm away, I leave this module home.
It has a ESP32-CAM which is asleep until the motion detector senses something.
When that happens, the ESP wakes up and takes a picture, and sends it to me both attached to a mail and posted on Telegram.
I can then take any measure I see fit.
What you need for this project:
What | img | price in 2020 |
---|---|---|
Esp32-Cam | 4€ | |
HC-SR501 PIR | 5€ | |
MT3608 DC-DC | 1€ | |
18650 case | 5€ | |
FT232RL | (6€) | |
Total | 15€ |
Links are not an endorsement of the product and just provided for convenience sake. I get not cut.
That said, I do have a good experience with AZ-Delivery in Germany. They are reasonably cheap and very fast.
They also have a quite complete free library (registration required) in several languages. The pdfs in the library contain all the information you need to get started, say with the ESP32.
The ftdi is in parenthesis because you only need one for flashing, which you can reuse again and again. Also the prices are what they are because I bought several items at once. Buying 5-10 ESP-cam is cheaper than buying 5-10 ESP32, for some reason. But well worth the ftdi investment. There are several programmers but according to web comments, the FT232RL seems to be the best one,best being defined as no transmission error when flashing. Note also that the FTDI can be used for other board than the ESP32-Cam, the Arduino pro Mini for example.
Putting it together
The project is fairly straightforward. The tricky part was to squeeze 5V out of a 3.7V battery, and that's why the MT3608 is there.
The wiring looks like this:
To flash the esp32-cam, you need an ftdi programmer, because the chip doesn't have a usb:
Do read the doc of your FTDI, because there are not all the same, even if they look the same. If you look at it with the usb to your right, from top to bottom, you can find:
var 1 | var 2 | var 3 (5 pins) |
---|---|---|
GND | DTR | 3V |
CTS | RXI | TXD |
VCC | TXO | RXD |
TXO | VCC | GND |
RXI | CTS | 5V |
DTR | GND |
And on mine it is almost hidden by the voltage switch, so it was not exactly straightforward. And talking about voltage switch, make sure to check whether it is on 3V or 5 V and cable accordingly (or change the switch).
From a programming point of view, I just took the sample code from the motion sensor, hooked the code for taking and storing a picture, and coupled the whole with email sending and Telegram posting. (See boat monitor for references).
Some pics:
Lessons learned
Considering the price of the esp32-cam (€4 in bulk), I thought I would just buy a batch and use them for everything. While it offers much less pins than the esp32 (8<>32), a €2 difference made it worth. Not to mention the difference with other arduino board. A Nano like I used in other projects costs the same €4, but is more more limited in terms of memory. However, as usual, there is nothing like a bit of experience....- In terms of programming confort, the esp32-cam is definitely behind the esp32. You need the ftdi to flash it, but the wiring has to change to test what you wrote. Complete waste of time compared with the ESP32 where you flash and can see immediatey the result in the Arduino IDE monitoring window. I ended up developping on a spare esp32 and then, when everything was working, flash the esp32-cam for last tweaking.
- If you factor in the MT3608 cost, the difference with the ESP32 is only €1/piece. The development time saved might be worth it.
- Let's not forget the ESP8266 (NodeCMU). Still alive and kicking, if you don't need bluetooth, it is like the ESP32 (ok slower and less memory, and 24 pins), but also for €4 in bulk).
- Best of both world: develop on the ESP32, deploy on ESP32-CAM :-)
Going further
I'm thinking of other applications, because the motion sensor could trigger any switch, ie light, music, whatever.
Potentially useful for basements, etc, even if the esp32 is probably overkill for such simple tasks :-) but with a relay switch like the kf-031, the sky's the limit.
Later addition: Yes ! the sky is the limit, especially since David Niven had the briliant idea to port the fuzix minimal unix to the ESP8266 and he promised he'll be working on an ESP32 port later.
Some tips to get started.
Even later: somebody done it.
This is of course absolutely fantastic, because it means you can get an (albeit minimalistic) working unix on a €5 chip!!! Cheapest unix machine in the world!
Some genius also ported Linux to the intel 4004. I know;Useless, but absolutely brilliant!!
There is also a dos port.
For windows, you'll probably need a driver for the ftdi.