So… Its turning to crap huh?

Likely you don’t have time to read this then… but in case this is pre-emptive and not reactionary – heres some tips for when you inevitably find yourself at the wrong end of the shovel trying to work your way back to breathing space…

Firstly: Stay calm!
Your a web developer. Yeah people get frustrated, and there’ll be a bit of puffery, but think through what is the worst that could happen. 99% of the time it’ll just be some sites are unavailable for a bit, there may be some reputation damage, or if theres been a mistake with some calculations – there may be some financial repercussions. This is not ideal at all – totally, but getting stuck on this will not help get the problem solved.

Secondly: Start from the top.
In my spare time I enjoy being an audio tech around the place. Troubleshooting is very similar in that world – a mic or speaker or something isn’t working, you work out how to fix it. And the process is the same. Start at the top of the signal chain (ie from the microphone), and check you have signal at each point in the chain from there right on through to the speakers. In development land, The input into the system is the end user – what does their browser hit first. Throw in some logging at that point and make sure the browser gets there. For many PHP frameworks that means starting at the index.php file and then following through a series of includes narrowing down till you find the culprit code / system / resource failure. Don’t be afraid to throw exit statements around – the system is already broken right? If you can be doing this in a development environment – ideal – else do what you can.

Thirdly: Bring your toolbox.
A tradesperson is no good without their tools. Ours is a bit more virtual than most, but the theory is the same. Know how to get log information, get familiar with linux tools like:
grep -rnw ./ -e "text to find" //recursively find text
tail -n50 filename //show last 50 lines of a file
tail -n1000 filename | grep "text to find" //find text in the last 1000 lines of a file

For php – learn how to turn debugging on:

for production environments investigate silently logging to a file – many frameworks support this, so it has minimal client impact. Otherwise send error information via email when it happens, or use services like rollbar or sentry to track issues.
Don’t be afraid to echo and exit. dump what data you do have to the browser so you know your script is on the right track. break your code down into components in order to rule out chunks of code from being the issue. Once you know what isn’t broken, you can quickly hone in on what is.

Lastly: Communicate.
Tell people what is going on. Often talking through a problem is a key to solving it – whether the person understands what you are on about or not. Just by replaying it in your head trying to package the problem for others to understand, you will think through potential areas you have missed checking. Have great communication with the key stakeholders. If people understand what is going on and what you are doing to try to fix the problems, they are likely to be more lenient, but also they are likely to feel part of the team and with a bit of control, rather than on the outside questioning what on earth is going on. Open and honest is the best policy. Don’t hide things. If you’ve cocked up – own it. If a member of your team has dropped the ball – don’t throw them under the bus, but the whole team wears the responsibility of getting things solved and communicating to the client / stakeholders what is going on.

We’re all human. Crap happens. Its how you approach it that makes the difference.

Interaction Projects

Architectural Lighting with website control

Yep – thats right – controlling building lighting from a website. I mean – how hard could it be right? Nowadays there are plenty of apps for your phone to control all manner of LED based lights. But we were keen to take this concept a bit further. So we built

The concept:

Our office is in an old air traffic control tower. We thought it’d be pretty neat to light up the cabinet at the top (the bit with all the windows that the controllers would have sat in) for Christmas, and give people the opportunity to request whatever colour they want the lights to display, through a public web page. Bit of a marketing ploy, but also a fun wee project to flex some of the many skills within our team.

The gear:

  • SP108E LED Wifi Magic Controller (we are using 1 of these to control all LED’s)
  • WS2815 DC12V RGB LED Strip Light (we are using 4 of these – each 5m strip has 60 LED’s per metre, and pulls a total of 90 watts)
  • DC12V LED Power Supply 10A Switch Mode Transformer
  • Wifi access point connected to a network with DHCP (most home wifi routers would do the job fine here)
  • A computer (headless raspberry pi would be more than fine here)
  • A smartphone for initial configuration

The LED’s, power supplies and controller were all sourced from Ali Express relatively cheaply. The rest we “had lying around”…

The hardware setup:

So – one power supply per 5m LED strip. The strips have connectors at each end so you can connect them up for the data connection, and tails (leads allowing power connection) so we connected all 4 LED strips into one long strip. We’ve been careful to make sure that its wired so all turn on at once, so as not to overload any one power supply trying to power all lights at once. Options to do that can be to switch everything on or off all at once, or separate power to each of the LED strips so that each strip can only be powered by one power supply, and the only linking wires between strips are data wires, not V+ or V-.

On one end of the LED strip, attach the SP108E controller. One it is powered up, you’ll need to connect to it using the supplied instructions in the box and their smartphone app, which allows you to set the wifi network that the controller connects to. On your router you should be able to tell the DHCP server to assign a static ip address to the controller, so that you can then consistently connect to the one IP address that controls the LED’s.

Once we can connect to the controller consistantly, we can then put onto the raspberry pi, set the IP address to look at the controller, and start playing. You will likely need to change the LED’s per segment, and number of segments settings to ensure all the LED’s are getting signal and behaving as expected.

How we’ve tweaked it up from there:

We’ve set up a database table to store a colour change queue, and tolde teh php script above to poll that database table for changes. If a change is noticed, we can then fade between colours (the fade is a custom function we have written). We then have a public facing website that allows people to load up colours into the queue, and the building changes colour every minute to reflect the next queue colour. No changes in the queue? It’ll just show the last colour until something new comes along.

Keen to enable this level of control in your building or office space? Its quite neat allowing your people / clients to interact with your building, and also its a draw-card that can be promoted widely – people love getting reaction from actions they have taken.

I’f you’d like to set up something similar, large project or small, get in contact – there are lots of really neat ways to make this happen, this is just one. We can assist with your next project.