Sending messages between Raspberry Pi using ScratchGPIO

NB Only available in dev version
http://cymplecy.wordpress.com/2013/11/26/scratchgpio-development-testing/

For a while I’ve wanted one computer running a Traffic Light program to easily talk  to a  Pi running as robot vehicle so that the robot can respond easily to the traffic light  sequence.

And extending this to another robots crossing the lights as vehicles or pretend pedestrians!

Link1I’ve added in a basic syntax for this

Link is used to setup connection to any other computer running Scratch with Remote Sensor Connections (RSC) enabled.  (All ScratchGPIO instances running on Pi are and it can be simply enabled on other computers by users)

Then simply, prefix any broadcasts that you want to send to the other computer with Send.  The other computer will receive the broadcast without the Send prefix e.g  Stop or Go

Ideas to enhance/change

Let Link work with just last octet of IP (ie. assume on the same LAN and automatically determine first 3 octets. (easy)

Try and come up with using last 4 digits of serial num like SID uses (hard)

Or something to make it less geeky if possible (hard)

Add a prefix/identifier to the broadcast so that receiving computer can identify/filter/differentiate non-local broadcasts (to prevent advanced Scratchers from taking control of a remote Scratch device without permission and make it possible to have more 1 computer sending messages into a remote computer)

The code is in the dev version (but liable to change) but please have a play and pass on your ideas/thoughts

Please remember my target audience are 7-11 year olds and their teachers 🙂

Simon

 

You may also like...

27 Responses

  1. Carlos says:

    Hi there
    I’m trying to broadcast through one raspberry to another with its IP address but it doesn’t work. Could you help me?
    I’m trying a simple broadcast lie your example, but nothing.
    Thx

    • cymplecy says:

      Are you using the dev version ?

    • cymplecy says:

      Just tried between Pi and and XP machine using dev version and it works ok – I did broadcast link192.168.0.11
      then broadcast sendhello

      then on XP I did when I receive hello
      say hello for 10 secs

      Clicked on broadcast sendhello on Pi and my XP machine said Hello 🙂

      Simon

    • cymplecy says:

      Make sure also that receiving compueter has Remote Sensor Connections enaabled
      ther is a bug on Pi that means you have to disable then re-enable it to make it work properly 🙂

      • Carlos says:

        I’m trying between two raspberrypi, but I’m gonna try re-enabling de Remote Sensor Conection and then let you know if it works.
        Thx 🙂

  2. Carlos says:

    I’m sorry I’m a little noob on this.
    I have onde rpi on 192.168.1.107 and another on 192.168.1.108 and I’v open Scratch on both and both send the message “Remote Sensor Connections enabled”.
    Then I made this simple code:

    On rpi with 192.168.1.107:

    When “GreenFlag” clicked
    Broadcast Join Link 192.168.1.108
    Broadcast Send roda

    On rpi with 192.168.1.108 I have:

    When I receive roda
    repeat 10
    turn 15 degrees

    Now when I click on the green flag on rpi (192.168.1.107) just don’t work 🙁

    By the way, I didn’t find out how to disable and re-enable the Remote Sensor Connections 🙁

    So, sorry to bother you again, but can you help me on this?

    • cymplecy says:

      1st thing is that once link is set up the broadcast isn’t needed again.
      So try on green flag broadcast link ……
      Then make space bar do broadcast send roda
      I’ll power up 2 pi later to check myself
      Simon
      PS must be running dev version.
      Your the 1st person to test it 🙂

  3. Carlos says:

    I found that I was not runnig the dev version.
    I’ve installed it (from your blog) and now with just this:

    Scracth rpi1

    When “greenflag” clicked
    Broadcat join Link 192.168.1.107

    When “spave” key pressed
    boradcast “Send roda”

    On Scratch rpi2:

    When I receive roda
    repeat 10 turn 15 degrees

    Should I activate Scratch rpi2 somehow to turn it to listening mode?

  4. Carlos says:

    Amazing 🙂
    Finally I got it working 🙂 Thank You!!!

    Listen, I know this is not the subject, but… have you ever tried to control an Ultrasonic Sensor with Scratch? I think its possible. Is this ScracthGPIO Dev prepared for it?

    Once again, it Works!!
    Now I’m gonna try to interact with 3 RPI and then I let you know how it goes 🙂

  5. Carlos says:

    Hi
    I’ve already connected the Ultrasonic Sensor with a breathboard to the RPI through a Pibrella board.
    On Scratch I’ve found the “distance sensor value” Sensing option, but it returns always zero 🙁

  6. Carlos says:

    Sort of…
    I’ve found some coding in Python to broadcast to Scratch and learn from it.
    I’ve made some adjustments and now I can broadcast to Scratch and sequence the other RPIs on Scratch. Basically I read some sensor values, send them to Scratch by broadcast and then it interacts with 3 other RPIs 🙂

  7. Bill Robinson says:

    “Please remember my target audience are 7-11 year olds and their teachers …”

    RFC: Whilst your ScratchGPIO is an utterly and unalloyed-ly brilliant project , if that is your actual target audience then either a) the rate of change of your API needs to moderate, or b) the documentation needs to march in lockstep with changes to the API.

    Otherwise your target audience is likely to get left behind.

    • cymplecy says:

      I am really bad at documention but I’d had an offer of some help recently 🙂

      I think if there had been any co-ordination AT ALL between the Foundation and its open-source software developers, then the huge gap in having working software that has occured since Christmas might have been minimised.

      But NO-ONE told ANYBODY ANYTHING (inc me 🙂

      But you point is well made and ScratchGPIO6 was my “vista” version

      Hopefully V7 will be stable for a year but if the Foundation pull any more big suprises without any warning – I think quite a number of us will be packing up and going home 🙁

      All is not well at all in the community 🙁

      Simon

Leave a Reply

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