Octoprint with ESP32 with camera

Yes, they work very nice.
Just not very high resolution combined with a high frame rate, so dont expect a 4k resolution. But I bought the for 6 Euros ;-), and at 800 x 600 it gives 60Hz, good enough for a frame in octoprint.
The problem is that all the demo software is in Arduino and does either a stream or a jpg.
I changed one of these to use 2 webservers as the esp32 has dual core.
You can find this version here:

http://esp32_ip/stream
http://esp32_ip/jpg

Hi, I would like to use your system, but I have not quite understood how to do it from Platform.IO, I am not very practical ... :frowning:

Hi Daniele,

Hard to guess where you are stuck...
So assuming you have PlatformIO up and running with this code :slight_smile:
And you have a ESP32-cam board.

You can edit your wifi credentials in wifikeys.h

For first use you need to program the ESP using a COM port. This COM port needs to be setup in platformio.ini. Find the upload_port lines:
;upload_port = COM6 ;com port of the ESP32-cam
upload_port = x.x.x.x ;ip address of the ESP32-cam

Say your Com port is COM3, then change this to:
upload_port = COM3 ;com port of the ESP32-cam
;upload_port = x.x.x.x ;ip address of the ESP32-cam

notice the ";" goes to the other line.

Now you should be able to upload the program to the ESP32-cam.

When successful your board will have an ip-address and you can change the ";" again and fill in the ip, to upload changes in the program over wifi.

I hope this helps?

Regards

1 Like

Sorry but with Platformio I'm really limited :frowning:
this is the error it gives me back (I had already set WIFI key and COM)

Executing task in folder ESP32-cam-Octoprint-main: C:\Users\dorrico.platformio\penv\Scripts\platformio.exe run <

Processing esp32cam (platform: https://github.com/platformio/platform-espressif32.git; board: esp32cam; framework: arduino)

Platform Manager: Installing git+https://github.com/platformio/platform-espressif32.git
Error: Traceback (most recent call last):
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\commands\run\processor.py", line 70, in process
p = PlatformFactory.new(self.options["platform"])
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\platform\factory.py", line 54, in new
raise UnknownPlatform(pkg_or_spec)
platformio.platform.exception.UnknownPlatform: Unknown development platform 'https://github.com/platformio/platform-espressif32.git'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio_main_.py", line 109, in main
cli() # pylint: disable=no-value-for-parameter
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\core.py", line 829, in call
return self.main(*args, **kwargs)
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\commands_init_.py", line 44, in invoke
return super(PlatformioCLI, self).invoke(ctx)
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\commands\run\command.py", line 143, in cli
is_test_running,
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\commands\run\command.py", line 175, in process_env
result = {"env": name, "duration": time(), "succeeded": ep.process()}
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\commands\run\processor.py", line 75, in process
skip_default_package=True,
File "c:\users\dorrico.platformio\penv\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\commands\platform.py", line 332, in platform_install
force=force,
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\manager\platform.py", line 52, in install
spec, silent=silent, force=force, skip_dependencies=True
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\manager_install.py", line 49, in install
spec, silent=silent, skip_dependencies=skip_dependencies, force=force
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\manager_install.py", line 97, in _install
pkg = self.install_from_url(spec.url, spec, silent=silent)
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\manager_install.py", line 141, in install_from_url
vcs = VCSClientFactory.new(tmp_dir, url)
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\vcsclient.py", line 55, in new
src_dir, remote_url, tag, silent
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\vcsclient.py", line 137, in init
self.configure()
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\package\vcsclient.py", line 146, in configure
result = proc.exec_command([cls.command, "--exec-path"])
File "c:\users\dorrico.platformio\penv\lib\site-packages\platformio\proc.py", line 117, in exec_command
p = subprocess.Popen(*args, **kwargs)
File "C:\Users\dorrico.platformio\python3\lib\subprocess.py", line 800, in init
restore_signals, start_new_session)
File "C:\Users\dorrico.platformio\python3\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato

============================================================

An unexpected error occurred. Further steps:

============================================================

The terminal process "C:\Users\dorrico.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Hmm, I see.
Altough this builds a .bin file for me, I never did it this way. You would still need means to upload it to the cam board.
In your case it complains about the platform being unknown. My guess is that the esfpressif32 platform is not on your system?

Do you have VScode (it's free) installed? Platformio runs as an extention (ide). It would download the espressif32 from github (see platformio.ini). This also makes it easier to edit, upload and monitor.
instructions here: A professional collaborative platform for embedded development Β· PlatformIO

It should look something like this:

at the bottom you find -> = build and upload
Give it a go and you will be programming away in no time :wink:

1 Like

First of all I thank you, both for your kindness and for the fw you gave us for the OctoCam :slight_smile:

Eventually I changed the following line within the platformio.ini file as follows and everything worked (I had everything installed already, it just couldn't download the dependencies of the espressif):

before
platform = https://github.com/platformio/platform-espressif32.git; espressif32

after
platform = espressif32; https: //github.com/platformio/platform-espressif32.git

Basically I used the Stable version instead of the Development version

Thanks :slight_smile:

Happy to help.
Great job. Not so limited then :-).

I changed it to http... as someone might not have the esp32 platform installed in PlatformIO.

1 Like

I discovered these posts in my search for a firmware that would allow me to use an ESP32-CAM with Octoprint (and whatever other uses I can find for them!) and it seems to work well.
But my LED doesn't work, I've tried with two different ones, and I've tested with a LED-blinker sketch and the LEDs do work. When I issue the /ledon comamnd it writes "Done" but nothing happens, same thing with "ledoff." "Start_ota"seems to work since it will then appear in the Arduino port list as a network port.
I examined the code but since C++ isn't my strong point, it didn't tell me much.

Any thoughts would be appreciated!

Petter

Hi Petter,

In platformIO.ini the LED is set to: -DLED_BUILTIN=4
This is used in the code as: pinMode(LED_BUILTIN, OUTPUT);
Is you LED on pin 4?
If you are not using platformIO, than it is probably not set.
Replace all occurances of LED_BUILDIN with your pin (see the working blinker sketch) in the code.

I WAS trying to use Arduino IDE, but decided to try PlatformIO since I already had it installed for customizing Marlin firmware.
And after a humbling amount of trouble (including, but not limited to: the problems encountered by@Dexter2478 and the fact that VS Code doesn't appreciate Swedish characters in the paths) it worked like a charm! Thank you!

Great!
I will change the Dexter2478 issue :slight_smile: