Small Basic - Talking to Raspberry Pi

Published Feb 12 2019 05:13 PM 549 Views
First published on MSDN on Jul 03, 2016

Authored by LitDev

This blog is about communicating with a Raspberry Pi using Small Basic.

I summarise a Gold Medal award winning TechNet Wiki article by Philip Munts.  Follow the links to see Philip's original article and second follow up article .

Raspberry Pi

The Raspberry Pi is a small cheap computer.  It has no keyboard, monitor or other usual computer peripherals so is an ideal candidate to communicate with using Small Basic.

Raspberry Pi Model A+

Summary of Connection

Since the Pi is a fully working computer in its own right, the connection is really a connection between 2 computers.

As Philip says there are several ways this can be achieved (for example using a serial port), but the method he selected doesn't even need an extension.  It uses the Small Basic Network object.

Network.GetWebPageContents(url) allows Small Basic to send a message to a networked computer and receive text data that the networked computer returns.

The network url can be a local home network IP address like or http://familyPC or an internet address http://www...

The return from GetWebPageContents is some text.  For a web url this would be the html used by a browser (Edge, Chrome, Firefox etc) to display a web page.

The clever part is getting the Raspberry Pi to respond to a web request in a useful way.  This is achieved by installing a special linux operating system on the Pi that runs a Thin Server.  The Thin Server allows the Pi to act like a basic web server responding to web requests.  Philip provides a zip download and instructions to perform this step.

Philip then uses GPIO (General Purpose Input Output) pins on the Pi to control LEDs that can be controlled by commands sent from Small Basic.

Once this is set up you can communicate with the Pi from Small Basic and can set and get the status of the GPIO pins, in his example turning LEDs on and off.

To quote Philip's article:
The web server running on the GPIO Thin Server responds to requests of the following forms:

http://servername:8083/GPIO/ddr/n,s Set data direction (0=input, 1=output)

http://servername:8083/GPIO/get/n Get pin (state 0=OFF, 1=ON)

http://servername:8083/GPIO/put/n,s Put pin (state 0=OFF, 1=ON)

The commands are read by the Pi and either perform some action or return some data.

Philip's second follow up article shows how to achieve the same results using a cheaper Raspberry Pi variant.  Both articles are clear and provide detailed descriptions of the component parts and step-by-step procedures to achieve the connection.

See Also

Small Basic and the Raspberry Pi

Simpler and Cheaper Raspberry Pi GPIO for Small Basic

About Raspberry Pi

Small Basic - Arduino

TechNet Guru awards
Version history
Last update:
‎Feb 12 2019 05:13 PM
Updated by: