In the previous experiments, we dealt with the subject of TCP and access to web servers a lot. Today, the module is to act as a web server of its own for the first time.

Behind the door of the 11th day, there is a special cable that will be very useful soon. A special setup is not necessary today, since the program works similarly to the serial monitor programme of day one.

The program: Day11_TCPServer

Change the WLAN data as before and load the program onto your board. Then start the monitor. It may take a few seconds before the message that the board is connected appears. When the success message has appeared and the IP of the module is displayed, you can start with the first command in the Serial Monitor:

AT+CIPMUX=1

This command permits multiple connections to the module. You can then access the web server from several computers. Use the next command to start the web server:

AT+CIPSERVER=1,80

The parameter 1 means that the server is being started. 0 terminates a server again. The number 80 represents the port under which the server can be reached. HTTP requests sent by the browser are generally sent through port 80.

You can now open a browser of your choice and enter the IP of your module into the address bar and call it. The browser initially shows a loading message, but the Serial Monitor will show a change. You can see a request query similar to the one you have sent out manually before.

Die Browser-Anfrage
The browser query

The browser now waits for a response, and will show a loading sign until then, or until the connection is interrupted due to time-out. You can send a message to the browser with a version of a familiar command:

AT+CIPSEND=0,7

The parameter 0 indicates the client to which the message is to be sent here. This is necessary because multiple connections are permitted and several clients may therefore also be connected. The second parameter, here 7, again indicates the characters to be sent. > appears, and you can enter a simple

Hello

and send it out with Enter. Nothing will change in your browser at first. You need to close the connection before this can happen. For this, use the command:

AT+CIPCLOSE=0

Now you can see a Hello in the browser. You have implemented the first webserver application.