CSF117 Module 8 Web servers in IoTmodule

Thumbnail Image
Journal Title
Journal ISSN
Volume Title
Welcome to the Web servers in IoT module. This module aims to facilitate learning about web server in your arduino microcontroller to serve web requests from remote Arduinos.
Welcome to the Web servers in IoTmodule. In this module we will answer questions such as What is a web server. Why use a web server in an IoT device? How can a web server be setup in an IoT? and What challenges exist with web servers in IoT. We will setup a web server in an Arduino and access it’s web pages or services from another arduino Embedded web servers have been around long before the concept of Internet of Things. Several manufacturers would embed web servers in their devices for purposes of reporting and configuration. For example some photocopiers machines that had network capability also had web server interfaces that would allow an administrator to login and obtain a log of print jobs. Home routers nowadays will almost always have a web server to allow you to configure several aspects of your network, as opposed to using a command line interface via SSH. Web pages are more user friendly than command line interfaces. Also, many end user devices have web browser clients, making it easy to connect to the device easily without extra hardware or software. Also, web access supports secure end-to-end data communication when TLS is used. When setting up a web server in your IoT device, it is important to remember that IoT devices have limited resources. Your web server should have a small memory footprint and also be lightweight. That way, there is efficient use of the scarce resources as well as low energy use. A web server should be chosen or developed with performance in mind, so that the device does not slow down when dealing with multiple user requests. To use an arduino as a web server, you need to have network connectivity via http or https protocols. When the web server is all setup and the arduino has connectivity, you can perform several tasks with the arduino via the web interface. For example, you can read the status of a sensor, control an actuator, and so on, by clicking on buttons on web pages served by the arduino device. Accessing any web server requires using the IP address or a hosntame or domain name that resolves to an IP address. The same applies in IoT. After running the web server software, you must assign the arduino device and IP address. That is the address that will be used to access the web server. If the arduino device can be connected with a valid public IP address, you can access the web server from the public internet. Which means you can control your IoT from anywhere. In Arduino, it is possible to write simple code to achieve a web server using the SPI and WiFi or Ethernet libraries. A similar architecture to PC web servers is used. There is provision for obtaining data from the client by reading the input stream, and also a provision to send data to the client by writing to the response output stream. Both the PUT and POST methods are supported, just like conventional web access. Web sockets, a newer way to exchange data between a web server and web pages, are also possible to use in Arduino. Web sockets allow for loading a web page only once. Subsequent requests do not need to reload the entire page. Bi-directional data exchange is possible in real-time. Using web sockets, it is possible to click on buttons and links so that only parts of a web page need to be modified, as opposed to reloading the entire page. One problem, though with working with a web server in Arduino Uno and Nano is low memory which can cause instability.