Raspberry Pi library for the Radiation Watch Pocket Geiger
Python Makefile
Switch branches/tags
Nothing to show
Clone or download

README.md

Raspberry Pi Pocket Geiger library

Build Status

A Raspberry Pi library to interface with the Radiation Watch Pocket Geiger counter (Type 5).

The library monitors the Pocket Geiger through interrupts - using the RPi.GPIO package - and processes the CPM and hourly Sievert dose.

Learn more about the Pocket Geiger counter on the Radiation Watch FAQ and on our blog. Actually it is not a proper Geiger-Müller counter, but a Photodiode PIN sensor that can effectively counts gamma rays.

Getting started

Install the library

PiPocketGeiger on Pypi.

Python 2

sudo pip install PiPocketGeiger

Python 3

sudo pip3 install PiPocketGeiger

Wiring

The Pocket Geiger must be wired to the GPIO ports of the Raspberry Pi. Refer to the GPIO pin specification of your RPi revision.

For exemple you can wire the radiation and the noise pin on respectively the GPIO24 and GPIO23 of your Raspberry Pi.

Pocket Geiger pin Raspberry Pi pin Standing for
+V 3V3 Alimentation pin (DC 3V~9V)
GND GND Ground pin
SIG GPIO24 Radiation-detection pulse pin
NS GPIO23 Noise-detection pulse pin

The pin used are specified at the creation of the library object:

with RadiationWatch(24, 23) as radiationWatch:
  pass # Do something with the lib.

Even if the Pocket Geiger can handle voltage between 3V and 9V, the RPi GPIO only works on 3.3V levels, so do NOT supply 5V to your Pocket Geiger, but 3.3V instead.

Pocket Geiger Type 5 interface specification.

Initialize the library

You can either use the with statement to initialize an instance of the library. It will automatically bootstrap the instance and properly close it when existing the with block.

with RadiationWatch(24, 23) as radiationWatch:
    # Do something with the lib.
    print(radiationWatch.status())

You can also manage yourself the lifecycle of the instance, using setup() and close().

# Create an instance.
radiationWatch = RadiationWatch(24, 23)
# Initialize it (setup GPIOs, interrupts).
radiationWatch.setup()
# Do something with the lib.
print(radiationWatch.status())
# Do not forget to properly close it (free GPIOs, etc.).
radiationWatch.close()

Getting readings

To get readings, call the status() method:

print(radiationWatch.status())
# {'duration': 14.9, 'uSvh': 0.081, 'uSvhError': 0.081, 'cpm': 4.29}

Then do whatever you need with the results. For exemple, log them to a terminal or write them on a file.

React on radiation hits

The library allows to register callbacks that will be called in case of radiation or noise detection, using respectively the register_radiation_callback() or register_noise_callback():

def onRadiation():
    print("Ray appeared!")
def onNoise():
    print("Vibration! Stop moving!")
with RadiationWatch(24, 23) as radiationWatch:
   radiationWatch.register_radiation_callback(onRadiation)
   radiationWatch.register_noise_callback(onNoise)
   while 1:
       time.sleep(1)

This can be used to simulate the typical Geiger counter click sound or as a random generator.

Stream in real-time on Plotly

As a more ellaborate idea, you can stream the data directly to Plotly, allowing to sharing it easily. See the complete exemple.

In the same vein, you can upload reading to a Google Docs or also broadcast on Twitter.

Finally if you want to contribute to an open-data initiative you can publish your measurements to the Safecast API. More info on the SafecastPy lib repo.

Yes, with a Raspberry Pi, Python and an internet access, there's not so much limits to what you can pretend!

Note on Noise

Remember the Pocket Geiger can't record correctly in presence of vibration. For a more precise and mobile oriented unit, you may look at the bGeigie Nano from the Safecast project.


Like it? Not so much? Simply tell us. Don't forget to check out our blog! :-)

Happy hacking!

Credits

Created upon the Radiation Watch sample code.

Contribute

Feel free to open a new ticket or submit a PR to improve the lib.