ESP32 camera with image refresh in basicui

Hai,

Over a week ago I bought an ESP32 + camera module. Grabbed some example firmware from the internet and got the streaming webcam running. Then thought to just “simply” add the camera to the openhab basic UI which we are using. Cost me a lot of googling, to the point where I got really frustrated.

But…

Got it working. So here are my steps:

1) Fix the ESP32
Modified the ESP32 arduino example, so the camera does also support captures (single snapshots) next to streaming.

esp32_camera_adv_2.txt (10.8 KB)

Use the IP of the ESP32 and you get the stream, add “/capture” and you get an single image. Refresh browser to get next image.

My camera: http://192.168.2.90/capture

2) HTML page
Simple HTML page which will load the camera image and scale it (!). This was something I learned from one of the other forum solutions.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv=”Content-type” CONTENT=”text/html; charset=utf-8″>
<meta name="viewport" content="width=device-width, minimum-scale=0.1">
<meta http-equiv="refresh" content="10">
</head>

<body style="margin: 0px; background: #ffffff;">
<img style="-webkit-user-select: none;cursor: zoom-in;" src="http://192.168.2.90/capture" height="420">
</body>
</html>

3. Sitemap / item
Add a webview to your sitemap.

sitemap matthijs label="Testing Some Sitemaps"
{
	Frame label="ESP32 webcam" 
	{
        Webview url="http://192.168.2.120:8080/static/esp32webcam.html" height=12 icon=none
    }
}

4. Enjoy

4 Likes

Hi Matthijs, thanks a lot for sharing.
I will try this. It would be helpful to me if I could have a scaled image.

Greeting

can you provide more infos on the hardware and cost?

Hai,

Google “ESP32 camera module” and you will be overloaded with results. General < EUR 10 including shipping from China.

Greetings Matthijs

yep thanks. just found it. awesome!!! but I need a 3D printer for the case :wink:

Just a heads up that these cameras only seem to work with a single mjpeg stream at a time (maybe it was my mistake causing this and they can), so they won’t work if trying to view them from two tablets at the same time unless you setup the camera with the IpCamera binding instead of using them directly. The binding will copy and serve out multiple copies for you so no issues if you wish to view on multiple phones and tablets using the mjpeg stream.

Biggest issues with the ESP32 cameras for me are.

  • No night vision
  • No h264 which means you can not cast a stream to your chromecast devices.
  • Picture quality is shocking when not in bright daylight, they need loads of light to look OK. At least mine does.

If your happy with the above they are great for $9 :slight_smile:

1 Like

Do you have an alternative in mind? I was googleing small nodemcus with cameras in the past and the esp32 with the ov camera seemed to be main thing in this field

Amazon had this when I looked.

$38
Foscam C2E
Which has no mjpeg stream

Amcrest cameras start at $55

or any other cheap wificam from aliexpress that can be used with openhab?

1 Like

for me at least it must be flashable with custom code. I don’t really trust chinese stuff, therefore I would like to flash it. But this is only my personal opinion and thus the reason why I’m looking for an arduino/raspberry whatever based nodemcu

1 Like

Hi Matthijs,

Thanks for sharing the information. I have also been playing around with the esp32 Cam and was able to show the basic stream in the Basic UI using a simple “Image” item with URL, but the OpenHab app (IOS) did not like that. So, I’ve got some questions:
1.) Does your solution work for the OpenHab app? Also, please can you please share the sketch for the espCam.
2.) When you say, “Simple HTML page” for hosting the camera image/stream, where did you host it? and do you think the hosting a Webserver on the esp32 Cam will work?

thanks

Alex

Correct, the best way to get high res video streams in the ios App is to get a camera with h264 support and use HLS format via the ipCamera binding. This camera can not do h264 as the processor is not fast enough. If you use the Andriod app it does work with this camera using the mjpeg stream, but I have not found a way to display that on ios.

See the link here for ideas on showing the cameras picture…

Hi,

Will upload the ESP32 sketch again.
Will add the “webpage” wrapper too.
Will also check how the camera behaves on in iphone. Running android myself and that worked great.

Will be back.
Grt Matthijs

Update:

  • Added the code for the ESP32 to the original post.
  • The HTML page to show the image is also in the original post. The HTML file is in the /html folder of my openhab installation. Not on the ESP32.
  • Tested the page through openhab on my wife’s Iphone and that works correctly too.

So, technically everything is working fine. Just a very lousy camera on the ESP32. So good for an experiement and some fun, but not good enough for darker conditions.

Grtz Matthijs

1 Like

Did you try the iOS app on the iPhone or did you just use basic ui in a browser on the phone? I can not make mjpeg show in the iOS app, it works in basicUI. I have not tried the beta version of the iOS app that some people are using and it would be worth trying that out as a few things r fixed from what I read.

Super, much appreciated. Will test and let you know.