You know the story: while you’re calmly eating your cornflakes you go to check-out bus times on your phone app – only to be side-tracked by that irresistible click bait on social media…and before you know it, you’ve missed the No 42. Again.
Or, when you do check your app, you’re at the bus stop in plenty of time only to be kept waiting for about seventeen hours in the teeming rain.
Well at last there’s an answer to this bus catching quandary – the amazing #WhereIsMyBus
This neat visual alert tells you precisely when to leave for your bus stop. And, as if by magic, the No 42 will trundle up just after you arrive.
#WhereIsMyBus will even warn you if there are no buses running, so you can make other plans. Isn’t that just the ticket?
But there’s more. Because, when you’re not using it as a bus alert, this nifty little beast transforms into a #Cheerlights light.
So enough of the hype already. If you really want to catch that bus, here’s the secret of how to make the #WhereIsMyBus alert.
What you’ll need:
You’ll also have to know one end of a soldering iron from the other, but it’s pretty basic stuff.
For starters, let’s sort out the Raspberry Pi Setup bit.
Connect the Pi to your wifi and find the IP address. (You can find it by hovering the mouse over the wifi icon on the top right of the screen or by typing “ifconfig” into a terminal window:
The Internet address is likely to be listed by the Wlan0 block – it should look something like “inet addr:192.168.1.XX”)
Before you go any further, make sure your Pi is up to date and has some extra software on it. You’ll be glad you did. Now type these instructions into a terminal window (be warned – some take ages to install and make you go through the whole yes/no rigmarole, which is a real drag):
sudo apt-get update
sudo apt-get dist-upgrade
sudo systemctl enable nodered.service
sudo apt-get install mosquitto
You can now run your Pi “headless” – i.e. it no longer needs a monitor, keyboard or mouse to be connected.
On another computer connected to the same wifi network, type in the IP address:1880 (type the actual IP address of the Pi e.g. 192.168.1.13:1880). The Node-RED flow page will flash up.
If you didn’t know, Node-RED is an awesome visual flow programming tool – check it out at http://www.nodered.org
You can get the Node-RED flow here:
Click on Raw
Copy all the code to the clipboard.
In the Node-RED flow page click on the Menu (three horizontal lines at the top right)
Paste the flow into the grey box
Click somewhere on the flow screen (white area in the middle) to drop the code.
Boom – you should now be gazing at something like:
Now double click the white “Edit the TFL API” node!Double click here for info” node for instructions on how to get the bus route, bus stop and direction information you need.
Double click the “TfL API node” and edit the URL with the information you require.
And that’s the Pi done! Simples!
If you’d like to change the 3-6 minute threshold, just adapt the ‘thresholds’ Function node. For more info on what each node does, why not buy the book “Wiring the IoT” by Lucy Rogers and Andy Stanford-Clark http://shop.oreilly.com/product/0636920049104.do#
Right, time to sort out your hardware.
Take your trusty soldering iron and solder a wire between:
Use the latest open-source Arduino Software (IDE). You can download it here: https://www.arduino.cc
Now plug the WeMos into your computer using a USB cable.
You’ll need to install the following – the readme files have installation instructions.
In the Tools menu:
Download and open the Arduino file busLocalPiv3.ino
In the code, replace the ****’s in
const char* wifi_ssid = "****"
const char* wifi_password = "****"
with your wifi name (ssid) and password.
#define BROKER "192.168.1.28"
with the IP address of your Pi.
If you want to use more than one WeMos connecting to the Pi, each has to have a unique CLIENTID. This can be whatever you like.
#define CLIENTID "BusWeMos1"
Remember we said this nifty little beast transforms into a #Cheerlights light when you’re not using it as a bus alert? Well we’re now going to show you how. Hold tight, ding ding…
First of all, let’s check out this cute 3D printed bus which we’ll light up cheerfully…
Lovingly cover the inside of the upstairs windows with plasticard to give an atmospheric diffuse glow from the neopixel light.
Insert the #WhereIsMyBus and voila! A quirky addition to any bedroom or pad.
We hope you enjoyed creating this brilliant little device – and it makes your (bus) journey through life a little easier.