Raspberry Pi Auto-Hotspot

Initial software from http://blog.sip2serve.com/post/48420162196/howto-setup-rtl8188cus-on-rpi-as-an-access-point

The concept of headless Pi at Jams and in classrooms has always been a subject close to my heart and recently I’ve been trying to go down the route of a Pi that see if it gets an IP address from a DHCP server, if not – it turns itself into a hotspot so that other computers can connect and communicate to it over WiFi.

So sequence should be

1.  Check if IP been handed out on WiFi from a DHCP server – if OK End

2.  If not, create hotspot for other Pi/clients to use.

The basic software needed is something called hostapd to make the Pi appear as a WiFi access point and dnsmasq so that it can hand out ip addresses to anything connecting to it.

Current situation

Note:  Hopefully this current state will be taken over by @heeedt  https://github.com/heeed/hotpi

Working Hotspot (but no automatic changeover) using 8188CUS based adaptors

To get this working you need to connect your Pi to the internet using a LAN cable.

Then copy and paste this into an LX Terminal session

wget http://git.io/wZV8tg -O ipispot.sh

and then type

sudo bash ipispot.sh

You will be asked a series of questions but unless you an advanced geek or the network you are running on is using 10.0.0.xx addresses – just accept the default for each question

The only exceptions to this would be for your country and WiFi channel number

At the end, it will ask to reboot – once done, you should now see a open ClassPi available WiFi connection that you can connect to.

The hotspot does not supply a bridged connection to your LAN and the internet – (it would be an access point if it did that) it is purely designed to let you connect to it from a WiFi laptop or any WiFI enabled device such as as tablet

Please try and give me feedback


Why Traffic Lights are good for Computing

I’m well known for promoting the simulation of Traffic Lights using Scratch so I thought it was about time I said why and explained how good they are for the new computing curric.

In the old days,  Data Harvest with with Flow-Go box and GO software were the No 1 method of engaging pupils in the practical computing.

The Flo-Go box has yet to be bettered (or equalled) in terms of its design/sturdiness and ease of use.

The Go software had many activities but no 1 in my mind was the concept of simulating Traffic Lights.  They even provided a 1 m high cardboard set of lights with Red/Amber/Green – a wait light and a switch for whole class room

The hardware was superb but the programming software was based on flowcharting concepts.

Which was fine at the time but then Scratch came along :)

So, although the hardware stuff was brilliant, Scratch was such a transformation in bringing programming to young people that I switched to doing all my teaching using it and abandoned  Flow-Go :(

I still loved using Traffic Light simulations to teach control concepts but missed having real lights to control.

2 Years Ago
The Raspberry Pi was launched with Scratch built into it and the capability of easily controlling its GPIO pins.  The PiFace team very generously shared their code with me and I’ve built up ScratchGPIO so that Scratch on Pi can be used to control lots of hardware plugged into the Pi and we can now do “real” Traffic Lights again :)

Using Traffic Lights as Teaching Tool.

You can approach this in various ways – I like to use it as a bit of Road Safety exercise and a test of observation skills to see who knows what the main TF sequence is.

It turns out not many young people know the full sequence and you can have a lot of discussion on why they go Green/Amber/Red – Red & Amber/Green

(TopTip: Always start off from Green as the sequence down is much simpler than the sequence up)

So then you can get your pupils to program up the Green/Amber/Red sequence.

The move onto the Red & Amber/Green up sequence.

Then we can discuss and get into the pedestrian crossing version with its flashing Amber.

Then add in Red/Green Man – and the Wait light – and the button

So with all this we have used sequencing, repetiton and hardware input/output .

But we can also use costume changes on a TF sprite to do the same (or as well as) as using LEDs

And have a baby doing cartwheels across a crossing when the lights go to Red :)

I love it :)



Arduino class-set in Year 6

Today I tried out a class-set of 15 Arduinos with LEDs with Win 7 laptops with a Year 6 class with past experience of Scratch.

First  issue was that I only managed to get 8 set-ups working before the start of the lesson!

This was due to driver issues – I thought I was OK as I’d used Arduinos in the past in the school but all machines wanted to install a new driver and only 4 of them decided that the ones it had already were suitable.

With all the others, I had to download the latest Arduino package and use the drivers in that.

After that, plain sailing using ScA (Arduino version of ScratchGPIO) to make some Red/Yellow/Green LEDs go on and off.

All groups had a full pedestrian crossing LED Sequence and Scratch cat walking across a Zebra crossing on the screen with quite a lot having cars going back and forth and one group had a baby doing cartwheels across the road!

Technically ScA throws an error if they save and then reload another script meaning it has to be killed and restarted but I’ll hopefully sort that out and get some input handling added to it so be can use switches as well.

As usual, forget to take pics – will try and do better next time.


Post Post

There may be as easy solution to the driver probelm!


Pin Trigger handling in ScratchGPIO

I was looking at some of William Bell’s RPiScratchIO scratch code and notice that he had the concept of receiving broadcasts on inputs pins changing state.

So I’ve started implementing this (in dev version)

Basic concept is that if an input changes state – it will send a broadcast message to Scratch.

So if Scratch has a hat block that says

On Trigger received
Say “An input has changed state” for 2 seconds
Broadcast ResetTrigger

then if  any pin changes from 0 to 1 (or 1 to o) then Scratch will run the On Trigger block.

To make sure that only one event is dealt with at a time, my handler will not send any more changes until it receives a ResetTrigger from Scratch which is why that Broadcast ResetTrigger command is at the end.

As well as this global trigger, each pin has its own trigger so to just detect a change in pin7 use

On TriggerPin7 received
Say “Pin7 has changed state” for 2 seconds
Broadcast ResetTriggerPin7

If using an addon that names the inputs (say Switch) then the following would be triggered on a switch press

On TriggerSwitch received
Say “The switch has changed state” for 2 seconds
Broadcast ResetTriggerSwitch


Sending messages between Raspberry Pi using ScratchGPIO

NB Only available in dev version

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 :)



Change to Ultrasonic behaviour

Dev Version only

My ultrasonic handling code now runs in its own separate thread and defaults to returning an update distance measurement every 1 sec.

This can be change by creating an UltraDelay variable and using

set UltraDelay to xxx

If xxx = 0 then it will run as fast as possible which is currently about 5 times/sec or equivalent to xxx =0.2


You can also use

Broadcast UltraDelayxxx

if you prefer

Raspberry Pi SID testing using LAN->Laptop cable

Today I took my 6 Pi into one of my schools and connected them up to the school Win7 Pro laptops using a direct CAT5 cable and powered them from USB charger batteries.

They all performed fine technically and it was a great success (if I say so myself) :)

[I could only get 5 to work in the lesson as the last SD card imaging took over and hour instead of the usual 15 mins but that's a separate issue ]

By connecting them direct to laptops via cat5 cable means they didn’t need WiFi adaptors and therefore no configuring of the laptop was needed.

This is because I used this post to set up the Pi to automatically try and use an IP addressing the same range that Windows machines default to ( to

The reason for doing it this way is that I only have 1 school left with pupil desktop machines – all the rest use laptops/net-books/IPads so there is no chance of plugin any Pi into any monitors/main network ports.

The Pi are also set up to be SIDs  and therefore for the pupils to get controlling the addon boards plugged into them (mixture of PiDie,Pibrella,PiStep and Ladderboards) all they had to do was run the Handshake.py program (which I’ve wrapped up into a windows .exe file), saved it to a network folder and stuck a shortcut toit on the desktop.

Once they’d handshaked with SID running on their Pi, They simply loaded their normal Windows Scratch 1.4 and loaded in a basic script to switch all the LEDs off and On to test that everythgin was working.

From the start of a 1 hours lesson (and considering this was the first time we’d done it) 3 out of the 5 groups (only a 15 intake class luckily) had got a full Traffic Light –  Green/Amber/Red/Red and Amber/Green sequence going.

Lessons Learnt

All the AddOns responded to LED1..n On/Off commands except for the PiStep (as its normally used as a stepper) and that group needed to use Pin11,12 and 13 and it meant separate instructions for them so better to make sure all boards can respond to same commands of make sure individual help-sheets for each board are printed out.

Once group didn’t push their CAT5 cable in until it clicked (obviously as a tech I knew this and didn’t bother telling them – so I’ll make sure that’s in the instructions next time)

Also, I’m going to make a tick sheet of plug in sequence just to make sure its all done in a good order.

Laptop on and logged in, cat 4 plugged into laptop,cat 5 into Pi, power lead into Pi (this is the fiddly bit they found) and then power lead into battery supply.