About David Holstius

Blog author (bio)

Monitoring particulate matter with commodity hardware


Interested readers can now download the full text of my just-released Ph.D. dissertation, titled Monitoring particulate matter with commodity hardware [15 MB PDF]. Chapters 2 and 3 have previously been published as journal articles. New results obtained with the Shinyei PPD42NS sensor are presented in Chapter 4, “Observing urban plumes”.

Continue reading

Field calibrations of a low-cost aerosol sensor

Our  paper on the development and evaluation of a PPD42NS-based instrument is now publicly available via the AMT Discussion forum (Article [PDF]Supplement [PDF]). It’s permanently citable in its existing form, though it will technically be in review until March 24. Hope you find the results to be of interest, dear reader.

PPD42NS sensors on a calibration rack

Affordable PM Sensor Roundup

This is a quick roundup of low-cost dust/haze/smoke sensor modules and fully packaged instruments that I’m aware of. I’ll be adding to it.

Sensor Modules

  • PPD42NS (Shinyei). Used in a couple of hacker/maker/commercial projects going on.
  • DSM501A (?). Available on AliBaba, etc. for $6 or so. h/t to Josh Schapiro.
  • GP2Y1010AU0F (Sharp). Used in some projects (e.g., SensorApp.net‘s) but haven’t seen anyone get a convincingly good signal out of this one yet. Correct me please.

Commercially Available

  • Dylos (DC1100, DC1700, etc). “Small” and “large” particle bins. Great sensitivity. Not sure about the upper end of the range.
  • UCB Particle Sensor. Manufactured by Berkeley Air from a modified smoke detector design. Used in health studies around the globe.

DIY and Research Projects

Fast POSIXct in R

as.POSIXct() can be slow as molasses. Have you ever tried to import a million timestamps in R? Luckily, Simon Urbanek has gifted useRs with fasttime, an R library for quickly parsing timestamps using string manipulation. Install it with:

install.packages('fasttime', type='source', repos='http://rforge.net')

fasttime contains one function, fastPOSIXct, that is restricted to parsing GMT timestamps after 1970-01-01. For many of us dealing with lots of recently acquired time-series data, that’s no problem.

Continue reading

Posted in Code | Tagged

OtterBox + Shinyei PPD42NS

Long hiatus on the blog, but it’s been a busy couple of months. I’ve been doing some rapid prototyping with the Shinyei PPD42NS, pictured above in an OtterBox enclosure with a battery, real-time clock, microSD datalogger, and temperature-humidity sensor. I’m thinking of calling it the Bento, what with all the tasty little sensors inside (and h/t to Lady Ada’s Bento). As you can see, I’m no mechanical engineer. But some folks over in Mech Eng at Berkeley are starting to work with us on enclosures. Nice!

Continue reading

Using a WiFly to Network Air Quality Sensors

The Roving Networks WiFly RN-XV is a nice little device. For $35 at SparkFun you get a low-power 802.11b module with a real-time clock, analog and GPIO pins, basic DNS and HTTP literacy. It’s a perfectly capable wireless sensor node, just by itself. It even has a nifty UART trigger mode, where incoming serial input will send a basic GET request to your favorite URL with the payload tacked on.

Continue reading

This Side Up: Build Notes on the Shinyei

For field-testing purposes, I hacked together some plywood “backpacks”. Each has a small lip that hangs over a laptop screen, and with a few pieces of tape or velcro, it secures nicely to the back without much trouble. Duct tape over the surface helps velcro tabs adhere, so you can velcro on a GPS logger. And you can still screw components into the 1/4″ plywood. Makes it easy to rig up a laptop for a morning’s worth of sensing.

In the process I’ve learned at least two things that could help you getter better data out of your PPD42NS:

Tip #1: The Shinyei PPD42NS has a correct orientation (expressed as “UP” on page 2 of the spec sheet). There’s a resistor at the bottom to generate a thermal updraft to move air through the sensing chamber. In the build above, I drilled three round holes into a Radio Shack enclosure, such that they line up with the exhaust port on the basic Shinyei assembly. I cut out an elongated opening near the bottom to line up with the intake port, and Dremeled out most of the enclosure to make room (hence the two absent screws). In most air sampling devices the movement of air happens through the use of a fan or pump, but this is an elegant and quiet solution. It’s not power-efficient, and it’ll be interesting to see if there’s a better way to accomplish the same goal …

Tip #2: cover the large opening to the sensing chamber. There’s also a note buried in the Shinyei docs that says to do so. Why isn’t it sealed? So the lens can be cleaned after extended use. I settled for taping a piece of stiff paper over the triangular opening (you can see this in the gallery pics below). Seems like this probably changes both the ambient light that reaches the sensor, and the airflow pattern induced by the heating element. H/T to Ajay Pillarisetti.

If you have a tip to share, please leave it in the comments!

Cosm R package

Here we go, an R package with a couple of helpful functions to help you pull your data from the Cosm API:

  • feed_detail() returns JSON-like data as nested lists.
  • feed_history() returns a zoo object representing selected datastreams.

Why zoo objects? Well, zoo is one of the most widely relied-on R packages. It’s a building block, much like the sp package for spatial data. If you’re working with totally ordered observations—like repeated measurements from one sensor or device—then it seems likely that you’ll encounter it sooner or later. (The zoo FAQ and the Time Series R task view explain more about related packages.) R’s “baked-in” ts objects and methods are designed for regular time series, and let’s face it, when you’re logging sensor measurements from a microcontroller, there’s no way your measurements are exactly equally spaced. But they are totally ordered.

Here’s a quick example of what your R code might look like using this package:

If you want to install it and play around, I suggest first installing Hadley Wickham’s excellent devtools package. Then you can just install directly from my GitHub repository, like so: