ESP32 camera with image refresh in basicui


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.


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:

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>
<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">

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

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

sitemap matthijs label="Testing Some Sitemaps"
	Frame label="ESP32 webcam" 
        Webview url="" height=12 icon=none

4. Enjoy


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


can you provide more infos on the hardware and cost?


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.

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?



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…


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


  • 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.

Hi all,

meanwhile I got the cam and a 3D printer for the case :wink: Still testing, but so far it looks promissing.

I used the out of the box ESP32 CameraWebServer example sketch.
Then I loaded the html file mentioned above (just tweaked from 10s to 2s refresh) for integration into BasicUI (which works great in the Android openHAB app).
I’ve tested two clients at the same time (mobile phone and PC) which worked as well.
Now I need to print a nice housing and find a place for final implementation

Hi, I have a problem to have the image over the internet.
From PC in local connection works well but if I connect thru myopenhab it not works. It means also from smartphone if i’m away from home.

Did you solved the problem ?

Use the IpCamera binding and setup the new ‘snapshots.mjpeg’ feature.
Video items pass through, but WebView does not unless you setup VPN or another way for the files to pass through your firewall. Also please be kind to a community server by not leaving it stream through myopenhab, limit its use and if you want to leave it open setup your own cloud or use VPN access. Consider donating to the running of the server as video places a higher strain compared to simple switch states.