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.
Follows instructions to install ligpio:
sudo apt install swig python3-dev python3-setuptools
cd /tmp
wget http://abyz.me.uk/lg/lg.zip
unzip lg.zip
cd lg
make
sudo make install
rm -rf /tmp/lg.zip /tmp/lg
# Ensure RPi.GPIO library is installed.
sudo apt-get install python3-rpi-lgpio swig gpiod libgpiod-dev
pip install --user --break-system-packages PiPocketGeiger
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.
Look at the buildlogs folder for examples and more step by step instructions.
python examples/console_logger_signals.py
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()
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.
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.
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!
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!
Created upon the Radiation Watch sample code.
Feel free to open a new ticket or submit a PR to improve the lib.