What is S3GPIO?
In January, when Scratch 3 came out, there wasn’t a method of incorporating user extensions.
The Raspberry Pi Foundation have said that they aren’t releasing an offical extension to control GPIO pins in the near future.
As everyone knows, I’m very keen on using physical computing to develop programming skills and during Scratch 3 beta testing, I’d come up with an idea but didn’t pursue it much but now I’ve developed it into an interim solution that can be used until Scratch and Raspberry Pi come up with an official one
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.
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 – even a Pi3B+ 🙂
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 at some bits are hard-coded to physical pin numbering)
*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