A while back I posted an article about an Android app I wrote that allows you to perform real-time vehicle diagnostics using Google Glass and an OBD-II adapter. At the end of that article, I promised I would share the source code once I completed it. Unfortunately, I have lost the final source code for that project. Earlier today, I received an email from a reader asking for an explanation of how to read data from the OBD-II adapter. Since I’ve received several other emails asking this same question, I thought I would turn my reply to that email into a post to share with anyone else that might be interested in doing this.
BTW, I did manage to find an earlier version of that source code in one of my backups which I will share a link to at the end of this article. Just be warned, though, that the code is very messy (there’s a lot of commented out debugging stuff in there), it isn’t documented, and it doesn’t include all of the stuff mentioned in the video at the link above. It also only supports reading RPM & speed information, but I had also started adding support for MPG which wasn’t finished at the time this backup was made. But, this code and the following explanation should be enough to get you started with creating your own Android app that allows you to perform real-time vehicle diagnostics using your Google Glass.
In yesterday’s article, I showed you how to create a Python script that broadcasts a systems’ vitals (diskspace, memory, & CPU) out onto the network. As promised, today I will show you how to create a Python script that listens for these broadcasts and displays the results. I use this script as part of my home automation system and display the results on a touchscreen TFT that’s exposed out the front of an enclosure that houses the main-brain of my home automation system (see pictures below). But, you can do all kinds of other cool things with the results such as selecting Raspberry Pis with unused resources to act as slaves in a distributed computing application (which I will explain in another article). But for now, let’s get started.
In case you haven’t read any of my other home automation articles, I use a lot of Raspberry Pis in my home automation system. Keeping track of them used to be a burden, but not any more. As mentioned in yesterday’s article, I have Raspberry Pis installed in some pretty crazy places. Even though all of the Pis in my house have dedicated functions, some Pis aren’t used as extensively as others. For example, I have Raspberry Pis installed inside the walls of several rooms in my house which act as built-in media centers. But, when those Pis aren’t being used for providing media, I don’t want them sitting there doing nothing. So, I make them contribute their unused resources to the rest of the Pis in my house to get a little extra horsepower for some of the Pis that have more heavy lifting to do (such as the Pis that do face & speech recognition).
In order for me to keep up with which Pis are online and how much free diskspace, memory, and CPU utilization they have available to share with the rest of the house, I wrote a small Python app that runs every time the Raspberry Pi starts up and continues to broadcast its existence and system vitals every 10 seconds (configurable) where I detect those broadcasts and display the results on a touchscreen TFT monitor (which I will explain in my next article). For now, I want to share with you the Python script that broadcasts its system vitals out to any listening system on the network.
In my last 2 articles, I have shared with you code from my home automation system (HAS) controller written in Python that allows you to access your Google Calendar for scheduling events and communicating with the Insteon PowerLinc USB modem for controlling your Insteon and X10 HAS devices from Raspberry Pi (or other dedicated computer).
In today’s article, I want to share with you some Python code that uses OpenCV to detect faces from the Insteon (or FOSCAM) IP Camera which you can get from SmartHome.com for about $79. At my house, I use this code to detect when my fiancee or I approach one of the exterior doors. When we do, my HAS will recognize us and will automagically unlock the door that we are approaching. To do that, I am using the MiLocks 3-in-1 deadbolt system which is also available at SmartHome.com and will run you about $100 per lock. You will also need the MorningLinc Insteon adapter which will allow you to communicate with the MiLocks deadbolts over RF. These are also available from SmartHome.com and will run you about $50. You will only need 1 which is capable of controlling multiple locks.
Before I share the code, I should say that this particular code does NOT include the ability to recognize one person from another like that found in my personal HAS controller. All this code is capable of doing is detecting a face and saving a screenshot of that face to the file system (regardless who the face belongs to). The reason I am not sharing the face matching code yet is because there are a lot of complex steps required to train the system to detect individuals. I am currently working on a way to simplify these tasks. It took me several weeks to prepare the system manually for recognizing my fiancee and I with an acceptable accuracy and to not unlock our doors due to any false positives. Once I get this process simplified, I will share the code.
As explained in yesterday’s article, I have been overhauling my home automation system (HAS) and have decided to release parts of my controller software written in Python and runs on Raspberry Pi. I have been working on breaking apart the controller software so that each piece can be ran standalone. For example, yesterday’s article showed how to read your Google Calendar with Python. By doing that, you can schedule events to occur in your HAS by simply adding items to your Google Calendar.
Today, I want to share with you some Python code that allows you to control Insteon & X10 devices in your HAS using the Insteon PowerLinc USB modem which you can get from http://www.smarthome.com/powerlinc-modem-insteon-2413u-usb-interface-dual-band.html for about $80. Since the PowerLinc requires an always-on computer to be connected to it, it’s recommended to use a low powered computer such as the Raspberry Pi. Since the code below is written in Python, you can also use it from Windows or Mac if you want. Just make sure you change the “port” property in the serial connection to match your environment. If you combine this code with yesterday’s code, you can schedule your lights and other appliances to turn on and off by scheduling items in your Google Calendar.