Raspberry Pi have worked with MIT to produce a Scratch2 compatible program that runs standalone on a Pi2/3/4 (but not older models or PiZero series).

It comes with basic gpio pin control but I’ve modified this, with help from David Ferguson (@fergusondavid6 ) and Nicole Parrot (@Cleo_QC)   so that it can take advantage of all the features of ScratchGPIO.

Grateful thanks to Sarah Lacase (@slmediation) and Darren Townsend (@forrishilier) for testing out the code and finding the bugs 🙂


It now comes ready to use, with a desktop icon, when you install ScratchGPIO from here

Using it

Double-click the new Scratch2GPIO 8plus icon and wait till it all loads up.

Click on More Blocks – Add an Extension – select Pi GPIO and click OK.

You should now have a new set of blocks to use that uses (as far as possible) the same syntax as the original ScratchGPIO running on Scratch 1.4

Main differences are

  • The black broadcast blocks should be used to send commands and not the orange control ones
  • You have to send variable changes off to ScratchGPIO yourself as Scratch2 isn’t as clever as its older sibling 🙂 So instead of old method of just changing a variable value e.g:
    set MotorA to 50
    you now would still create a variable called MotorA but to get ScratchGPIO to use its value you’d have to do this
    set MotorA to 50 (using red data block)
    set MotorA to MotorA (using black block where first MotorA would be plain text and second MotorA would be the red variable block)(I really need to get some images into this explanation 🙂

Ideas and suggestions (and bug reports) VERY welcomed 🙂

Contact me via twitter @cymplecy or email

You may also like...

13 Responses

  1. AlanCairns says:

    I’m very interested in using MQTT with Scratch 2. I have managed to send and receive MQTT messages using scratchClient but would very much like to try your system. I have the mosquito broker running permanently on a Pi 2 with the Stretch OS.

    I am trying to encourage my two grandsons 10yrs and 12yrs experiment with Scratch and IoT devices. The idea is to use Scratch 2 to communicate with other devices using MQTT. This would include a Pi running the Node-Red application.

    You say on your website that you have built in the capability of using MQTT in ScratchGPIO for the Raspberry Pi and that it is currently available for testing in dev version. Can you tell me how I can get this version?

    • cymplecy says:

      I’m very sorry that I’ve not been checking my blog for comments

      Its in the standard ScratchGPIO8 version nowadays – I’ve amended the post

      Sorry about the delay again


  2. Inner Peace says:

    How do I run the MCP23017 on Scratch 2 with those new features installed?

  3. Rudolf Schenke says:

    How can the “set … to …” block be used? From my understanding: The first entry should hold a pin number, the second one a value?! But I get it not work. Please give idea.

  4. Tharun says:

    Hello Simon,

    I would like to know if scratch language can be used to collect data from a sensor, say humidity and temperature (DHT11), through raspberry pi. I understand we could do it through python but would it be possible with scratch to read the data from any sensor? It would be very helpful if you could direct me on how to go about it.

    We are trying to teach middle school children on using raspberry pi to collect data from various sensors and trying to develope content for the same. I’m aware of sense HAT addon but we’d like to be more versatile on sensors, with scratch.

    PS: I didn’t know how to contact you and hence you find me in the comments section. Thank you for putting up this blog, this definitely bridges the gaps in many ways!

    Thanking you,

  5. Ramzi BEN ROMDHANE says:

    Hi, thank you very much for developing Scratch2GPIO.
    I would like to know if there is any update available.
    thank you for your answer.
    Ramzi a father!

    • cymplecy says:

      I’ve not done any work on it recently – what enhancement are your looking for?

      • Paul says:

        Is there a tutorial somewhere that shows how you built the blocks for Scrstch2GPIO? Or the source?

        Secondly, Perhaps we could setup a catalog if we can get developers to build more sophisticated blocks/classes or even code pieces for the community.

        • cymplecy says:

          No – there is no tutorial

          My code is on Github

          My code is generally considered the worst (but working) exmaple of Python programming in the known universe 🙂

          I just hacked into Scratch2 on the Pi to get it to talk to my ScratchGPIO python handler for Scratch 1.4

          Scratch 2 on the Pi has never really taken off as it offers little (apart from procedures) over Scratch 1.4 – runs more slowly and doesn’t work on PiZeros

          And with Scratch 3 coming closer to being operational, I think any use will decline further


  6. Eva says:

    Thank you for your post.
    Could you please tell me if Scratch2GPIO blocks are only available in English? Is there a way to translate them to French? I use Scratch 2 in French but my programs with Scratch2GPIO blocks are a mix of French and English and I would like them to be only in French.
    Thank you in advance!

    • cymplecy says:

      Hi – sorry – not been reading comments recently

      if you edit this file


      between lines 208 and 218 at the bottom
      you should be able to change the names on the blocks to French


  7. BOBO says:

    Dear Simon
    Why are some blocklys of my Scratch2GPIO8 ineffective?
    Only “pin..sensor value”,” high?” ,”set ..” are valid.
    Others are invalid。There was no response to the broadcast.
    And there’s no place to start GPIOSERVER.
    Because of this, I was confused for many days.
    I hope you can find time to answer my confusion.
    Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *