---
title: "Image Capture and Streaming Webserver using W5100S, RP2040 and OV2640"
url: "https://maker.wiznet.io/viktor/projects/image-capture-and-streaming-webserver-using-w5100s%2C-rp2040-and-ov2640/"
markdown_url: "https://maker.wiznet.io/viktor/projects/image-capture-and-streaming-webserver-using-w5100s%2C-rp2040-and-ov2640/md"
type: "WCC: WIZnet Created Content"
author: "viktor"
author_url: "https://maker.wiznet.io/viktor/"
original_author: "Viktor"
published: "2023-09-07"
language: "en"
tags: ["Webserver"]
hardware: ["WIZnet W5100S-EVB-Pico", "Arducam Mini 2MP Plus"]
likes: 1
views: 2141
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Image Capture and Streaming Webserver using W5100S, RP2040 and OV2640

> This example aims to demonstrate how to implement simple webserver and transmit image from OV2640 camera to webpage using WIZnet W5100S.

Original author: Viktor

## Components

- **WIZnet W5100S-EVB-Pico** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5100S/w5100s-evb-pico))
- **Arducam Mini 2MP Plus** x 1 ([docs](https://www.arducam.com/product/arducam-2mp-spi-camera-b0067-arduino/))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))

## Documents and links

- [webserver.ino](https://github.com/wiznetmaker/W5100S-ArduCAM-Arduino-Examples/tree/main) (code)

## Article

## Libraries used in the project

1. [Arducam library](https://github.com/wiznetmaker/W5100S-ArduCAM-Arduino-Examples/blob/main/Webserver): please pay attention to important note in main readme file.

2. [WebServer](https://github.com/khoih-prog/EthernetWebServer/tree/master) by Khoi Hoang

## Project summary

Webserver wil be serving 3 pages:

1. Root page - shows simple text and server up time

2. Capture page - when user visits the page, the camera takes single shot and transmits to the page

3. Stream page - upon user visit, the camera sends frames in real-time.

## Code explanation

### Ethernet and webserver related code:

For test purposes webserver will be running on static IP which is coded in defines.h file.

**handleRoot() Function:**

```
- This function generates an HTML response with information about the server's uptime and serves it when the root URL ("/") is accessed.
```

**handleNotFound() Function:**

```
- This function responds with information about the requested URI, HTTP method, and arguments when a page is not found (404 Not Found).
- If a query parameter "ql" is provided in the request, it changes the JPEG quality setting of the camera module.
```

**serverCapture() Function:**

```
- This function initiates a camera capture, measures the time taken for the capture, and then calls `camCapture()` to send the captured image to the client.
```

**serverStream() Function:**

```
- This function sets up a multipart response for streaming video frames.
- It continuously captures frames from the camera and sends them as parts of a multipart response, creating a live video stream.
```

### Camera related functions

**test_capture() Function:**

```
- This function clears the FIFO (First In, First Out) flag of the camera and initiates a capture.
```

**camCapture() Function:**

```
- This function captures an image from the camera and sends it as an HTTP response with the appropriate content type and length.
- It reads the image data from the camera's FIFO buffer and sends it to the client.
```

**read_fifo_burst() Function:**

```
- This function reads image data from the camera module's FIFO buffer in burst mode.
- It processes the image data and prints it to the serial port. This function is not directly used for serving HTTP requests.
```

**i2c_init(), spi_init(), and camera_init() Functions:**

```
- These functions initialize the I2C and SPI communication interfaces and set up the camera module.
- They perform various checks to ensure that the communication with the camera module is established correctly.
```

### Setup & Loop

**setup() Function:**

```
- This function is the setup routine that runs once when the Arduino starts.
- It initializes serial communication, I2C, SPI, and the camera module.
- It configures the Ethernet connection and sets up various routes for handling HTTP requests.
```

**loop() Function:**

```
- The `loop()` function runs continuously, and its main purpose is to handle incoming HTTP requests through the `server.handleClient()` method.
```

## Demonstration

When connected to network, the board will run Webserver on designated IP.

![](https://maker.wiznet.io/upload/ckeditor5/77976289%5F1694099655%2Epng)

Full demo is shown below:

[Embedded media](https://www.youtube.com/embed/oNN7dklpJ64)

---

Source: https://maker.wiznet.io/viktor/projects/image-capture-and-streaming-webserver-using-w5100s%2C-rp2040-and-ov2640/
