Did this quick graph recently with my Gmail data to see when I was most likely to send an email. Surprisingly my night-owlness isn’t as apparent as I thought it’d be.
If you’re waiting on an email from me, it’s most likely coming at 11am or 11pm.
Herp Derp’s at 20K+ Chrome users!
In Part 1 of my ‘Raspberry Pi + Garage door’ series, I showed a super simple way to control a garage door with a script that could potentially be ran from the Internet.
This part expands on that and tackles the issue: ‘How do I know the state of my garage door if I’m not at home?’
Because the code operates no differently than someone pressing a single button on the remote control, you would normally have to look with your own eyes to see if you were closing, stopping, or opening the garage door. This can be an issue when your eyes are nowhere close to it.
I wanted to come up with a solution that didn’t involve running new equipment such as a switch to detect the door’s orientation. I decided to utilize what I already had in the garage: A camera. Namely, this one: Foscam FI8910W
The idea is to use the camera to grab an image, pipe that image into OpenCV to detect known objects, and then declare the door open or closed based off of those results.
I whipped up a couple of shapes in Photoshop to stick on the inside of my door:
I then cropped out the shapes from the above picture to make templates for OpenCV to match.
To help make step 3 more accurate, I added a horizontal threshold value which is defined in the configuration file. Basically, we’re using this to make sure we didn’t get a false positive – if the objects we detect are horizontally aligned, we can be pretty certain we have the right ones.
I was happy to find that the shapes worked well in low-light conditions. This may be due to the fact that my garage isn’t very deep so the IR range is sufficient, as well as the high contrast of black shapes on white paper.
Currently I have some experimental code in the project for detecting state changes. This will not only provide more information (e.g. the door is opening because we detect the pentagon has gone up x pixels), but is good for events (e.g. when the alarm system is on, let me know if the door has any state change).
I’ve tested running this on the Raspberry Pi and it works fine, though it can be a good bit slower than a full-blown machine. I have a Raspberry Pi 2 on order and it’ll be interesting to see the difference. Since this code doesn’t need anything specific to the Raspberry Pi, someone may prefer to run it on a faster box to get more info in the short time span it takes for a door to open or close.
I’ve created a video to demo the script in action!
The other day an idea popped in my head for a side project that would involve the Gmail API. Whenever this happens, I normally hit up the developer site, find a simple tutorial, and immediately get my hands dirty.
A quick search led me to this page. It’s called a “Quickstart: Run a Gmail App in Python.” Perfect. I’ll run this script and be on my way in no time. Well, not so fast.
This tutorial assumes I’m doing development on my local machine where it can pop open a web browser and authorize the API access. Most of the time I don’t operate that way – I use a remote Linux server of some kind.
To get this quick start guide working on a remote server:
Now when you run the script, you’ll get a link to copy into any browser to authorize the access. Then, you’ll get an auth code to paste back into your script.
I’ve included both scripts so that you can compare easily. I hope this saves others from frustration and I also hope Google improves the tutorial.
I want to be able to control my garage door from anywhere. Solution? Dedicated Raspberry Pi.
I’ve provided the simplest example here. The next step would be to have the code driven by a web interface that could be loaded on a phone or a web browser.
There will be an exciting part 2 to this article where I take this one step further!
Experimental code: https://github.com/twstokes/arduino-gyrocube
Varying the speed on an RC car motor with the Arduino using PWM.
After upgrading to Yosemite, I noticed that graphics performance was starting to lag a bit on my 2009 Mac Pro while driving two monitors at fairly low resolutions. At one point I had two GT 120s running separate monitors, but after one replacement and two failures, I was back down to one.
I decided to look into upgrade options and was happy to see that OS X now supports non-EFI video cards. The only catch: You won’t see anything displayed until OS X loads your drivers. Who cares?
I settled on an EVGA GeForce GTX 660 2GB, which Best Buy happened to sell. I can feel the judgement from the hardcore nerds for buying something at Best Buy. Nevertheless, this was much cheaper than trying to buy another GT 120 to replace my second one and offers WAY more power. I don’t game on my Mac – I just want the OS to feel snappy and fluid.
Like many powerful cards, the GTX 660 requires the PCIe 6 pin power connector from the power supply or motherboard. I’ve ordered this, but until it gets here, I’ve rigged up an external power source.
Steps to install:
Thoughts after installation:
Mode: 1680×1050 fullscreen on one monitor
Before:
After: