Building a distributed cosmic ray detector in a weekend at CERN Webfest

This weekend I made a Android/Arduino based web enabled Muon (Cosmic ray) detector. I have to give a tonne of thanks to the team who did it with me (Ramviyas, Olof, Brad, Justin and Hugo) who deserve full credit for making it happen. I should also thank the ERGO Telescope team for thinking up the whole scheme of a distributed cosmic ray observatory in the first place and sending us the missing elements for our project.

Our Muon Source


One ERGO pixel unit (which I hacked)

One Geiger-Muller tube and amp/PSU board (which we didn’t use in the end)

One Arduino MEGA ADK

Arduino Mega ADK

One Android Phone (with GPS, running 2.3.4 or better) – we used a Samsung Galaxy Mini GT-S5570

CNY17 optocoupler

Some Arduino Code, some Java and some web scripting

Muon Detector (ERGO Pixel)


1) We hooked up the GM tube (in the end I had to hack the LED on the front of the ERGO box) to the Arduino MEGA ADK via a CNY-17 Opto-isolator. The signals out of the Geiger-Muller tube PCB were a bit too noisy to use straight up, and I didn’t manage to build myself a suitable high impedance device/amp to read them directly. We did the whole project in a weekend, so there wasn’t much time for anything!

Writing code…

2)We wrote some Arduino code that will hook up to an android phone and log events with an accuracy of 0.000212s. This is effectively a polling loop which checks a single input pin repeatedly and sends a signal to the Android when it sees a logical high on the input. The code will take any input on pin2 and output a packet with the relative timestamp to the Android. With this method we can resolve to approx 4700 loop cycles within the Arduino, using a counter (declared as a simple int that we add to). The counter is also re-set each 1s by a signal from the Android GPS clock. Counter values at reset are logged to use for a rolling timing calibration, but we didn’t get chance to implement this in the weekend.
3)We wrote an android app that reads NMEA sentences to get the raw time out of the GPS chipset (tested on Samsung phones running Android 2.3.4 and cyanogenmod) and sends a reset to the Arduino every second based on this value. The app also receives signals from the Arduino with the local timestamp (the loop counter in the Arduino) and adds this to the Navstar time (being the correct name for GPS time) We also correct the Arduino timestamp by multiplication with the constant of 0.000212 (our measured resolvable time interval) which bring the Arduino timestamp into seconds. We couldn’t get the date out of the GPS, so the leapsecond (Navstar time is 13 seconds behind UTC at the moment) correction will be necessary to datestamp it correctly – unless we figure out how to get the date from GPS directly.
4) For the moment we’re pushing it via HTTP post to  Eventually we will send it to the ERGO database, once we have done some more precise measurements of the timing accuracy.

The Android App in action

We have a few things that would also be nice to add:
The Arduino code could do with some optimisation – we can probably increase the timing accuracy significantly (but this will obviously take more time than we had over the weekend) to go beyond the 212 microsecond resolution. It’s also running as a polling loop without any de-bounce, so duplicate readings are a distinct possibility. Using interrupts caused problems with the Arduino crashing, I’ll put it on my list to figure out when I have time.

Our system timing and architecture drawing

Timing calibration has been worked out on the back of an envelope, with some work the Android could do a rolling calibration on the Arduino (so that the 4700 loop cycles are adjusted based on observed performance).

As for the GM tube interface (which I struggled with), SEEED studio make a geiger shield that at first glance it looks like it would plug straight in fine – the design is open source as well. It can be found here:

A great team!

That’s everything for the moment –  here are some links for the resources/websites we used/made:
Source code (arduino and android):
Pirate pads (where we did the working out..)
Tagged , , , , , , , ,

2 thoughts on “Building a distributed cosmic ray detector in a weekend at CERN Webfest

  1. […] Although successful, our prototype showed the clear difficulties that the development of USB accessories for Android presented at the time. Sadly the situation hasn’t improved in the interim, as demonstrated by the almost total absence of USB accessories for Android phones on the market. There was scope for significant cost savings in the ERGO design by using an android phone for GPS and the network uplink, however it wasn’t really practical at the time and still isn’t. We left our prototype, until a couple of years later the Raspberry Pi came out of the technological development oven. You can read the full backstory on my personal blog here. […]

  2. […] for Cosmic Pi dates back to 2012, when a team including Devine and Day got together at CERN’s first “Webfest” hackathon. At that point, they were trying to make an Android-based cosmic ray detector and were inspired by […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: