External Links

Creative Science Centre


Micro Web

This is a web server that will run on a device that has an SD Card and a network interface. The testing was carried out on a BV508_V2b

  • PC web pages
  • Dynamic pages page.html
  • Function calls page.byf
  • Images

Hardware & Setup

  • Firmware requires long file names *
  • ESP8266 should be connected to UAR1
  • Download the zip file and place on an SD card
  • Open BVSerial as normal and clear the flash by typing flclear(0)
  • Insert the SD Card, on reset this will automatically load and start the server
  • In a browser window type the IP address of the ESP8266
  • Sysflag on the ESP8266 set to 32 ** Done by automatically by the HTTP.init function

*Short file names can be used but the loader.bas and main.bas on the SD Card zip file will need to be changed. Also the demo web pages may need changing to the new short file names.

This is the very simple index page with 2 links that demonstrate how the server may be used.


The directory layout on the SD card is as follows:

\lib - these are library files to support the server. They have been taken from the standard library to be self contained.

\web - Contains all of the web pages for when a PC (non-mobile) device accesses the server.

Summary of how it works

In brief the function HTTP.server is called every half second by a task. This could also be in a continuous loop if needed. The server looks for any incoming text from UART1 (ESP8266) and acts on that. The flag on the ESP8266 has been set so that the full head from the browser is received. It is then possible to determine where the request is coming from - mobile or PC, however this is not put to any use so far.

If there is no page associated with the request then the index.html page is sent back. This is the default. If the extension is .htm or html then that file is sent back.

HTML files are scanned for <?bypic and if that exists then the page is processed, a temporary file is created and the temporary file is sent back. Lastly if the extension is .byf then a function with the page name is called and the function takes full responsibility of what happens next.

HTML Files

Where a page contains the <?bypic directive then these are for dynamic web pages similar to .php files but not using the php language. Instead ByPic is used as that is already on the processor (no way would php fit).

An example of this is in the GPIO Status page, the server takes the input from this page (file) and creates a temporary output file line for line until it comes across <?bypic at which point the server will process and interpret the input and only output what it is told.

.... code


Where <?bypic exists on one line by itself, a function is expected. Tin the GPIO Status example the function outputs text depending on what the GPIO is set to at the time. This function is compiles into the devices RAM and so should be removed at the end of the file otherwise eventually the RAM will fill up. On the GPIO Status example this is done at the end of the file thus.

<!-- <?bypic forget("analogue$") ?> -->

The function is used in the body of the example to write to the browser the state of the port. This is done using a special variable called echo$.

Pin 1 <?bypic echo$=analogue$(PORTA(PORT),1) ?><br>

Anything that is contained in echo$ is sent back to the browser.

  • The number of bytes between <?bypic and ?> is limited to 512 bytes
  • echo$ is limited to 255 bytes
  • Functions can be specified in the byp page as above or they can be part of the web server

BYF Files

If the page name .byf is specified then this must be a function on the webserver. The example contains just such a function that is within the webdemo.bas file. The function can do anything a normal function can - switch GPIO lines, get I2C data etc.

It must however send a page back to the browser otherwise it will leave the browser hanging and eventually time out. In the case of the Output Example it just sends the index page back.

A BYF page can be used instead of the BYP page particularly if the content is long or complicated.


To stop the server type taskclr. Add your own function on top of the server by using BVSerial. For quick testing, send a page using the browser and then in BVSerial type HTTP.server() which will service the page.

The html, or byp (but not byf) files need to be on the SD Card in the appropriate \web or \webm directory. This can be done through BVSerial using .upf, change to \web or \webm first.

The byf files are just functions on the web server and so they do not need to be on the SD Card so will be quicker to develop.