S3GPIO

What is S3GPIO?

S3GPIO allows you to use Scratch 3 in a browser on a Pi to control motors, add-on boards, neopixels etc. using the tried and tested ScratchGPIO engine.

How Does it Work?

S3GPIO relies on intercepting web requests that the Scratch translate extension makes and diverting them to a local webserver running on your Raspberry Pi.

Its a bit of a clumsy method but it works 🙂 and has the advantages that projects are fully-compatible with Scratch 3 and can be saved and uploaded to the main Scratch projects site.

Note: Its slower than ScratchGPIO running under Scratch 1.4, as its having go through a few layers of code and Scratch 3 doesn’t run too fast on a Pi – unless you’ve got a 4GB Pi4 🙂

Under the hood

S3GPIO launches a browser with a special Chrome extension that intercepts web requests that the Scratch 3 translate extension makes back to the Scratch servers

If you use a translate block like this

it will still go straight off to Scratch website and be processed normally.

But if you put [ ] around the word(s) like this

the request will be sent to a web-server running on the Pi itself. *

You don’t actually have to worry about doing this yourself in S3GPIO as I’ve created some defined blocks that make things very easy to use.

PLEASE NOTE – S3GPIO uses physical pin numbering
You can say gpio 17 on instead but its not recommended as some bits are hard-coded to physical pin numbering)

Click here to install S3GPIO

*Further technical info
in practice, I use blocks like this

The timer is there to stop Scratch translation extension caching identical sequential requests
And the closing ] is not necessary – I just use it to make things look nice but its not needed at all