Efficient web server technology for resource-constrained microcontrollers - Embedded.com

Efficient web server technology for resource-constrained microcontrollers


Some time ago we published an article titled A fresh look at embedding a web server, where we suggested using WebSockets instead of HTTP with its traditional GET and POST commands. One commenter criticized the article for not being suitable for a broad category of small microcontroller based embedded systems.

The WebSocket protocol when used correctly uses fewer resources than a traditional web server. In fact, we believe WebSockets is the only viable option if you ever plan on TLS enabling the embedded web server. You may already be using an embedded web server in your device, but enabling TLS on a standard web server for a resource-constrained device typically ends in disaster. To understand why TLS creates such a problem for standard web server technology, see our tutorial When Not to Embed a Web Server in a Device.

Modern Web Application Reference Design for Microcontrollers

We recently committed our Embedded HTTP and WebSocket Server to GitHub. The Embedded HTTP and WebSocket server, called the Minnow Server, has been specifically designed for tiny microcontrollers with limited resources.

More importantly, we also included a reference example that shows how to build a modern real time web user interface for device management. The web application is a so called Single Page Application (SPA) that exclusively uses the WebSocket protocol for device management. The HTTP protocol is used only for loading the SPA. In other words, HTTP is initially used by the browser when loading the application on demand from the device.

The reference example includes real time updates of LEDs and a thermostat gauge, and it shows how to do firmware upload over WebSockets. The complete SPA requires only 41 Kbytes of flash memory storage space. Also, the WebSocket server requires very little RAM for the communication.

The following screenshot shows the SPA firmware upload page. The page is one of several examples pages that show how to benefit from the new WebSocket protocol. The firmware upload page shows how to create a drag and drop JavaScript upload logic and how to send the uploaded file to the server via the WebSocket connection. All messages sent via the WebSocket connection are sent as JSON text messages except for the upload, which is sent as binary data. Modern JavaScript can easily manage binary data and the WebSocket protocol supports both binary and text frames.

Get Started with the Minnow Server

Head over to GitHub, download the Minnow Server, and start writing your own SPA for your own microcontroller design. The reference example has been designed such that it can easily be reused for your own embedded device management application. The CSS and HTML5 building blocks in this application have been designed for reuse. In addition, the WebSocket communication JavaScript library included in the example is designed to be generic and can easily be reused in other applications.


The Minnow Server is designed for small microcontrollers, but since the reference example is primarily designed for educational purposes, we have limited the ready to use build environment to Windows and Linux. You can port the application to an embedded system, but it makes more sense to just use the design ideas in the reference example. You may of course use the generic parts “as is”.

Although the Minnow Server can be set up to manage several connections, the reference example is set up to manage one connection at a time. Attempting to connect a new browser window while another browser window is using the one and only WebSocket connection will not work.

Should you lack the required HTML/CSS/JavaScript experience, consider teaming up with a front end web developer. The best way to think about how to create an SPA is to compare the development process to creating a desktop application or a phone application that is designed to communicate with a device using TCP. Typically, different developers are in charge of the desktop app and the device's firmware and this is also the best way to design an SPA. The firmware and front end developers would need to agree on the communication API between the browser and server and vice versa. In other words, they would need to specify the type of messages sent over the WebSocket connection.

Wilfred Nilsen, Founder & CTO of Real Time Logic, has 28 years' experience in designing embedded software. Powered by a vision of connected embedded systems, he designed the Barracuda Application Server, tailoring it for the small footprint, real-time needs of embedded microprocessors.

2 thoughts on “Efficient web server technology for resource-constrained microcontrollers

  1. “Does this support HTML/SSI/CGI or is it Websockets and thats it ? Which version of HTTP ? Persistent connections ?nWho provides the transport ? What API ? I mean, does it work with lwIP ? Does it require the socket API ? Or, do you expect the user to p

    Log in to Reply
  2. “Whoa, lots of questions.nnThis post was meant as a short introduction. If you had navigated to GitHub, you would have seen the long list of supported RTOSs, TCP/IP stacks, etc.. You would have also seen that it can use lwIP without an RTOS, but that in

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.