How to build the example server for the ESP32-CAM (AI-Thinker) for the Arduino IDE from nothing on Arch Linux
Unlike most operating systems, there is a special trouble (for noobs) with performing this on Arch due to the amount of compiling from source.
We want to run the v1 Arudino environment/IDE because it is the most compatible with tutorials online. If you are reading this you are probably a noob and following said tutorials.
- Get
base-devel
andgit
:sudo pacman -S --needed base-devel git
- Get the
arduino
package from the AUR repository:git clone https://aur.archlinux.org/arduino.git
. As a side note: I like to put this in a new folder in my home directory called Applications so I can keep track of my apps. - Enter the folder of the package you just cloned with git:
cd arduino
- Add the GPG signature for Arduino so your build doesn't fail due to unverified keys:
gpg --recv-keys 95FA6F43E21188C4
- Update your local package cache so you don't get unknown package errors:
sudo pacman -Syy
- Build and install the package. Also add any depdencies you need:
makepkg -si
- You can now run the IDE using
arduino
If you try run off and build the sketch now you will get the following error: ModuleNotFoundError: No module named 'serial'
. Let's fix that:
- Get PySerial: sudo pacman -S python-pyserial
Now if you try and build you will notice a new error. You will find the editor lying to you saying A fatal error occurred: Could not open /dev/ttyS0, the port doesn't exist
.
Well guess what editor, it does. You just can't see it. Unfortunately, the editor does need to read and write to this device to be able to
compile and deploy your code to the board. Let's give it access:
- Get access to read and write on the device:
sudo chmod a+rw /dev/ttyUSB0
This will give EVERYONE (every user on your computer) access to this device ... until you unplug it. Then it is back to root
only again.
Now we're ready to set up the hardware. Connect a bunch of cables to your board using a FTDI (red thing): Be careful when plugging in these cables as the manufacturers are sneaky and like to move around what pin position is actually for what pin. So make sure to check the text on your board before blindly plugging in cables.
If you're wondering where I got my red thing (FTDI): Aliexpress: https://www.aliexpress.com/item/1005007395673301.html
Now you've done all that. Don't forget if the board had some code on it before you gotta wipe that sh!t off!
To do this, you have to connect the GND
to the IO0
pin. - Just like what I've illustrated below in this diagram I stole:
AND THEN you need to press the RST
(reset) button while those cables are connected:
Now we are ready to actually make the software product. To do this, we need to get the board manager for our board. Right now the Arduino IDE is simply too stupid to know of it.
- In the Arduino editor, press
CTRL
+,
to bring up the Preferences menu. - In the "Additional Boards Manager URLs:" text field add the following link:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
If you need more space here because you already have a list. Just click the double-rectangle looking icon and it will open up a bigger dialogue menu as shown below. Just add it under a new line.
-
Now you need to download the board manager. Open the Board Manager under 'Tools'
-
Now search for
esp32
and install the latest version.
Ok, now we should be good to get the code and compile it. All we need to do is select the correct board, the correct port, and example.
-
This is the worst part of all. Finding the actual board. Select 'Tools' -> 'Boards' -> 'AI Thinker ESP32-CAM'. It can be very hard to find it but you will eventually. In Arch, the windowing sucks hardcore as well but just bear with it.
-
Now you have your board, get your port set correctly. It will very likely be
/dev/ttyUSB0
-
Just as a final safety measure, I also select the programmer
Esptool
: -
Now you have all that set, select the example for streaming with this board. 'File' -> 'Examples' -> 'ESP32' -> 'Camera' -> 'CameraWebServer'. This will load all the code you need to get this running as a template you can use to edit as you desire!
-
Let's make sure the template works first before we edit it though: Select the camera model by uncommenting
#define CAMERA_MODEL_AI_THINKER
(removing the//
at the start) and commenting out any other models in that block/list -
Now you just need to set your WiFi SSID (your network's name) and password like so:
That's it. We're done. Now we just need to put it on the board.
-
Press the forward/next/right arrow in the editor to upload the software to your board:
-
The upload is complete when you see the message
Leaving
Hard resetting via RTS pin
-
IMPORTANT: Unplug the
GRD
andIO0
cables so you don't remove all your newly uploaded soft/firmware. -
Now press the
RST
(reset) button again and you should now be able to discover your device using your router ornmap
or whatever and connect to it using its IPhttp://<your board's ip address>
!
You're done! ππππππ
Stole the board connections from: https://randomnerdtutorials.com/program-upload-code-esp32-cam/
I found this site pretty useful for the board's anatomy as well: https://lastminuteengineers.com/getting-started-with-esp32-cam/