Automating LIFX Lights With The LightBlue Bean and IFTTT

The LightBlue Bean is a small low energy Bluetooth Arduino microcontroller with a built in 3-axis accelerometer and temperature sensor. It’s quite an interesting way to add connectivity to objects via Bluetooth connectivity instead of Wi-Fi. It has digital and analog pins like a typical Arduino, so you can expand what it can do by adding new elements to the set up.
In order to add new elements, a bit of soldering is required. For this article, I wanted a solder-free demo that anyone with a LightBlue Bean can follow along with, so we’ll be focusing on the built in accelerometer. A few months ago, I put together an IFTTT demo here on SitePoint which automatically turns off my LIFX light when I set my Jawbone UP24 to sleep mode. It is a nice touch but I still need to get my smartphone out to turn on my lights each night. I’d prefer something more automatic and decided to try out a few technology experiments to turn the lights on in convenient ways too. In this article, I’ll cover the first of my prototypes – I’ll be using a LightBlue Bean to detect my door movements and turn my lights on or off depending on if my door is opened or closed.
For those who are a fan of the LightBlue Bean, there is a newer version of the LightBlue Bean on Kickstarter right now called the LightBlue Bean+ which looks pretty neat! It has a rechargable battery, solderless connectors and plenty more useful features. There are only a few days left to put in your pledge!
How This Will Work
Our demo will work like so:
Stick the LightBlue Bean on the door we want to track.
Upload an Arduino sketch which watches for accelerometer changes (the door swinging one way or the other) and sends a message via the Bean Loader Virtual Serial.
Set up a Node server watching for the serial messages coming through.
Set the responses to those messages in the Node server to send a HTTP request to IFTTT’s Maker channel to tell it to turn on the light.
Set the LightBlue Bean to Virtual Serial mode.
Run the Node server and close your door to see your light turn on!
Additional rules could be included in our Node server later on to ensure that the code only runs during certain times of day too (to avoid the light going on when it really doesn’t need to be). Or even better – add on a photo resistor to detect automatically if the light is needed!
Setting Up Your LightBlue Bean
If you are completely new to using the LightBlue Bean, you’ll need to have both the latest Arduino software and the Bean Loader software installed on your Windows 8.1 or Mac computer (apparently the Bean Loader software does not work on older Windows PCs). The guides to getting your LightBlue Bean connected up to your Mac or PC are pretty thorough on the LightBlue Bean website:
Getting Started with Mac OSX
Getting Started with Windows 8.1
This demo has all been set up on Mac OSX but should theoretically work on Windows too.
The steps in this article will assume you are comfortable with the basics of putting a sketch onto your LightBlue Bean, if not, run through the “Getting Started” link for your OS above first.
Our Arduino Sketch Code
All the code is available on GitHub for you to use and adapt for any purpose you choose!
Our Arduino sketch contains most of the brains behind the door watching and looks like so:

int minXVal = 0;
int maxXVal = 0;
int minYVal = 0;
int maxYVal = 0;
int minZVal = 0;
int maxZVal = 0;
int movement = 15;
bool ready = false;
void setup()
Serial.begin();

void loop()
AccelerationReading acceleration = Bean.getAcceleration();
if (!ready)
for (int i = 0; i
if (acceleration.xAxis > maxXVal)
maxXVal = acceleration.xAxis;
else if (acceleration.xAxis
minXVal = acceleration.xAxis;

if (acceleration.yAxis > maxYVal)
maxYVal = acceleration.yAxis;
else if (acceleration.yAxis
minYVal = acceleration.yAxis;

if (acceleration.zAxis > maxZVal)
maxZVal = acceleration.zAxis;
else if (acceleration.zAxis
minZVal = acceleration.zAxis;
}
delay(10);
}
ready = true;
} else
if (acceleration.zAxis
String stringToPrint = “CLOSED”;
Serial.println(stringToPrint);
else if (acceleration.zAxis > maxZVal + movement)
String stringToPrint = “OPEN”;
Serial.println(stringToPrint);

}
Bean.sleep(1000);
}

Our Sketch Code Explained
To start with, you’ll see a range of variables called minXVal, maxXVal, minYVal, maxYVal, minZVal and maxZVal. These track our LightBlue Bean’s initial accelerometer readings. Within my demo code, we only really use the z values, however I’ve left the others in here as you may need to use their values for your own implementations (e.g. if you place the Bean in a different orientation on the door or have a different sort of door, like a sliding door). The accelerometer tracks the force of gravity on each side of the Bean. We only want to know about the changes in these forces, so we need to know the range of forces acting on the Bean originally when it is stationary on our open door. This is where we store those values:

int minXVal = 0;
int maxXVal = 0;
int minYVal = 0;
int maxYVal = 0;
int minZVal = 0;
int maxZVal = 0;

Next we set a variable called movement which is the level of movement we’ll accept before triggering the action. You’ll need to adjust this to suit your own situation (your door may move a lot more subtly whilst open than mine). In the sample code, we’re allowing for movement of about -15 to +15 from our min and max values before we trigger anything:

int movement = 15;

We will need time to run the initial test of the min and max values, so we use the ready variable to tell our loop whether we are ready to start watching for door movements within our min and max ranges:

bool ready = false;

In our setup() Arduino function, we set the serial connection to start running when the Arduino is ready:

void setup()
Serial.begin();

Within our loop, we perform all our watching of our accelerometer values from the Bean. This will all be readable via the acceleration variable we set up at the start of the loop() function:

void loop()
AccelerationReading acceleration = Bean.getAcceleration();
// Our accelerometer tests

Continue reading %Automating LIFX Lights With The LightBlue Bean and IFTTT%

via Reme Le Hane

Why Agile is a Competitive Advantage in a Digital Age

This article was sponsored by Atlassian. Thank you for supporting the sponsors who make SitePoint possible.
Atlassian, the company behind the popular project and issue tracking software JIRA, recently partnered with Harvard Business Review Analytic Services to write a report on the successes of agile software development. The report outlines the recent shift in development trends, and how the increase in competition requires software teams to meet deadlines faster than ever. Moving to an agile workflow is the key to rapid development and release cycles, but there’s a trick to doing agile the right way. Let’s go over a few key points highlighted in the report in order to gain a better understanding of the best way to do agile.
The History of Agile
As it turns out, the agile process has been around for some time. Nearly two decades in fact. But only recently has the method of software development gained acceptance as a mainstream best practice. Although its taken a while to grow in popularity, the report from Atlassian and Harvard states that “IDC estimates the market size for agile lifecycle management tools will surpass $1 billion in worldwide revenues by 2017.” This means that agile’s popularity shows no signs of slowing down. Isn’t it time your team took notice?
So what makes agile so special? As the report outlines, agile differs from the traditional waterfall approach to programming. This waterfall method breaks down programming into several iterative steps, including planning, design development, testing, and implementation. Each step is designed to take place in succession, with no overlap occurring between the next. As you may be aware, this approach has its difficulties. Each step can take a long time to be completed, and often gets delayed due to changing business requirements. Of course the most important reason to choose agile over the waterfall approach is communication. With the traditional waterfall approach, it becomes difficult to create an environment of teamwork and collaboration, since each phase of the project needs to happen successively.
With agile, the waterfall approach is broken up into a much smaller scale, so that incremental parts of the project are can be iterated on at a much faster pace. This in turn promotes teamwork and communication, since all team members are encouraged to work with each other in order to deliver a smaller piece of the whole project.
Continue reading %Why Agile is a Competitive Advantage in a Digital Age%

via Reme Le Hane

Writing PHP Git Hooks with Static Review

If you’ve been using Git for more than a short length of time, you’ll hopefully have heard of Git hooks. If not, Git hooks, as Andrew Udvare introduced here on SitePoint back in August of last year, are scripts which run, based on certain events in the Git lifecycle, both on the client and on the server.

There are hooks for pre- and post-commit, pre- and post-update, pre-push, pre-rebase, and so on. The sample hooks are written in Bash, one of the Linux shell languages. But they can be written in almost any language you’re comfortable or proficient with.
As Tim Boronczyk pointed out in September 2013, there are a wide range of meaningful purposes which hooks can be put to. These include linting, spell-checking commit messages, checking patches against accepted coding standards, running composer, and so on.
Now, PHP’s a great language, don’t get me wrong, but it’s not necessarily the best language for shell scripting. Admittedly, it’s gotten a lot better than it once was. But compared to languages such as Bash, Python, and Ruby, it hasn’t been quite as suitable for creating Git hooks; that is, until now.
Thanks to Static Review, by Samuel Parkinson, you can now write Git hooks with native PHP, optionally building on the existing core classes. In today’s post, I’m going to give you a tour of what’s on offer, finishing up by writing a custom class to check for any lingering calls to var_dump().
Installing the Library
Like most, if not all modern PHP libraries and packages, StaticReview is installable via Composer. To install it in your project, run composer require sjparkinson/static-review in the root of your project. With that, let’s get going.
Continue reading %Writing PHP Git Hooks with Static Review%

via Reme Le Hane

Monday Special: 100 Super High-Res Subtle Textures with a Commercial License – Just $15

You can never have too many textures. Or enough of them for that matter.
In fact, a good collection of textures can be a goldmine for a designer. You can use them in pretty much any design – from backgrounds, to photo overlays, prints, digital work, and much more. You imagination is the only limit.
It can change a design’s look and feel in just a couple of seconds!
But finding a good set of textures can be pretty tough. Most of them are either low-res or incredibly expensive. Luckil…Keep on reading: Monday Special: 100 Super High-Res Subtle Textures with a Commercial License – Just $15

via Reme Le Hane

Create Beautiful and Complete Style Guides with Frontify

Frontify lets yous create your complete and beautiful style guide in less than 5 minutes! It’s simple, fast and fun. Document and maintain your brand or design guidelines with an online tool. Forget about the time consuming manual creation of PDF style guides. Frontify Style Guide makes professional style guide creation a fast and fun […]
The post Create Beautiful and Complete Style Guides with Frontify appeared first on WebAppers.

via Reme Le Hane