Friday, February 4, 2022

ESP32 cam with Octoprint

 For an index to all my stories click this text.

As you will know by now I have been playing with the ESP32-cam module lately. I build a programming board for it, which makes life a lot easier. You can read that story here: http://lucstechblog.blogspot.com/2021/12/esp32-cam-programming-board-revisited.html

And there was a modification for that board which in certain circumstances makes sending pictures a lot faster: http://lucstechblog.blogspot.com/2021/12/esp32-cam-programming-board-revisited.html

And here is a small experimenting board for the ESP32-CAM: http://lucstechblog.blogspot.com/2021/10/esp32cam-experiment-board.html

For those who have no clue on what this is about: the ESP32-cam board is an ESP32 with an OV2640 camera which gives a decent picture (for a board of a few dollar anyhow) and I have a few plans for this.

My 3D printer is controlled by Octoprint. I have an USB camera attached and Octoprint will send a notification to my phone when a print has finished. Besides that I can watch proceedings on my phone or tablet from the Octoprint web-page whenever I want. The USB webcam has a low resolution (640 x 480) but it does the job. The ESP32-cam has a better resolution but is wireless and I wondered how difficult it would be to use that.

It took time.

Actually it took me some time before I had the wireless ESP32-cam working with Octoprint. Not that is was difficult to get it working, but there is few documentation on this subject and you have to use the right settings in Octoprint. Finding the settings was the time consuming part. So you will find them here a bit further on.

Installing the ESP32-cam in Octoprint.

First thing to do is to get the ESP32-cam working. If it works you can see the picture on a web-page in your PC.
To find the IP adress of the ESP32-cam just look into your router. My router shows all IP adresses of all attached (wired and wireless). I have demonstrated in previous stories on how to do that. You can read an example here: http://lucstechblog.blogspot.com/2020/01/sending-data-from-esp-to-domoticz.html
In my particular case the ESP32-cam has the IPnumber 192.168.1.84

If you know the IP-number we can go on to the next step.



Open Octoprints web-page and press on the wrench at the top-right side of the page that will open the settings page.



First enable the web-cam support with the radio button.

In the Stream URL enter: http://192.168.1.84:81/stream

Replace the 192.168.1.84 with the IP-number of your ESP32-cam. Add :81 after the IP-number and then /stream.
So in your case the command should be:
http://YOURIPNUMBER:81/stream

Finding the port number (81) took me a considerable time. So this makes it easy for you.



Press the test button and a small screen should open that shows the webcam stream.

It does not work.

Well it did not work on my end either at first until I realised something.
I had the ESP32-cam webpage still open on my PC. And there was the pitfall. The ESP32-cam can only stream to one device. So it streams to Octoprint or it streams to your PC. Not both at the same time.

When I closed the webpage on the PC everything worked as it should.



And there it is. The picture of my printerbed.

All in all a very cheap solution if you need a webcam for checking your 3D printer.

Till next time.
Have fun

Luc Volders