Tag Archives: Python

Wireless Home Monitor System

Over the past five years or so, I’ve been tinkering with wireless monitoring in my home. One of my first projects in 2010 was the Remote Fuel Oil Gauge that used the OnShine RX/TX pair at 433 MHz.

Shortly after this, I began to explore home environmental sensing, using a new internet service called Pachube (then Cosm, now Xively). I built an internet-linked environmental sensor that’s now installed in my office at NSCAD.

Next step was to build sensors that could wirelessly send data to a base station that would relay it to a central repository on the internet. To do this, I used Jean-Claude Whippler’s JeeNode library that enables the Hope RF12 and RF12B to communicate with each other and a base station JeeLink that can connect directly to a Raspberry Pi using its built-in USB.

Home Sensor Configuration
Home Sensor Configuration

The basic configuration is comprised of the RPi and Python control and communication software that accepts the data from the JeeLink, does some conversions, and then sends it along to Xively. Xively handles the graphing.

Sensor Units

  • Basic Temperature only unit using DS1820
  • Basic Temperature and Humidity unit using DHT22
  • Garage unit: one DHT22 for garage, another DHT22 for “worm box”—Dorothea gives food scraps to worms, which process the scraps to good soil for the garden—plus a carbon monoxide sensor and a garage door open sensor
  • Office unit: one DHT22 plus a PIR sensor to detect activity in the office
  • Kitchen sensor unit: one DHT22. Solar powered.
  • Backyard Shed sensor unit: one DHT22. Solar powered.

Display Unit

There’s one LCD display on the kitchen refrigerator door that displays data from the Garage unit; if the garage door is open, a redLED blinks at .5 Hz.

More on various aspects of the system… later.

RAzer: Another headline cutup program

RAzer results
Results using join word ‘in’ from headlines on Aug. 30, 2014

RAzer is an extra Python gadget behind the rear end of Media Circus.

The source text for Media Circus are ‘cutups’ of headlines, retrieved from RSS feeds of news agencies. Up until this month, I have been using an online php program called ”cutup“ that accesses feeds from the Toronto Globe and Mail and the CBC, cuts them up and re-presents them on a web page. The strategy for this program is simple: count the words in headline 1 and split it through the middle, do the same with headline 2, then combine the front of headline 1 with the back of headline 2, and vice versa.

RAzer retrieves headlines from 12 world sources and re-combines them by identifying common “join words”, such as ’in‘, ‘on’, ‘of’, ‘the’, ‘at’, ‘to’, ‘into’, ‘as’, ‘from’ and ‘over’. Like cutup, the interface is through the web, but in this case the user has a choice of join word, the number of headlines to generate, and whether or not to retrieve a fresh set of headlines. The form data is sent through a post action to a Python script on my little RaspberryPi.


And by the way, here’s another reason to own an RPi: although I’m very happy with my web hosting provider Hostgator, shared hosting accounts have a defined set of Python libraries that are installed, and you can’t add new ones. In the case of RAzer, I needed the feedparser library, which was not included, so I had to use my little guy.

2014 Summer Wrap-up

‘Fake’ Mondrian in his most recognizable style.
‘Fake’ Mondrian in his most recognizable style.

It’s the end of the summer hiatus from teaching and time to summarize:

  • At the beginning of the summer, I got back to drawing. I’m only really satisfied with one drawing, shown in the previous post. Others ‘kind-of’ done and waiting for me to look at them and “yeah, that’s a good drawing”—but this hasn’t happened yet. Maybe I need beer goggles. One other image I did was a Mondrian—not a copy, but trying to use the same strategies of placement of line and colour that he used. I’m happy with this one.
  • Clock with Tics web app: When I published this web app a couple of years ago, I used PhoneGap and XCode, and it all seemed rather complicated to me. I came back to it because I wanted to get up-to-date with the latest tools for making web apps. I found out about the HTML5 “cache manifest” function, which allows the app to function without having to access the server. So now it works more like a ‘real’ app. View the source code.
  • Media Circus web app: I took the time this summer to learn a little more Javascript using CodeAcademy and then settling on CodeAvengers, with the intention of developing a Media Circus web app. It was developed using JQuery Mobile, a development process that was much simpler than PhoneGap/XCode. View the source code.
  • Vegomatic
    Sample run of Vegomatic

    Vegomatic: On an off during the summer, I’ve played with ways to generate headline cutups for Media Circus tweets. Vegomatic uses the Python Natural Language Toolkit (NLTK) library. NLTK is used by scholars to analyze texts, so if, for example, you wanted to know how many times “freedom” is said in every U.S. State of the Union address, NLTK is your tool of choice. I had problems managing unicode characters (such as é and ü), so as a last resort I inserted some code to simply ‘give up’ if it encountered unicode. This is why there’s a unicode error in the example. I consider these experiments in themselves a failure, but they led the way to better things, such as RAzer.

  • RAzer: This is a Python program that does more sophisticated headline cutups for use in Media Circus tweets.
  • allRAzer: As a final, faintly ridiculous conclusion to my efforts to create better tools for making cutups, allRAzer builds a list of cutups using all of the join words that are available in RAzer. Like Vegomatic, this is a Python program that has to be run from a computer that has Python installed.
  • Sectional: This is a theme for RespondCMS. Respond is a responsive content management system that uses Bootstrap 3. I wanted to build a theme to prove that it was possible to create a one-page site in Respond. Mission accomplished.