用辐射表袖珍盖革监测辐射的图书馆。
PiPocketGeiger的Python项目详细描述
覆盆子皮口袋盖革图书馆
与Radiation Watch Pocket Geiger counter(类型5)接口的覆盆子Pi库
库通过中断(使用RPi.GPIO包)监视Pocket Geiger,并处理CPM和每小时Sievert dose。
进一步了解辐射表FAQ和our blog上的袖珍盖革计数器。实际上,它不是一个合适的盖革-穆勒计数器,而是一个能够有效计数伽马射线的光电二极管管脚传感器
入门
安装库
Python2
sudo pip install PiPocketGeiger
Python3
sudo pip3 install PiPocketGeiger
接线
Pocket Geiger必须连接到覆盆子PI的GPIO端口。请参阅您的RPI版本的GPIO管脚规范。
例如,你可以把辐射管和噪声管分别接在树莓皮的GPIO24
和GPIO23
上。
Pocket Geiger pin | Raspberry Pi pin | Standing for |
---|---|---|
^{ | ^{ | Alimentation pin (DC 3V~9V) |
^{ | ^{ | Ground pin |
^{ | ^{ | Radiation-detection pulse pin |
^{ | ^{ | Noise-detection pulse pin |
使用的管脚在创建库对象时指定:
with RadiationWatch(24, 23) as radiationWatch:
pass # Do something with the lib.
即使Pocket Geiger可以处理3V到9V之间的电压,RPi GPIO只能在3.3V电平下工作,因此^{Str 1}$不向Pocket Geiger提供5V,而是提供3.3V。
Pocket Geiger Type 5 interface specification。
初始化库
您可以使用with
语句初始化库的实例。它将自动引导实例,并在存在{{CD11}}块时正确关闭该实例。
with RadiationWatch(24, 23) as radiationWatch:
# Do something with the lib.
print(radiationWatch.status())
您还可以使用setup()
和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()
获取读数
要获取读数,请调用status()
方法:
print(radiationWatch.status())
# {'duration': 14.9, 'uSvh': 0.081, 'uSvhError': 0.081, 'cpm': 4.29}
然后根据结果做你需要的任何事。例如,log them to a terminal或write them on a file
对辐射击中的反应
库允许注册在辐射或噪声检测时将调用的回调,分别使用register_radiation_callback()
或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)
这可以用来模拟典型的Geiger counter click sound或作为随机生成器
实时绘制流
作为一个更具说服力的想法,您可以直接将数据流到plotly,从而方便地共享数据。请参阅complete exemple。
同样,您可以upload reading to a Google Docs或者也可以broadcast on Twitter。
最后,如果您想为开放数据计划做出贡献,您可以publish your measurements到the Safecast API。关于SafecastPy lib repo的更多信息。
是的,有了覆盆子皮,Python和互联网接入,你可以假装的东西没有那么多限制
关于噪音的说明
记住袖珍盖革在振动时不能正确记录。对于更精确和面向移动的单元,您可以查看Safecast项目中的bGeigie Nano
喜欢吗?没那么多Simply tell us。别忘了结账our blog!:-)
快乐黑客
学分
在Radiation Watch sample code上创建。
贡献
随时可以open a new ticket或者提交一个PR来改进lib