Scratch Interface Device (SID)

Note:  This assumes you are wanting to use it instead of ScratchGPIO running on a Pi.  It is only for Scratch 1.4 and using ScratchGPIO syntax

Acknowledgement: Connection concept/original code supplied by Martin Bateman 🙂

Although a Raspberry Pi can be programmed to use Scratch to control the GPIO pins, because of the limited computing power of the original Pi, once the Scratch scripts become  longer and more complex, it can become slow to use.

And if you want to control the pins from Scratch on a battery powered Pi, then you have to use remote viewing software (VNC) to do this.

However, there is another way of using the GPIO pins on your Pi – turn it into SID – a Scratch Interface Device – and simply use Scratch on a desktop/laptop PC and get it to remotely control the GPIO pins via a WiFi connection.

To do this, first follow the instructions to install my normal ScratchGPIO software and then install the extra software to turn your Raspberry Pi into a remote SID (Scratch Interface Device)

Installing SID

Your Raspberry Pi needs to be connected to internet to install the software.

Copy the text below ( left click just before the s of sudo and drag right until all the text in the line, up to and including isid.sh, as been selected) then right-click and select copy. Open up an LX Terminal window and select Edit and the Paste that into an LX Terminal window and run it to download the installer..

wget https://goo.gl/GFD9ok -O isid7.sh

then just type (or copy and paste as before)

sudo bash isid7.sh

MAKE SURE YOU MAKE A NOTE OF THE 4DIGITS ON YOUR SCREEN – YOU WILL NEED THIS TO CONNECT

Reboot your Pi

(If logged in as a different user, then type sudo bash isid5.sh yourusername)

PC Computer

At the moment, the software on the PC is a simple python program that allows you to enter which SID you want to use.  (As you might have a few in a classroom situation)

To do this download and run the following program on a Windows computer

http://bit.ly/1NeOPNs

Use this code for a Mac running Python 3.3
https://www.dropbox.com/s/4x8rc0zgv1k98ht/handshake_py3.py

and then enter the last 4 digits of your Pi’s serial num and then press Connect. As long as you do this within 5 minutes of switching on your Pi, then it will connect.

You can find your RPi serial number digits by doing

cat /proc/cpuinfo

in an LXTerminal window on your RPi.

Put them into the above script and save it as handshake.py.

Getting your SID to connect to another computer

Reboot your RPi and after a couple of minutes yo should notice that the on-board green SD card activity LED is flashing the morse code for S (3 dots) This means your RPi is listening out for the next 5 mins for a connect message from your other computer.

Simply run the handshake.py program on your main computer and then enter the last 4 characters of your RPi serial num that you found out earlier and press connect.

Watch the green LED on your RPi and you should notice that it changes to flashing an O in morese code (3 dashes) for 30 seconds and then goes out.

Finally, launch Scratch on your main computer and enable Remote Sensor connections (right click on bottom block in Sensing section)

You should then be able to run exactly the same Scratch scripts on your PC as you can on your Pi and get the same control of the GPIO pins.

If you have any problems – please contact me @cymplecy on twitter or mail simplecy at google mail.com

Plans

I think the RPi should broadcast its last 4 digits or its serial number so that the program at the PC just needs to pick which one to connect to from a list.